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
This is what I did and I am able to connect to AD over SSL. You said you have Java program connecting to the same server over SSL. Are you running the Java program from the same machine as your c#? if not and in case of a self signed certificate in AD, install that certificate in your client machine and try.