1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
ULib/tests/examples/wi-auth/bin/delete-cards-without-usedby.sh
2015-01-23 17:24:36 +01:00

16 lines
413 B
Bash
Executable File

#/bin/bash
if [ -f /tmp/dn-list.txt ]; then
rm -f /tmp/dn-list.txt
fi
ldapsearch -x -D "cn=admin,o=unwired-portal" -w "programmer" -b "ou=cards,o=unwired-portal" '(&(objectClass=waCard)(!(waUsedBy='*')))' | grep 'dn:' >/tmp/dn-list.txt
IFS='$'
while read dn
do
dn=`echo -n "$dn" | cut -d':' -f2`
echo $dn deleted
ldapdelete -c -x -D "cn=admin,o=unwired-portal" -w programmer "$dn"
done < /tmp/dn-list.txt