connecting problem in with ldap to active directory

Sep 26, 2016
Reaction score
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)

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 sUid, String sPwd) in C:\inetpub\wwwroot\ums\business\UsrMgmtBus.vb:line 127"

Please help. Thanks a lot.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads