2015-10-19 16:05:37 +02:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# This script will convert UR1 user mail into UR1 user sesame
|
2017-02-15 14:37:46 +01:00
|
|
|
|
# The first argument must be :
|
|
|
|
|
# a file with a mail by line !
|
|
|
|
|
# a mail address
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2016-04-07 16:49:38 +02:00
|
|
|
|
# Dependancies:
|
|
|
|
|
# ldapsearch (provide by ldap-utils on GNU/Linux)
|
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
# Test if the first arg is a existing file
|
|
|
|
|
if [ -f "${1}" ]; then
|
|
|
|
|
MAIL_LIST="${1}"
|
|
|
|
|
UID_LIST="${MAIL_LIST}_uid"
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
touch "${UID_LIST}"
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
index=0
|
|
|
|
|
while read -r 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)
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
#printf '%b' "${index}: ${mail} -> ${uid}\n"
|
|
|
|
|
printf '%b' "${uid}\n" >> "${UID_LIST}"
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
done < "${MAIL_LIST}"
|
|
|
|
|
|
|
|
|
|
printf '%b' "Please see ${UID_LIST} file\n"
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
MAIL="${1}"
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
2017-02-15 14:37:46 +01:00
|
|
|
|
printf '%b' "This email address correspond to :\n"
|
|
|
|
|
|
|
|
|
|
ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(mail='"${MAIL}"')' -b "dc=univ-rennes1,dc=fr" -x uid | grep "^uid" | cut -d" " -f2
|
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2015-10-19 16:05:37 +02:00
|
|
|
|
|
|
|
|
|
exit 0
|