on error resume next
Set objUser = GetObject("LDAP://CN=" & sAMAccountName & _
"ou=usuarios,dc=quahog,dc=edu,dc=br")
do while objUser = true
objUser.Put "objUser.otherMailbox", "objUser.mail"
objUser.Put "objUser.mail", "objUser.userPrincipalName"
loop
wscript.echo "Done"
I am trying to swap some attributes in my Active Directory: I want my actual e-mail attribute, which happens to be mail, to be my otherMailbox. Then, I want my actual logon user name, which I believe to be objUser.userPrincipalName, to be also my new e-mail.
VBScript debugging step 1: remove
On Error Resume Nextand see what breaks.AFAICS your code has 3 issues (aside from the
OERN):objUseris an object, not a boolean, soobjUser = Truewill fail.Putmethod expects the attribute name as the first parameter and the new value for the attribute as the second.Change your code to this:
Check out the ActiveXperts script repository for more examples.