krex
(Fresh Scripter)
2006-09-08 10:38 AM
Add SMTP and set primary

Hi!
All of our users need a new mail address. So i Want to add that new e-mail address. I put a post a part of my script below here.

Now my problem is that if i add tha new address the old address get delete so i save the old one and then try 2 add both and the works .

My Problem is that both E-mail Addresse get primary and i can not delete Primary address in Active Directory

So how do i add the 2 adresse and make Sure that only the new is primary
I dont know if this command will work i cant seem to get working ADS_PROPERTY_UPDATE

Code:


$NewMail = "MyNew"
$OLDMAIL = "MyOld"
$Grp = GetObject ("LDAP://cn=somegroup,OU=Some place,dc=my,dc=domain,dc=com")
For Each $User in $Grp.Member
$Userdata = GetObject ("LDAP://"+$User)

IF $UserData.sAMAccountName = "Aname"
$Array = "SMTP:"+$NewMail+"@@????.??","SMTP:"+$NewMail+"@@???.??"
$UserData.Put ("proxyAddresses", $Array)
$UserData.SetInfo()
Endif
Next



krex
(Fresh Scripter)
2006-09-08 11:25 AM
Re: Add SMTP and set primary

Sorry!
Found the Solution if you write smtp with uppecase it becomes the Primary SMTP
and if you use lowercase if becomes secondary.
So my array will look this if i want my $newmail as primary and the $oldmail as secondary.
Code:

$NewMail = "MyNew"
$OLDMAIL = "MyOld"
$Grp = GetObject ("LDAP://cn=somegroup,OU=Some place,dc=my,dc=domain,dc=com")
For Each $User in $Grp.Member
$Userdata = GetObject ("LDAP://"+$User)

IF $UserData.sAMAccountName = "Aname"
$Array = "SMTP:"+$NewMail+"@@????.??","smtp:"+$oldMail+"@@???.??"
$UserData.Put ("proxyAddresses", $Array)
$UserData.SetInfo()
Endif
Next