A. The simplest way to determine the logged-on user's DN is to query the ADSystemInfo object, as the following sample code and output shows:
Set objSysInfo = CreateObject("ADSystemInfo") strUser = objSysInfo.UserName WScript.Echo strUser
This code outputs the user's DN. Now that you know the DN, you can fetch the actual object for the user to get additional information (e.g., the email address) as the following example shows:
Set objUser = GetObject("LDAP://" & strUser)
WScript.Echo objUser.mail
0 comments
Hide comments