Hi, I got the following code from microsoft website to authenticate against AD but this code only valid with LDAP and not with WinNT:// because it uses DirectorySearcher which is not supported by WinNT://
How can I modify it to autheiticate agains AD with WinNT:// ?
Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal pwd As String) As Boolean
Dim domainAndUsername As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry(_path, domainAndUsername, pwd)
'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 & ")"
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
'Update the new path to the user in the directory.
_path = result.Path
_filterAttribute = CType(result.Properties("cn")(0), String)
Catch ex As Exception
Throw New Exception("Error authenticating user. " & ex.Message)