Public Function GetUserADFullName() As String
'https://thedbguy.blogspot.com/2020/07/get-users-full-name.html
Dim objADInfo As Object
Dim objADUser As Object
On Error GoTo ErrorHandler
Set objADInfo = CreateObject("ADSystemInfo")
Set objADUser = GetObject("LDAP://" & objADInfo.UserName) 'ERROR HERE
GetUserADFullName = objADUser.FullName
Set objADUser = Nothing
Set objADInfo = Nothing
ErrorHandler:
If Err.Number <> 0 Then
MsgBox "Error " & Err.Number & ": " & Err.Description, vbInformation, "basUtilities - GetUserADFullName"
End If
End Function