Solved

Query AD for users Email Address

Posted on 2004-10-12
2
175 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now