I have a problem about a connection to an LDPS server with C# code.
I'm working on Windows server 2003 SP2 and i try to connect to an LDAP server with a c# code.
The framework is .net 2.0
Ther error that the .net show me is:
Code:81 Cannot connect to ldap server
The code that i use is this :
LdapConnection con = new LdapConnection(new LdapDirectoryIdentifier(szLdapId));
con.AuthType = AuthType.Basic;
con.Credential = new NetworkCredential(szUserName, szPassword);
con.Timeout = new TimeSpan(1, 0, 0);
con.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback); // the server callback function return a true value
con.SessionOptions.ProtocolVersion = 3;
con.SessionOptions.SecureSocketLayer = true;
con.Bind();
the variable szLdapId is "servername:636"
The bind connection throw me an exception: "The LDAP server is unavailable."
I try to connect to ldap server with Apache DirectoryStudio and o can connect without problem.
The only thing that i see is that the variable
con.SessionOptions.SecureSocketLayer
is set to false also after i set it to true, i try to force it to true but it don't change I try to make some test it windows server 2008 and it works.
Andrea