2

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

Dudu
  • 33
  • 1
  • 9

1 Answers1

0

Please take a look at Unable to turn on SecureSocketLayer with DirectoryServices.Protocols.LdapConnection

It says that SessionOptions.SecureSocketLayer may not be the problem.

Community
  • 1
  • 1
garrik
  • 63
  • 1
  • 7
  • Ok but where is the problem? :D I modify the start post adding that: in win 2008 all works fine and the error when i make the bind is: Cannot connect to ldap server (error code 81) – Dudu Mar 29 '12 at 09:16