Here’s an extremely simple application that will query Active Directory for a user’s full name when given their username.
Compiled program download link: http://cjwdev.co.uk/…/GetRealNameFromAD/GetRealNameFromAD.zip
and here is the source code for the main function if anyone is interested:
''' Finds a user's combined first name and surname from Active Directory given their username
''' <param name="UsernameToFind">The username (sAMAccountName) to search for</param>
Private Function GetRealNameFromAd(ByVal UsernameToFind As String) As String
Using searcher As New DirectorySearcher(New DirectoryEntry())
searcher.PageSize = 1000
searcher.SearchScope = SearchScope.Subtree
searcher.Filter = "(&(samAccountType=805306368)(sAMAccountName=" & UsernameToFind & "))"
Using Results As SearchResultCollection = searcher.FindAll
If Results Is Nothing OrElse Results.Count <> 1 Then
Throw New ApplicationException("Invalid number of results returned – either no users were found or more than one user account was found")
Using UserDE As DirectoryEntry = Results(0).GetDirectoryEntry
Return CStr(UserDE.Properties("givenName").Value) & " " & CStr(UserDE.Properties("sn").Value)