mailtosesame: Tiny script to convert UR1 user mail to it's sesame.

This commit is contained in:
Jeremy Gardais 2015-10-19 16:05:37 +02:00 committed by Gardais Jérémy
parent 00e9c3e781
commit 420755f00b
1 changed files with 29 additions and 0 deletions

29
mailtosesame Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# This script will convert UR1 user mail into UR1 user sesame
# The first argument should be a file with a mail by line!
MAIL_LIST="${1}"
UID_LIST="${MAIL_LIST}_uid"
# Test if the given file exists
if [ -f "${MAIL_LIST}" ]; then
touch "${UID_LIST}"
else
printf '%b' "The fist argument should be a file with one mail/line\n"
exit 1
fi
index=0
while read mail; do
index=$((index+1))
uid=$(ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(mail='"${mail}"')' -b "dc=univ-rennes1,dc=fr" -x uid | grep "^uid" | cut -d" " -f2)
#printf '%b' "${index}: ${mail} -> ${uid}\n"
printf '%b' "${uid}\n" >> "${UID_LIST}"
done < "${MAIL_LIST}"
printf '%b' "Please see ${UID_LIST} file\n"
exit 0