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



Benjamin Fischer wrote:

I need to change the default proxyAdress for all AD Users with VBScript.
I've found out that the E-Mail addresses used for exchange is stored in
the
proxyAdress property array including an smtp prefix. The default address
is
distinguished by letter case. The default address includes the prefix in
upper case.
So here are my questions:

1. How do i modify a property inside the array with vbscript. I can modify
propertys which are strings, but i never tied it with those array
propertys.
2. If i set another prefix in upper case will the old default address be
automatically convertet to lower case?

Use the PutEx method of the user object to modify multi-valued attributes,
such as otherTelephone or proxyAddresses. For example, to add another phone
number to otherTelephone:

Const ADS_PROPERTY_APPEND = 3
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=Sales,dc=MyDomain,dc=com")
objUser.PutEx ADS_PROPERTY_APPEND, "otherTelephone", Array("425-555-0116")
objUser.SetInfo

or, to modify (replace) the attribute value:

Const ADS_PROPERTY_UPDATE = 2
objUser.PutEx ADS_PROPERTY_UPDATE, "otherTelephone", Array("425-555-0116",
"425-555-1234")

To read a multi-valued attribute into an array use the GetEx method:

colNumbers = objUser.GetEx("otherTelephone")

If you need to modify an existing entry, you need to read the attribute into
an array, enumerate the array to find the old value, modify it, then update
the attribute with the new array. Perhaps:
============
Option Explicit

Dim strOldAddress, strNewAddress, blnFound, blnSkip
Dim objUser, colAddresses, k

Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
strOldAddress = "FirstLast@xxxxxxxxxxxxx"
strNewAddress = "FirstLast@xxxxxxxxxxxxxx"
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=Sales,dc=MyDomain,dc=com")
colAddresses = objUser.GetEx("proxyAddresses")
blnFound = False
blnSkip = False
For k = 0 To UBound(colAddresses)
If (colAddresses(k) = strNewAddress) Then
blnSkip = True
End If
If (colAddresses(k) = strOldAddress) Then
colAddresses(k) = strNewAddress
blnFound = True
End If
Next
If (blnSkip = False) Then
If (blnFound = True) Then
objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", colAddresses
Else
objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses",
Array(strNewAddress)
End If
objUser.SetInfo
End If
===========
The logic depends on when you want to add the new entry or modify an
existing. You should take into account that the old entry may not be there
and the new one may already be there. Also, note that attributes values are
case aware but not case sensitive.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: passing parameters by reference
    ... Try thinking of it this way: everything in Lisp is passed ... If you passed in an array, any changes you make to array elements ... and see that it does not necessarily modify its argument. ... A macro call looks syntactically ...
    (comp.lang.lisp)
  • Re: writing library functions and pointers?
    ... array is an object. ... of this operation is the contents of the pointer object which is the ... when the function needs to modify the object in the calling ... only the memory that array in the calling function points to. ...
    (comp.lang.c)
  • Re: Any way to take a word as input from stdin ?
    ... know whether it modifies the original array or not. ... It does modify the original array, but ... and it will form the basis of get_words function which will store all ... you intend to modify the pointer (by calloc ...
    (comp.lang.c)
  • Re: SSCANF
    ... This gives undefined behavior. ... You're trying to modify ... in this context will evalutate to pointers to their ... array of three char). ...
    (comp.lang.c)
  • Re: Problem in writing to a property node of a cluster
    ... I took the liberty to modify your VI for an alternative approach. ... You should keep your array of 32 clusters in a shift register and show only a single cluster as a front panel control. ... - Selecting a different transducer from the listbox on the left will load its settings into that control via a local variable. ...
    (comp.lang.labview)