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




Reply With Quote