Last post Dec 04, 2018 03:16 AM by Nan Yu
Dec 03, 2018 03:07 PM|DevD|LINK
I am trying to connect to AD using LADP over SSL. I have following code, but I am getting exception (The LDAP server is unavailable). I can able to connect using LDAP test application on both 636 and 389 ports. I can able to connect using 389 port
but not from 636 port from below code.
Please suggest me if I am doing something wrong in my code.
Dim ldapErrorInvalidCredentials As Integer = &H31
Dim activeDirectoryServer As String = "xyz.test.com:636"
Dim activeDirectpryDomain As String = "test.com"
Dim ldapConnection As LdapConnection = Nothing
Dim user As String = "testUser"
Dim ldapPort As String = "636"
Dim Success As Boolean = False
ldapConnection = New System.DirectoryServices.Protocols.LdapConnection(activeDirectoryServer)
ldapConnection.SessionOptions.SecureSocketLayer = True
ldapConnection.SessionOptions.ProtocolVersion = 3
ldapConnection.AuthType = AuthType.Negotiate
' ldapConnection.SessionOptions.VerifyServerCertificate = New VerifyServerCertificateCallback(ldapConnection, cert)
ldapConnection.AutoBind = False
'ldapConnection.Credential = New NetworkCredential(username, password, activeDirectpryDomain)
Dim cert As X509Certificate = New X509Certificate()
ldapConnection.Bind(New NetworkCredential(user , "testpassword", activeDirectpryDomain))
Console.WriteLine(("Successfully authenticated to ldap server " & activeDirectoryServer))
Catch ex As Exception
Dec 04, 2018 03:16 AM|Nan Yu|LINK
Please try to use the Ldp.exe tool on the domain controller to try to connect to the server by using port 636. If you cannot connect to the server by using port 636, see the errors that Ldp.exe generates. Also, view the Event Viewer logs to find errors