2015-10-19 16:05:37 +02:00
|
|
|
#!/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!
|
|
|
|
|
2016-04-07 16:49:38 +02:00
|
|
|
# Dependancies:
|
|
|
|
# ldapsearch (provide by ldap-utils on GNU/Linux)
|
|
|
|
|
2015-10-19 16:05:37 +02:00
|
|
|
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
|