The following function validates a username and password against an active directory.
VB Code:
  1. Private Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal Username As String, ByVal Password As String) As Boolean
  2.         Dim Success As Boolean = False
  3.         Dim Entry As New System.DirectoryServices.DirectoryEntry("LDAP://" & Domain, Username, Password)
  4.         Dim Searcher As New System.DirectoryServices.DirectorySearcher(Entry)
  5.         Searcher.SearchScope = DirectoryServices.SearchScope.OneLevel
  6.         Try
  7.             Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
  8.             Success = Not (Results Is Nothing)
  9.         Catch
  10.             Success = False
  11.         End Try
  12.         Return Success
  13.     End Function
This would be used like:
VB Code:
  1. If ValidateActiveDirectoryLogin("VBForums", "Woof", "Mouse") Then
  2.    'do something
  3. End If
Woka