I am trying to connect to active directory over ssl using .net System.DirectoryServices.Protocols
namespace api
Here is the snippet that I have written for connecting to active directory
LdapConnection ldapConnection = new LdapConnection(new LdapDirectoryIdentifier("<ipaddress>:<port>"));
ldapConnection.AuthType = AuthType.Basic;
LdapSessionOptions options = ldapConnection.SessionOptions;
options.SecureSocketLayer = true;
options.ProtocolVersion = 3;
X509Certificate cert = new X509Certificate();
cert.Import(@"E:\client.crt");
ldapConnection.ClientCertificates.Add(cert);
ldapConnection.Credential = new NetworkCredential("administrator", "xxxxxxxxxx");
ldapConnection.Bind();
Console.WriteLine("successfully connected");
When I am trying to execute this snippet, I always get LDAP server unavailable error. I've written a JAVA equivalent for the same and it is able to connect to server, so I think there is no issue with the certificate or active directory connection. I am also able to connect to Active directory without ssl, using the same IP address and port 389.
Thanks