How to fetch data from AD in a VBA script (Office 2003, Windows 2003 environment)

H

Harald

Hi



I want to develop a Word template (Office 2003, Windows 2003 environment)
that should retrieve data from Active Directory. Based on logon name, I want
to get Users full name, Users mail address, Phone number etc which are
stored in AD.



Question: How can these values be retrieved from AD using a VBA script? If
you have an example or link I am very thankful.



Thanks in advance

Harald
 
C

Cindy M.

Hi Harald,
I want to develop a Word template (Office 2003, Windows 2003 environment)
that should retrieve data from Active Directory. Based on logon name, I want
to get Users full name, Users mail address, Phone number etc which are
stored in AD.

Question: How can these values be retrieved from AD using a VBA script? If
you have an example or link I am very thankful.
You have to set a reference to the ActiveDirectory service (Tools/References in
the VBA Editor). Then you have access to the AD object model. I've never used
this, myself, and don't have it on my system so I can't give you any details.
But after you set the reference to the Active DS Type library, declare an
object variable as type ADSystemInfo and off you go. Intellisense should give
you a list, and the Object Browser can help as well. Example
Dim sys as ADSystemInfo

Set sys = New ADSystemInfo
Set user = GetObject("LDAP://" & sys.UserName)


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top