Access function to return username, not username
1 answer
Assuming you have Active Directory installed, you can use the following code taken from Andrey Artemiev's answer here :
Public Function ADtest() As String
Dim ADSI As Object, UN As Object
Set ADSI = CreateObject("ADSystemInfo")
Set UN = GetObject("LDAP://" & ADSI.UserName)
ADtest = UN.FirstName
ADtest = ADtest & " " & UN.LastName
Set UN = Nothing
Set ADSI = Nothing
End Function
(adding an answer here for better visibility, made by the Community Wiki as this is not my answer and I don't want to receive credit)
+4
source to share