joeware - never stop exploring... :)

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

Using AdFind and AdMod for an action you might normally have to script…

by @ 11:29 pm on 4/28/2008. Filed under tech

I received the following email:

If I wanted to copy the IP Phone attribute of each user into Exchange Extension attribute13 for that user, would AdMod work?  and if so, can you point me to and example?

This is actually extremely easy with adfind and admod since I added the -adcsv capability… This is however where you have to use the “special” formatting protocols in AdMod to describe what you want. This is what my friend Laura Hunter (Shutup Laura) calls the perl like syntax for doing things… There is a definite hint of perl with the {{ and }} but it isn’t perl. I just needed something handy to point out things that needed to be replaced.

So anyway, here is initial output of adfind trying to show the values

G:\>adfind -default -f “&(objectcategory=person)(objectclass=user)(ipphone=*)” ipphone extensionattribute13

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

Using server: dc2.joeware.local:389
Directory: Windows Server 2003

dn:CN=testuser,CN=Users,DC=joeware,DC=local
>ipPhone: testipphone
>extensionAttribute13: somevalue

dn:CN=testuser2,CN=Users,DC=joeware,DC=local
>ipPhone: testipphone2

2 Objects returned

 

As you can see, one already has a value in the extensionAttribute13 and one doesn’t.

Then you run the following command (all one line but it may wrap…) (oh and don’t mind the ##BETA## in there, that is my personal version of admod that has bugs in it…

G:\>adfind -default -f “&(objectcategory=person)(objectclass=user)(ipphone=*)” ipphone -adcsv |admod -unsafe extensionattribute13::{{ipphone}}

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

DN Count: 2
Using server: dc2.joeware.local:389
Directory: Windows Server 2003

Modifying specified objects…
   DN: CN=testuser,CN=Users,DC=joeware,DC=local…
   DN: CN=testuser2,CN=Users,DC=joeware,DC=local…

The command completed successfully

 

Now if I rerun the show the info command again…

G:\>adfind -default -f “&(objectcategory=person)(objectclass=user)(ipphone=*)” ipphone extensionattribute13

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

Using server: dc2.joeware.local:389
Directory: Windows Server 2003

dn:CN=testuser,CN=Users,DC=joeware,DC=local
>ipPhone: testipphone
>extensionAttribute13: testipphone

dn:CN=testuser2,CN=Users,DC=joeware,DC=local
>ipPhone: testipphone2
>extensionAttribute13: testipphone2

2 Objects returned

 

Very nice huh? Previously, that would have taken a script. Granted it would be a simple script but how nice is it to not have to write a script for something so silly?

The command uses AdFind to output a CSV file with the DN and iPPhone values and then AdMod scoops that up and writes the value in the iPPhone column for each object into the extensionAttribute13 attribute. Normally with AdMod if you want to set a value you specify

attribute::value

Since we are pulling data from the CSV file to insert, you tell it to grab that field and I have that set up to do that when AdMod encounters {{attribute}} like

attribute::{{attribute from CSV File}}

If you want to populate the same attribute name with that field from the CSV file… for instance you need to set the displayName of an object to the displayName value in the CSV file you can use this shortcut {{.}} to specify the displayName value from the CSV file… like so

attribute::{{.}}

I didn’t like typing displayname::{{displayname}} as much as the next person and figured, there should be a shortcut there…

You can also do manipulates of the data like merging it with other info, slapping two attributes together (say first and last name), bitwise operations, search and replace… See the CSV help in AdMod to see the manipulations possible… Just type

admod /csv?

or look at http://www.joeware.net/freetools/tools/admod/usage.htm

 

    joe

Rating 3.00 out of 5

One Response to “Using AdFind and AdMod for an action you might normally have to script…”

  1. Laura says:

    AHH!!!!! Now I see why you were surprised that I needed a for-do loop for that “match samaccountname to UPN” thing I did for Mr. Hunter.

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