Click here to Skip to main content
15,066,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
How to connect as anonymous user to ldap server through c# .net?
Bernhard Hiller 24-Apr-13 2:43am
And then do what? Anonymous connections may be blocked by the configuration of the server - even for reading data.
Member 9762654 24-Apr-13 2:51am
i have to access directories of mozilla thunderbird through c# .net coding using ldap. I am having server ip, username and password how to do this?

1 solution

"The following code examples show how to search for all users in a domain. It contains some basic required tasks such as using a C# try-catch or Visual Basic .NET try-catch-finally statement to catch errors and error handling for all the errors that can be thrown by the DirectorySearcher object."[^]

    string username =@"your username"
    string password =@"your password"
    // Bind to the users container.
    DirectoryEntry entry = new DirectoryEntry("LDAP://CN=users,DC=fabrikam,DC=com",username,password);
    // Create a DirectorySearcher object.
    DirectorySearcher mySearcher = new DirectorySearcher(entry);
    // Create a SearchResultCollection object to hold a collection of SearchResults
    // returned by the FindAll method.
    SearchResultCollection result = mySearcher.FindAll();
    // Get search results. For more information, see Getting Search Results.
    // ...
    // This sample uses Try...Catch to catch errors.
    // Create an Exception object. For more information, see System.Exception.
catch (System.Runtime.InteropServices.COMException)
    System.Runtime.InteropServices.COMException exception = new System.Runtime.InteropServices.COMException();
catch (InvalidOperationException)
    InvalidOperationException InvOpEx = new InvalidOperationException();
catch (NotSupportedException)
    NotSupportedException NotSuppEx = new NotSupportedException();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900