Thursday, January 14, 2010

Ldap Operations

LDAP ADD
ldapadd -D "cn=root,dc=mycompany,dc=com" -w secret1 -f allLdif.ldif

LDAP SEARCH
ldapsearch -h localhost -p 389 -D cn='Directory Manager' -w tneu34 -b dc=mycompany,dc=com 'tnaPhoneNumber=380332340400'

INDEX USAGE TEST
ldapsearch -h localhost -p 389 -D cn='Directory Manager' -w tneu34 -b dc=mycompany,dc=com 'tnaPhoneNumber=380933998099' debugsearchindex

LDAP MODIFY
ldapmodify -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret1 -f okanGrep.ldif

LDAP EXPORT
Openldap:ldapsearch -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret1 -b dc=mycompany,dc=com objectClass=* > /tmp/all.ldif
Opends:/export-ldif -h localhost -p 4444 -D "cn=Directory Manager" -w secret1 -X --includeBranch "dc=mycompany,dc=com" --backendID userRoot --ldifFile /space/primaryOpendsExport.ldif

LDAP EXPORT OF SPECIFIC ATTRIBUTE
Openldap exm-1:ldapsearch -x -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret1 -b ou=subscriptions,dc=mycompany,dc=com tnaTotalMessageCountQuota=* dn tnaSubscriptionStatus tnaTotalMessageCountQuota > quotaExport.ldif

Openldap exm-2:ldapsearch -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret1 -b ou=subscriptions,dc=mycompany,dc=com objectClass=* > /tmp/allSubscriptions.ldif

FOUND SUBCOUNT COUNT UNDER A NODE
Opends:ldapsearch -h localhost -p 1389 -D cn='Directory Manager' -w secret1 -b "ou=subscribers,dc=mycompany,dc=com" -s base "objectclass=*" numsubordinates

Getting exact count with scripting

ldapsearch -h localhost -p 1389 -D cn='Directory Manager' -w secret1 -b "ou=subscribers,dc=mycompany,dc=com" -s base "objectclass=*" numsubordinates| grep "numsubordinates:"| cut -c "18-"

FOUNDING OPEN CONNECTIONS
Opends:ldapsearch -h tas5 -p 4444 -D "cn=directory manager" -w secret1 --useSSL --trustAll -s base -b "cn=Client Connections,cn=LDAP Connection Handler 0.0.0.0 port 1389,cn=monitor" "(objectclass=*)"| wc -l
160

EXAMPLE OF BATCH SEARCH ON OPENDS UNDER LINUX
[ennio@serkanslnx ~]# while read line ; do ldapsearch -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret1 -b dc=mycompany,dc=com tnaPhoneNumber=$line; done < unique_in_ldap.txt | grep "dn" >dns.txt

LDAP IMPORT
Opends:import-ldif -n userRoot --skipSchemaValidation -l /space/migration/huge.ldif >import.log &

No comments:

Post a Comment