Question OpenLDAP and Invalid Credentials

enrique

New member
Joined
Feb 13, 2014
Messages
1
Programming Experience
10+
Hi all,

This is my first post in this forum.

I'm using the LDAPTest function below to authenticate users accounts from OpenLDAP, and get Invalid Credentials exception despite of working with Softerra LDAP Browse.

I need you to help me see what else I can check. Where to see.

Regards,

Enrique.

Working on ASP.NET, NET Framework 4.5, Windows Server 2012


VB.NET:
Function LDAPTest(ByVal strUser As String, ByVal strPassword As String) As Boolean

    Dim bolAuthenticated As Boolean = False


    Dim strLdapServer As String = "ldap.server.com"
    Dim intLdapPort As Integer = 389
    Dim intLdapProtocolVersion As Integer = 3


    Dim strLdapUserIdField As String = "cn"
    Dim strLdapUserDomain As String = "ou=People,dc=server,dc=com"
    Dim strUserFCD As String = String.Format("{0}={1},{2}", strLdapUserIdField, strUser, strLdapUserDomain)


    Dim oldapDirectoryIdentifier As New LdapDirectoryIdentifier(strLdapServer, intLdapPort, True, False)


    Dim oldapNetworkCredential As New NetworkCredential(strUserFCD, strPassword)


    Dim oldapLdapConnection As New LdapConnection(oldapDirectoryIdentifier, oldapNetworkCredential, AuthType.Basic)


    oldapLdapConnection.SessionOptions.ProtocolVersion = intLdapProtocolVersion


    Try
        oldapLdapConnection.Bind()
        bolAuthenticated = True
        LogError("Usuario v?lido!", Nothing)
    Catch lex As LdapException
        If lex.ErrorCode = 49 Then
            bolAuthenticated = False
            LogError("Usuario inv?lido:" & strUserFCD, lex)
        Else
            LogError("LdapException - oldapLdapConnection.Bind()", lex)
        End If
    Catch doex As DirectoryOperationException
        Dim strError As String = String.Format("DirectoryOperationException - oldapLdapConnection.Bind(){0}    User:{1}", vbNewLine, strUserFCD)
        LogError(strError, doex)
    Catch ex As Exception
        LogError("Exception - oldapLdapConnection.Bind()", ex)
    End Try


    oldapLdapConnection.Dispose()


    Return bolAuthenticated


End Function
 
Back
Top