joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

Replacing a Bunch of Target Addresses

by @ 8:16 pm on 3/27/2008. Filed under tech

I had someone ping me about replacing the target address on a bunch of contacts in a given OU with adfind/admod. This is actually a great use of those utilities and why I added the cool -adcsv functionality in… This used to be something that you had to script, no choice, but not now…

So the task was… Replace the target address on all contacts in a given OU with a new target address that replaced @dom1.com with @dom2.com.

The way the person was trying to do it was with (all one line if it wraps on you)

adfind -b “OU=source users,dc=source,dc=local” -f targetaddress=*@domain.com -dsq | admod -safety 10 targetaddress::”smtp:%’mailNickname’%@domain.local”

Not sure where he got this formatting because admod never used anything like that. At least not to my knowledge and I think if it did, I would have knowledge of it. ;o)

The direct replacement for that command that would work as this person expected it would be

adfind -b “OU=source users,dc=source,dc=local” -f targetaddress=*@domain.com mailnickname -adcsv | admod -safety 10 targetaddress::smtp:{{mailNickname}}@domain.local

Another way to have tackled that should work would have been

adfind -b “OU=source users,dc=source,dc=local” -f targetaddress=*@domain.com targetaddress -adcsv | admod -safety 10 targetaddress::{{targetaddress:r:.com:.local}}

Here is an example of that in action but I will only target a single user since it will show it off just fine…

[Thu 03/27/2008 20:10:52.19]
G:\blogfodder>adfind -e -default -f targetaddress=SMTP:*soewhere.net targetaddress

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: DC1.joeware.local:389
Directory: Windows Server 2003
Base DN: DC=joeware,DC=local

dn:CN=testcontact,OU=test,DC=joeware,DC=local
>targetAddress: SMTP:testuser@soewhere.net

1 Objects returned

[Thu 03/27/2008 20:10:57.49]
G:\blogfodder>adfind -e -default -f targetaddress=SMTP:*soewhere.net targetaddress -adcsv |admod targetaddress::{{targetaddress:r:soe:some}}

AdMod V01.11.00cpp Joe Richards (joe@joeware.net) June 2007

DN Count: 1
Using server: DC1.joeware.local:389
Directory: Windows Server 2003

Modifying specified objects…
DN: CN=testcontact,OU=test,DC=joeware,DC=local…

The command completed successfully

[Thu 03/27/2008 20:11:34.59]
G:\blogfodder>adfind -e -default -f targetaddress=SMTP:*somewhere.net targetaddress

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: DC1.joeware.local:389
Directory: Windows Server 2003
Base DN: DC=joeware,DC=local

dn:CN=testcontact,OU=test,DC=joeware,DC=local
>targetAddress: SMTP:testuser@somewhere.net

1 Objects returned

How do you do that with the built-in tools with Windows? You don’t unless you manually do the mod. Fine for the one off but if you have 50 or 100 or 1000 or 10000 then not so fine.

Oh the astute will realize that that version of AdMod is more recent than what is available on the website… yes true, it is my personal beta version that I haven’t released yet. I will work on it in the next couple months and get it released. I actually introduced a silly bug in that version that I am keeping all to myself. ;o)

    joe

Rating 3.00 out of 5

Comments are closed.

[joeware – never stop exploring… :) is proudly powered by WordPress.]