Read Active Directory user attributes

J

Jan Nielsen

In a Word template, I'm trying to read some attributes in AD about the
current user.
Some of these attributes should then be inserted in a letter.

So far I have the following code, which works ok.

Dim objAdSys, objUser
Set objAdSys = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objAdSys.UserName)

MsgBox (objUser.Get("cn"))
MsgBox (objUser.Get("distinguishedName"))
MsgBox (objUser.Get("displayName"))
MsgBox (objUser.Get("initials"))
MsgBox (objUser.Get("mail"))
MsgBox (objUser.Get("department"))
MsgBox (objUser.Get("company"))
MsgBox (objUser.Get("title"))

However, as this piece of code connects to the AD it only works when the
user is online.
Does Word have some means of extracting these attributes from the user
profile (which is cached on the local computer) ???


Thanks in advance,
Jan Nielsen
 
B

BJLMorgan

Officially certified Microsoft networking geek here (i.e., MCSE). Network User profiles are stored on the domain controller -- the server which allows users to log into a network. They are not local. Only local user profiles are stored locally. If you are wanting to get information about their LAN user account, they're going to have to be logged in.
 

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