I am using asp.net 2.0 with C#. I am authenticating users against LDAP and that is working fine. Once they are authenticated, I want to pull more information from LDAP, however, I have noticed that not all users will return information such as memberof. I am however able to get the displayName. I have the LDAP connection string in the web.config file, and I created a special user account that I use to query LDAP. Below is the code that I am using. For some reason not all users will return memberof information.
Please see the attached code snippet.
With the code, the display name is set regardless of the user, the memberOf will only set on certin users. I have looked through my LDAP directory and I do not see a connection between the users that do not show.
Any help would be appreciated.
DirectoryEntry entry = new DirectoryEntry();
DirectorySearcher Dsearch = new DirectorySearcher(entry);
String filterText = "sAMAccountName=" + _userName;
Dsearch.Filter = filterText;
SearchResult sResultSet = Dsearch.FindOne();
if (sResultSet.Properties["displayName"].Count > 0)
_displayName = sResultSet.Properties["displayName"].ToString();
string memberOF = (String)sResultSet.Properties["memberof"];