Re: How to modify the proxyAdress property in AD with VBScript
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Jul 2007 13:17:03 -0500
In the code I posted earlier, if the user has no value assigned to the
multi-value attribute, the GetEx method will raise an error. This error can
be trapped. Perhaps:
===========
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=Sales,dc=MyDomain,dc=com")
On Error Resume Next
colAddresses = objUser.GetEx("proxyAddresses")
If (Err.Number <> 0) Then
On Error GoTo 0
objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses",
Array(strNewAddress)
Wscript.Quit
End If
On error GoTo 0
==========
To do this for all users in an OU, bind to the OU, filter on objects of
class "user", and enumerate the users in a loop. Code similar to what I
posted would be in the loop.
Or, you can use ADO to retrieve distinguishedName and proxyAddresses for all
users. See this link for details on using ADO to rerieve attribute values
from AD:
http://www.rlmueller.net/ADOSearchTips.htm
ADO cannot be used to modify values, so you will need to bind to the user
objects (with distinguishedName). Also, ADO retrieves multi-valued attribute
values as arrays, but returns Null if there is no value assigned. You can
check with the IsNull function. If IsNull, use ADS_PROPERTY_APPEND to assign
the new value as a array. Otherwise loop through the array to check for the
old and new values. Again, the exact logic depends on what you want to
accomplish.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
.
- References:
- Re: How to modify the proxyAdress property in AD with VBScript
- From: Richard Mueller [MVP]
- Re: How to modify the proxyAdress property in AD with VBScript
- Prev by Date: Re: How to modify the proxyAdress property in AD with VBScript
- Next by Date: Re: setprinter command
- Previous by thread: Re: How to modify the proxyAdress property in AD with VBScript
- Index(es):
Relevant Pages
|