Discussion:
Read Active Directory user attributes
(too old to reply)
Jan Nielsen
2004-05-25 09:37:09 UTC
Permalink
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
BJLMorgan
2004-05-25 22:21:06 UTC
Permalink
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.
Loading...