Solved

Query AD for users Email Address

Posted on 2004-10-12
2
177 Views
Last Modified: 2010-05-02
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
Comment
Question by:robrandon
2 Comments
 
LVL 2

Accepted Solution

by:
Martone earned 125 total points
ID: 12290751
try this

Dim User
Dim UserName
Dim Domain
Domain = "domainname"
UserName = "username"
Set User = GetObject("WinNT://" & Domain & "/" & UserName & ",user")
wscript.echo User.Fullname
0
 
LVL 16

Author Comment

by:robrandon
ID: 12290865
I changed the User.Fullname to get the email address, but it works.  Thanks!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question