jculkincys
asked on
Get user's LDAP attribute with C# in asp.net
I want to connect to a Sun LDAP server using C# in asp.net and check to see if a given user has a specific LDAP attribute. Below is the code that I have so far but its not working.
The netid variable is set to a string that contains the username
The netid variable is set to a string that contains the username
DirectoryEntry de = new DirectoryEntry("LDAP://myldapserver/o=my1sto,o=my2ndo,ou=People");
de.Username = "user";
de.Password = "password";
DirectorySearcher searcher = new DirectorySearcher(de);
searcher.Filter = "(uid=" + netid + ")";
searcher.SearchScope = SearchScope.Subtree;
// I want to see if the given user has the pdsRole attribute set to a specific value - lets sat "TEST"
searcher.PropertiesToLoad.Add("pdsRole");
SearchResult oResult = searcher.FindOne();
// its from here that I get confused
// am I using the SearchResult object class right?
// How do I extract values from it and check them
ASKER
I get the following error
CS0103: The name 'GetGroups' does not exist in the current context
CS0103: The name 'GetGroups' does not exist in the current context
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you got the solution for this?
Open in new window