troubleshooting Question

Cannot connect to LDAP in ASP .Net

Avatar of one1082
one1082 asked on
ASP.NET ProgrammingC#
7 Comments1 Solution2131 ViewsLast Modified:
Hello, I'm having trouble connecting to an LDAP server within ASP .Net 2.0 using C#.  I can connect to the server via the Softerra LDAP Browser but when I try to add the credentials and run through asp it blows up.  
These are my settings in Softerra:
Host: 111.222.333.444
Port: 389
Base: ou=people,o=xxx

User DN: cn=fn.ln,ou=people,o=xxx
Password: password

LDAP Settings -> Connection Options:
Filter: (objectClass=*)


Here is my code in ASP:

                DirectoryEntry de = new DirectoryEntry();
                de.Path = "LDAP://111.222.333.444:389/ou=people,o=xxx";
                de.Username = "cn=fn.ln,ou=people,o=xxx";
                de.Password = "password";

                DirectorySearcher srch = new DirectorySearcher(de);
                srch.Filter = "(";

                using (SearchResultCollection results = srch.FindAll())
                    foreach (SearchResult res in results)
                        Console.WriteLine("\t{0}", res.Path);

The error occurs with this line:
     using (SearchResultCollection results = srch.FindAll())


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

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros