Tuesday, January 25, 2011

Scripts for deleting sso profiles and verfiy the records in the LDAP

Delete the uids

echo `date` >> /tmp/log/deleted.log
echo `date` >> /tmp/log/notdeleted.log
echo `date` >> /tmp/log/idnotexit.txt
for i in `cat /tmp/$1`
do
rv=`ldapsearch -h <Hostname> -p 41389 -D "cn=Directory Manager" -w xxxx -b o
u=geworker,o=ge.com  uid=$i | grep gessostatus | cut -f2 -d"="`
if [  -n "$rv" ]
then
   gessouid=`ldapsearch -h <Host Name> -p 41389 -D "cn=Directory Manager" -w xxxx -b ou=geworker,o=ge.com  uid=$i |grep -v  'manager'|grep ou=geworker,o=ge.com`
 ldapdelete -h <Host Name> -p 41389 -D "cn=Directory Manager" -w xxxx $gessou
id
 if [ $? -eq  0 ]
   then
      echo $i "has been deleted">>/tmp/log/deleted.log
   else
      echo $i "has not been deleted" >>/tmp/log/notdeleted.log
  fi
else
echo $i" does not exits in LDAP">>/tmp/log/idnotexit.txt
fi
done


Scripts to search the records through uids

echo `date` >> /tmp/log/NBCU400added.txt
echo `date` >> /tmp/log/NBCU400notadded.txt
echo `date` >> /tmp/log/idnotexit.txt
for i in `cat /tmp/$1`
do
rv=`ldapsearch -h <Host Name> -p 41389 -D "cn=Directory Manager" -w xxxxx -b o
u=geworker,o=ge.com  uid=$i | grep gessostatus | cut -f2 -d"="`
if  [ ! -z "$rv"  ]
then
out=`ldapsearch -h <Host Name> -p 41389 -D "cn=Directory Manager" -w xxxxxx -b
ou=geworker,o=ge.com  uid=$i gessolinkedbu | grep -c NBCUS400`
     if [ $out -ge 1 ]
      then
        echo $i" has added NBCUS400">>/tmp/log/NBCU400added.txt
      else
       echo $i" has not added NBCUS400">>/tmp/log/NBCU400notadded.txt
     fi
else
  echo $i" does not exits in NBCU LDAP">>/tmp/log/idnotexit.txt
fi
done
~

No comments:

Post a Comment