Adding attributes to an ldap entry
De Wikillano
I needed to add some values to a diferent entries on a ldap server,
first I needed to add this attributes to the objectclass the entries where from, once it was done I made a script to add the values to the entries automatically. these are the steps a followed. (this only works if the values are the same for all the entries)
first, extract de entries, in this cases users:
ldapsearch -h 172.24.57.20 -p 369 -s one -b "cn=it,cn=usuarios,o=com" "(&(objectclass=COM_Usuario))" > temp.txt
I extracted just the dn: of the entries and dumped them to the depurado.txt file:
grep "^cn=[a-z,A-Z,1234567890]*,cn=it,cn=usuarios,o=com" < temp.txt > depurado.txt
execute de script, here is the content, the script will create a file with a ldif extructure to do the modifications to the ldap server.
#!/bin/bash echo "" > final.ldif for i in `cat depurado.txt` do echo "dn: $i" >> final.ldif echo changetype:modify >> final.ldif echo add:department >> final.ldif echo department: it >> final.ldif echo " " >> final.ldif done
do the changes with ldaomodify:
ldapmodify -h 172.24.x.x -D "cn=root" -w password -p 369 -r -f final.ldif
checking:
ldapsearch -h 172.24.x.x -p 8182 -s sub -b "cn=it,cn=usuarios,o=com" "(cn=usertolookfor)"
Interesting links:
http://download.oracle.com/docs/cd/B10501_01/network.920/a96579/comtools.htm#632173