How do I list all LDAP users/members?
To list all the users in the directory, do a search for all possible objectClasses that a user account could have, for example:
ldap.DN = "dc=JUNGLE";
//specify the attributes you'd like returned for each search result
//if no attributes are specified, all attributes will be returned
ldap.Attributes.Add(new LDAPAttribute("displayName"));
ldap.Attributes.Add(new LDAPAttribute("name"));
ldap.Attributes.Add(new LDAPAttribute("cn"));
ldap.Attributes.Add(new LDAPAttribute("sn"));
ldap.Attributes.Add(new LDAPAttribute("givenName"));
ldap.Attributes.Add(new LDAPAttribute("ou"));
ldap.Attributes.Add(new LDAPAttribute("o"));
ldap.Attributes.Add(new LDAPAttribute("objectClass"));
ldap.Attributes.Add(new LDAPAttribute("userAccountControl"));
ldap.Attributes.Add(new LDAPAttribute("isAccountEnabled"));
ldap.Attributes.Add(new LDAPAttribute("loginDisabled"));
ldap.Attributes.Add(new LDAPAttribute("acctFlags"));
ldap.Attributes.Add(new LDAPAttribute("sambaAcctFlags"));
ldap.Search("(|(|(|(|(|(objectClass=user)(objectClass=posixAccount))
(objectClass=person))(objectClass=organizationalPerson))
(objectClass=inetOrgPerson))(objectClass=computer))");
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.