Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Get user's LDAP attribute with C# in asp.net

Avatar of jculkincys
jculkincysFlag for United States of America asked on
.NET ProgrammingASP.NET
4 Comments1 Solution4237 ViewsLast Modified:
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
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 CERTIFIED SOLUTION
Avatar of CB_Thirumalai
CB_ThirumalaiFlag of India image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers