error authenticating to active directory
Hi, I keep getting this error when I try to authenticate my windows form against our AD domain controller...
System.Runtime.InteropServices.COMException: The server is not operational
The source code that authenticates to our domain controller is:
Dim _domain as String = "connect2.com"
Dim _domainUID as String = "icadmin"
Dim _domainPWD as String = "password"
Dim _path As String
Dim _login As String
Dim _filterAttribute As String
Public Function Authenticate(ByVal username As String, ByVal pwd As String) As Boolean
Dim domainAndUsername As String = _domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://" + _domain, username, pwd)
Try
'Bind to the native AdsObject to force authentication.
Dim obj As Object = entry.NativeObject
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & username & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
Return False
End If
'Update the new path to the user in the directory.
_path = result.Path
_login = username
_filterAttribute = CType(result.Properties("cn")(0), String)
Return True
Catch ex As Exception
Return False
End Try
End Function
I would really appreciate any help you can give me for this one!
Regards,
Marlon
|