Visual Basic: Convert a Windows AD account name to a 'real' name.

Convert a Windows AD account name to the individual’s actual name, using ADSI.

Step 1: Add Reference

Add a reference to ‘Active DS Type Library’ to the project.

Step 2: Add Function

Add the following text to module:

Public Function GetFullName(DomainName As String, UserName As String) As String
Dim User As IADsUser
Set User = GetObject("WinNT://" & DomainName & "/" & UserName & ",user")
GetFullName = User.FullName
Set User = Nothing
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *