Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript and ADUC

Reply
 
Old 10-29-2008   #1 (permalink)
SP_1


 
 

VBScript and ADUC

Hi

In Exchange ADUC, when I go into the Properties of a user, the General tab
has a Description field and a Telephone field (among other fields).

How can I write a VBScript code to obtain the data in these 2 fields ? I'd
like to use this code in a published form in Outlook.

Thank you
Steve



My System SpecsSystem Spec
Old 10-29-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: VBScript and ADUC

Steve wrote:
Quote:

>
> In Exchange ADUC, when I go into the Properties of a user, the General tab
> has a Description field and a Telephone field (among other fields).
>
> How can I write a VBScript code to obtain the data in these 2 fields ?
> I'd like to use this code in a published form in Outlook.
>
I don't know about published forms in Outlook, but VBScript can retrieve the
values of any user attributes. The names of the attributes you refer to are
"description" and "telephoneNumber". The later is a single valued string,
but description is technically multi-valued (although there is never more
than one value in the collection). This only matters if you use ADO to
retrieve the values (ADO will return description as an array). For one user
the code could be similar to:
=========
' Bind to user object (using Distinguished Name).
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=West,dc=MyDomain,dc=com")
' Retrieve and display values.
Wscript.Echo objUser.Name & "," & objUser.description & "," &
objUser.telephoneNumber
======
My example echos to the screen. I don't how you would use the values in a
form. To do the same for all users in an OU the code could be similar to
(watch line wrapping):
======
' Bind to OU object.
Set objOU = GetObject("LDAP://ou=West,dc=MyDomain,dc=com")

' Filter on user objects.
objOU.Filter = Array("user")

' Enumerate all users in OU.
For Each objUser In objOU
' Retrieve and display values.
Wscript.Echo objUser.Name & "," & objUser.description & "," &
objUser.telephoneNumber
Next
=====
To retrieve the values for all users in the domain (or all users meeting
some criteria) you can use ADO. Complete details are in this link:

http://www.rlmueller.net/ADOSearchTips.htm

A paragraph on the page shows how to handle the "description" attribute. For
documentation on the attribute names corresponding to the fields on most of
the tabs in ADUC see the first spreadsheet on this link:

http://www.rlmueller.net/UserAttributes.htm

If you are doing this for a specific user, I don't know how you identify the
user. The Distinguished Name of the current user can be retrieved from the
ADSystemInfo object. For example:
=========
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
===
Otherwise, if you only have the "pre-Windows 2000 logon name", you can use
the NameTranslate object to convert to the Distinguished Name. See this link
for details:

http://www.rlmueller.net/NameTranslateFAQ.htm

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
New to VBscript, Help please! VB Script
CSS and VBscript VB Script
How to do No hang up VBScript (nohup for VBScript) VB Script
vbscript and HTA help VB Script
ADUC Tabs Missing Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46