Here's an example of how you can retrieve a user's full name from Active Directory when you just have their username (which is all you can get via managed code - not even sure if there is any way to get their full name via Windows API without querying AD).

You need to add a reference to System.DirectoryServices before this will work.

vb.net Code:
  1. 'Import System.DirectoryServices at the top of your class
  2.  
  3. '-------------
  4. 'Function definition
  5. Private Function GetRealNameFromAd(ByVal UsernameToFind As String) As String
  6.         Using searcher As New DirectorySearcher(New DirectoryEntry())
  7.             searcher.PageSize = 1000
  8.             searcher.SearchScope = SearchScope.Subtree
  9.             searcher.Filter = "(&(samAccountType=805306368)(sAMAccountName=" & UsernameToFind & "))"
  10.             Using Results As SearchResultCollection = searcher.FindAll
  11.                 If Results Is Nothing OrElse Results.Count <> 1 Then
  12.                     Throw New ApplicationException("Invalid number of results returned - either no users were found or more than one user account was found")
  13.                 End If
  14.                 Using UserDE As DirectoryEntry = Results(0).GetDirectoryEntry
  15.                     Return CStr(UserDE.Properties("givenName").Value) & " " & CStr(UserDE.Properties("sn").Value)
  16.                 End Using
  17.             End Using
  18.         End Using
  19. End Function
  20.  
  21. '--------------
  22. 'Example of using it:
  23. Try
  24.      MessageBox.Show("Real name for " & Environment.Username & " is " & GetRealNameFromAd(Environment.Username), "Real Name Found", MessageBoxButtons.OK, MessageBoxIcon.Information)
  25. Catch ex As Exception
  26.      MessageBox.Show("The following error was encountered during the Active Directory search: " & ex.Message, "Error During Search", MessageBoxButtons.OK, MessageBoxIcon.Error)
  27. End Try