aspvbnetnerd
Programmer
I have this code to validate a login to a Active Directory.
Now I also want to retrieve the user FirstName and LastName from Active Directory.
Does anyone have experience working with DirectoryServices and can help me with my problem?
/George
Code:
Private Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal Username As String, ByVal Password As String) As Boolean Implements IActiveDirectory.ValidateActiveDirectoryLogin
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
If (My.User.IsInRole(AD_GROUP)) Then
Success = Not (Results Is Nothing)
End If
Catch
Return False
End Try
Return Success
End Function
Does anyone have experience working with DirectoryServices and can help me with my problem?
/George