I have this posted on another Forum:
LINK
I already have code to get the Username and Computer name of the person using my Access Database. However I need to match the AD credentials to our ADP data. Using names is not a good solution due to name changes, name preferences etc... so I asked our IT group to use the EmployeeID field to be populated with the ADP Primary Key value... This way I don't need much extra code to "HOPEFULLY" guess the right person matches.
Any help would be greatly appreciated. Below is the code I use to get the UserName:
Function UserName()
Dim objSysInfo As Object
Dim objcurrentuser As Object
Set objSysInfo = CreateObject("ADSystemInfo")
Set objcurrentuser = GetObject("LDAP://" & objSysInfo.UserName)
Debug.Print objcurrentuser.givenName
Debug.Print objcurrentuser.LastName
End Function