Hello
Having a bit of trouble here.
What I want to do is replace the Primary mail address, the objUser.mail, with a second address. Currently I have tried many permutations around the script below. The core of it comes from MS which was to put a secondary, or proxy, address in. This works nicely no complaints. But then I want to take that secondary address and make it a primary whilst relegating the previous address to secondary. (Make sense?).
However, I can successfully get half of it to work but it's not correct. The new primary shows up in the general tab as the mail address and in the GAL but in the E-Mail Addresses tab the old primary is still there as the primary.
As I say I have tried many permutations and get a variety of results but not the one I want.
I have scoured Google and various forums using a different seach keywords but I'm not having a lot of luck.
Please help
' Set up the connections
'-------------------------
----------
----------
----------
---------
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
dim mail, newmail
newmail = ("first.surname.cllr@domai
n.org.uk")
Set objUser = GetObject _
("LDAP://serv/cn=first surname,ou=Test,ou=Service
,dc=domain
,dc=org,dc
=uk")
' Capture the elements
'-------------------------
----------
----------
----------
---------
currmail = objUser.mail
wscript.echo("This is the current mail address " & currmail)
' *** New proxy email address
objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", _
Array("smtp:" & newmail)
wscript.echo("This is the new proxy mail address " & newmail)
objUser.SetInfo
' *** New primary email address
objUser.PutEx ADS_PROPERTY_UPDATE, "mail", _
Array("SMTP:" & newmail)
wscript.echo("This is the new Primary mail address " & newmail)
objUser.SetInfo
' *** New proxy email address
objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", _
Array("smtp:" & currmail)
wscript.echo("This is the new proxy mail address " & currmail)
objUser.SetInfo
' *** Turn off recipient policy updates
objUser.Put "msexchpoliciesexcluded", "{26491CFC-9E50-4857-861B-
0CB8DF22B5
D7}"
objUser.SetInfo
wscript.echo("Complete")
Start Free Trial