Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

S.DS.P The LDAP server is unavailable

Last post 09-02-2010, 10:56 AM by Nuno. 1 replies.
Sort Posts: Previous Next
  •  09-02-2010, 10:16 AM 8533

    S.DS.P The LDAP server is unavailable

    Normal 0 21 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

    Hello,

     

    I'm trying to connect to an LDAP Server (active directory) from C# using System.DirectoryServices.Protocols in order to obtain the user mail.

    Here’s a summary of the code I’m using:

     

    LdapConnection _connect = new LdapConnection("serverdns.test");

    _connect.Credential = new NetworkCredential(username, password, domain);

    _connect.AuthType = AuthType.Basic;

    _connect.Bind();

     

    The Bind operation always fails with the message: "The LDAP server is unavailable."

    I can connect to the same server using the following code:

     

    DirectoryEntry entry = new DirectoryEntry(path, username, password, AuthenticationTypes.Secure);

    DirectorySearcher searcher = new DirectorySearcher(entry);

    searcher.Filter = string.Concat("(SAMAccountName=", username, ")");

    SearchResult searchResult = searcher.FindOne();

     

     What could be the problem with the first piece of code?

     

    Thanks,

     

    Nuno

  •  09-02-2010, 10:56 AM 8534 in reply to 8533

    Re: S.DS.P The LDAP server is unavailable

    Changing the AuthType resolved the problem:

    _connect.AuthType = AuthType.Negotiate;

    Thanks,

    Nuno
View as RSS news feed in XML