Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Query AD for users Email Address

Is there a way to query AD for a single users email address if I know their Logon Name?

I use something like this in a script, but I'd like to know if I can just get the info for a single user:

Set objDomain = GetObject("WinNT://mydomainname.com,domain")
objDomain.Filter = Array("User")
For Each objUser In objDomain
......




0
robrandon
Asked:
robrandon
1 Solution
 
MartoneCommented:
try this

Dim User
Dim UserName
Dim Domain
Domain = "domainname"
UserName = "username"
Set User = GetObject("WinNT://" & Domain & "/" & UserName & ",user")
wscript.echo User.Fullname
0
 
robrandonAuthor Commented:
I changed the User.Fullname to get the email address, but it works.  Thanks!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now