Wednesday, March 3, 2010

How to get opends record count

Following command will give you the exact record count under the given dn: {ou=subscribers,dc=mycompany,dc=com}
Script is using the virtual attribute called {numsubordinates}

sh /space/opends/OpenDS-2.2.0/bin/ldapsearch -h localhost -p 389 -D cn='Directory Manager' -w mycpassword -b "ou=subscribers,dc=mycompany,dc=com" -s base "objectclass=*" numsubordinates| grep "numsubordinates:"| cut -c "18-" > /space/.subscriberCount

Note: Output will be saved under /space/.subscriberCount file.Please customize it for yourself

opends export scheduled to work at midnight

The following crontab entry will get the export of the given branch {ou=subscriptions,dc=mycompany,dc=com} .4444 is the admin port of ldap server.

00 00 * * * sh /space/opends/OpenDS-2.2.0/bin/export-ldif -h localhost -p 4444 -D "cn=Directory Manager" -w mypassword -X --includeBranch "ou=subscriptions,dc=mycompany,dc=com" --backendID userRoot --ldifFile /space/opendsExport.ldif &

Opends replication

[root@dual1 bin]# ./dsreplication enable --host1 192.168.241.179 --port1 4444 --bindDN1 "cn=Directory Manager" --bindPassword1 mypassword --replicationPort1 8989 --host2 192.168.241.195 --port2 4444 --bindDN2 "cn=Directory Manager" --bindPassword2 tneu34 --replicationPort2 8990 --adminUID admin --adminPassword mypassword --baseDN "dc=mycompany,dc=com" -X -n





[root@dual1 bin]# ./dsreplication initialize --baseDN "dc=mycompany,dc=com" --adminUID admin --adminPassword mypassword --hostSource 192.168.241.179 --portSource 4444 --hostDestination 192.168.241.195 --portDestination 4444 -X –n

After executing dsreplication initialize all entries under the given base db {dc=mycompany,dc=com} will be replicated to secondary ldap server.for 1.2G records it takes a few minutes {~3-5 min}

Commands are needed to be executed only primary ldap server.

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

Monday, March 1, 2010

Auto Copy a file to destination host

[root@tas5 astelit]# cat /root/scripts/cleanupcopy.sh
#!/usr/bin/expect -f
# connect via scp
spawn scp /space/cleanupOpendsExport.ldif root@10.1.11.1:/space/
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "myPassword\r"
}
}
interact
[root@tas5 astelit]# ENJOY WITH IT :-)
NOTE: This script is copying the local file {/space/cleanupOpendsExport.ldif} to the destination host with IP {10.1.11.1} without entering password.Destination host username is {root} and its password is {myPassword}, destination folder is /space