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

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

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish