Showing posts with label ldap null attribute search. Show all posts
Showing posts with label ldap null attribute search. Show all posts

Tuesday, March 2, 2010

Find null attribute and modify on Ldap Server


Language null search


ldapsearch -x -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret -b ou=subscribers,dc=mycompany,dc=com "(!(tnaLanguage=*))" dn | grep dn:

This script gives us the subscribers without having tnaLanguage attribute.
Modify entries having null language

dn: tnaId=2108840497330132510,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=2806900514076119703,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=3602194238187496434,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=2806900514076119725,ou=subscribers,dc=mycompany,dc=com

Compose modifyLanguage.ldif like below

dn: tnaId=807889406294118443,ou=subscribers,dc=mycompany,dc=com

changetype:modify

add: tnaLanguage

tnaLanguage: english


Execute ldif file like below
ldapmodify -x -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret -f modifyLanguage.ldif

Note: You need use cshell for the use of " ! " sign before search operation