Search code examples
c#asp.netactive-directoryldapldap-query

How to decide if a SearchResultEntry is a user or a group?


I am using LDAP search to find users and groups in active directory.

here is my search filter:

string Filter = "(|(&(objectCategory=user)(objectClass=person)(SAMAccountName=*))(&(objectCategory=group)(sAMAccountName=*)))";

I get a SearchResponse and I want to decide for every SearchResultEntry if it is a user or a group.

Is there an attribute I can check in order to decide if it is a user or a group?

Thanks, Inbal


Solution

  • I used "objectClass" attribute which says "user" or "group"