illegal search
do the police have the right to ask question to you when you are visiting someone at there apartment. An if so aren't they suppose to give you there badge number? If asked.
Re: illegal search
Yes, they have the right to ask anything that they want to. Depending on the SPECIFIC circumstances, you probably have no obligation to answer any question. They should identify themselves. If they did not, just contact the police to find out who it was, although from your post, I see nothing that they did that was wrong.
The badge number is on their badeg.
The name is usually on their uniform.
Just look for it.