I'm using the following code, which works, to login a user to an application built in VB.NET against active directory.
This code works great but I need to retreive the user's first name, last name, display name and also check if the user is part of a group.
I've tried many forms of adResults.Property("displayname").ToString() and the like but just can't get it to work right.
Anyone have any ideas how to do what I'm looking to do?
Here's the code I'm using now and thanks in advance.
Public Function ValidateActiveDirectoryLogin(ByVal sDomain As String, ByVal sUserName As String, ByVal sPassword As String) As Boolean
Dim bSuccess As Boolean = False
Dim adEntry As New System.DirectoryServices.DirectoryEntry("LDAP://" & sDomain, sUserName, sPassword)
Dim adSearcher As New System.DirectoryServices.DirectorySearcher(adEntry)
adSearcher.SearchScope = DirectoryServices.SearchScope.OneLevel
Try
Dim adResults As System.DirectoryServices.SearchResult = adSearcher.FindOne
bSuccess = Not (adResults Is Nothing)
Catch ex As Exception
bSuccess = False
MsgBox("Error")
End Try
Return bSuccess
End Function