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-all-the-users-without-a-card.sh
2015-01-23 17:24:36 +01:00

24 lines
623 B
Bash
Executable File

#!/bin/bash
ldapsearch -x -D "cn=admin,o=unwired-portal" -w "programmer" -b "ou=users,o=unwired-portal" -LLL waUid | grep -v 'dn:' | grep -v '^$' | cut -d':' -f2 >/tmp/waUid.txt
while read waUid
do
DN=`ldapsearch -x -D "cn=admin,o=unwired-portal" -w "programmer" -b "ou=cards,o=unwired-portal" -LLL waUsedBy=$waUid | grep 'dn:'`
echo "DN: $DN"
if [ -n "$DN" ]; then
echo "User $waUid exists"
else
echo "User $waUid doesn't exists"
ldapdelete -c -x -D "cn=admin,o=unwired-portal" -w programmer "waUid=$waUid,ou=users,o=unwired-portal"
echo "User $waUid deleted"
fi
unset DN
done < /tmp/waUid.txt