Re: How to modify the proxyAdress property in AD with VBScript

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
--


.



Relevant Pages

  • Re: Table open times and rowsize discontinuity
    ... some manner related to ADO or the tool you are using. ... University of Washington ... Puget Sound Oracle Users Groupwww.psoug.org- Hide quoted text - ... For the array fetching, the only parameter I can find in the ADO ...
    (comp.databases.oracle.misc)
  • Re: Table open times and rowsize discontinuity
    ... some manner related to ADO or the tool you are using. ... Puget Sound Oracle Users Groupwww.psoug.org- Hide quoted text - ... For the array fetching, the only parameter I can find in the ADO ... exceeding the SDU and the MTU. ...
    (comp.databases.oracle.misc)
  • RE: Transaction problem between DAO and ADO
    ... do while whatever 'start your loop ... objects opened in ADO. ... Logically I need a new pkID ... dim NewID as long,objMyTable as object ...
    (microsoft.public.access.formscoding)
  • Re: ADO Command object in a Loop
    ... By default A2K references ADO version 2.1, ... downloaded MDAC 2.8 (which contains the ADO libraries), ... >I have a problem with a stored procedure call that occurs in a loop. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Performance problem
    ... I would suggest that you use dao (or ado) in this case. ... My guess is that the above loop to insert data will run about 100, ... Note that "jet" ships with windows xp, and vista, so you don't actualy have ... to install access to read/write mdb files on a windows box. ...
    (microsoft.public.access.gettingstarted)