![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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. > 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 Specs![]() |
![]() |
| 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 | |||