Jun/06
14
Visual Basic: Convert a Windows AD account name to a 'real' name.
No comments · Posted by Craig Buchanan in Programming, Visual Basic
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
