LDAP over SSL connectivity RRS feed

  • Question

  • User950454326 posted

    Hi all,

    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


            End Try

    Monday, December 3, 2018 3:07 PM

All replies