My question involves criminal law for the state of: NY City of: New York

My friend was arrested for smoking marijuana inside of a FTAP building. FTAP is the Federal Trespass Affidavit Program which allows the NYPD to go inside buildings when owners register their buildings for this program. The police were looking to see if anyone was trespassing and found my friend smoking marijuana. My friend wasn't trespassing. He was just visiting a friend. They charged him with Criminal Possession of Marijuana 5th degree. Is this arrest legal? My friend wasn't smoking in a public place. It was a building. It was in the hallway.