Question connecting problem with ldap to active directory

hakeem122

New member
Joined
Sep 26, 2016
Messages
2
Programming Experience
10+
I am upgrading our servers and .net application from windows 2000 to the newly-purchased windows 2012R2 servers. There is one function which works in windows 2000 but doesn?t work in windows 2012R2.


I am running an .net 2.0 internal application in windows 2000 and IIS 5.0 using Visual Studio professional 2015. There is one function in this application which will make a function call to an AD server using LDAP to check the login id and password in Active Directory. It is running perfectly fine before. However, once I upgrade to this new window2012R2 server running .net 2.0, it doesn?t work. The function in the application is not able to get authorization in the Active Directory. The function as below:

        Private Function IsAuthenticatedByAD(ByVal sUid As String, ByVal sPwd As String) As Boolean


            Dim direntRoot As DirectoryEntry, direntUsr As DirectoryEntry
            Dim sDomain As String, sDomainAndUid As String
            Dim dirsrchUsr As DirectorySearcher, oNative As Object


            direntRoot = New DirectoryEntry("LDAP://rootDSE")
            sDomain = direntRoot.Properties("DefaultNamingContext")(0)


            sDomainAndUid = String.Format("{0}\{1}", sDomain, sUid)
            direntUsr = New DirectoryEntry(direntRoot.Path, sDomainAndUid, sPwd)


            Try
                oNative = direntUsr.NativeObject
            Catch ex As Exception
                Return False
            End Try


            Return True


        End Function




The username existed in AD and the password is correct for sure. I received error message in the "Try" section when run oNative = ....
The error message as below:


"System.DirectoryServices.DirectoryServicesCOMException (0x8007052E): The user name or password is incorrect." & vbCrLf & vbCrLf & " at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)" & vbCrLf & " at System.DirectoryServices.DirectoryEntry.Bind()" & vbCrLf & " at System.DirectoryServices.DirectoryEntry.get_NativeObject()" & vbCrLf & " at ums.business.UsrMgmtBus.IsAuthenticatedByAD(String sUid, String sPwd) in C:\inetpub\wwwroot\ums\business\UsrMgmtBus.vb:line 127"


Please help. Thanks a lot.
 
Last edited by a moderator:

hakeem122

New member
Joined
Sep 26, 2016
Messages
2
Programming Experience
10+
[FONT=&quot]I am stuck and really desperate. Can anyone please help? I appreciate that.[/FONT]
[FONT=&quot]I am stuck and really desperate. Can anyone please help? I appreciate that.[/FONT]
 
Top Bottom