2

I am new to LDAP. I am trying to connect to LDAP using my certificate credentials and no user name and password. The code i am using is

    LdapConnection ldapConnection = new LdapConnection(new LdapDirectoryIdentifier("ldap://192.168.10.5:636"));
    ldapConnection.AuthType = AuthType.Anonymous;
    LdapSessionOptions options = ldapConnection.SessionOptions;
    options.SecureSocketLayer = true;
    options.ProtocolVersion = 3;
    X509Certificate cert = new X509Certificate();
    cert.Import(@"c:\certfolder\mycert.crt");
    ldapConnection.ClientCertificates.Add(cert);
    ldapConnection.Bind();

The above code is giving me error "The LDAP server is unavailable" when compiler tries to run line ldapConnection.Bind();.

When i place a breakpoint at line1 it gives the following error. base{system.DirectoryService.Protocols.DirectroyException}{"The server cannot handle directory request."}

user3202862
  • 207
  • 4
  • 19

1 Answers1

0

Same code without prefix worked for me.

LdapConnection nconnection = new LdapConnection(new LdapDirectoryIdentifier(LDAPurl, LDAPPort));

or

LdapConnection nconnection = new LdapConnection(new LdapDirectoryIdentifier("localhost:10636"));

Both are working fine.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
swathi
  • 1
  • 2