Hey all, I got what I think should be a relatively simple script.
I feed it a full distinguished name (e.g. 'CN=Some Account,OU=Service Accounts,DC=domain,DC=com) and it reads the proxyAddresses attribute. If I echo what I am looking for (strAddress) inside the If Left... command, it finds the rfax: addresses I want to kill. However, the objUser.PutEX ADS_PROPERTY_DELETE does not actually delete the addresses from the proxyAddresses attribute. If I error check after the SetInfo, there aren't any errors. As you can see, I tried the CLEAR parameter to test it and it works as expected, removes all values for the proxyAddresses attribute. What's wrong with DELETE that it won't actually delete anything? I am running this under a Domain Admin account so its not permissions.
Code:
Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_DELETE = 4
strDN = InputBox("Enter the distinguishedName:","Clean up rfax: addresses")
Set objUser = GetObject("LDAP://" & strDN)
For Each strAddress In objUser.proxyAddresses
If Left(strAddress,5) = "rfax:" Then
objUser.PutEX ADS_PROPERTY_DELETE, "proxyAddresses", Array(strAddress)
'objUser.PutEX ADS_PROPERTY_CLEAR, "proxyaddresses", 0
End If
Next
objUser.SetInfo
Wscript.echo "Done!"
I feed it a full distinguished name (e.g. 'CN=Some Account,OU=Service Accounts,DC=domain,DC=com) and it reads the proxyAddresses attribute. If I echo what I am looking for (strAddress) inside the If Left... command, it finds the rfax: addresses I want to kill. However, the objUser.PutEX ADS_PROPERTY_DELETE does not actually delete the addresses from the proxyAddresses attribute. If I error check after the SetInfo, there aren't any errors. As you can see, I tried the CLEAR parameter to test it and it works as expected, removes all values for the proxyAddresses attribute. What's wrong with DELETE that it won't actually delete anything? I am running this under a Domain Admin account so its not permissions.