How can I determine the logged-on user's distinguished name (DN)?

John Savill

October 23, 2005

1 Min Read
ITPro Today logo

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.UserNameWScript.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

About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like