2016-07-01 14:58:06 +02:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# This script will convert UR1 user sesame into UR1 user mail
|
2017-01-17 18:27:37 +01:00
|
|
|
|
# The first argument should be a file with a uid by line !
|
|
|
|
|
# OR a USER sesame (id).
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
|
|
|
|
# Dependancies:
|
|
|
|
|
# ldapsearch (provide by ldap-utils on GNU/Linux)
|
|
|
|
|
|
2017-01-17 18:27:37 +01:00
|
|
|
|
if [ -f "${1}" ]; then
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
2017-01-17 18:27:37 +01:00
|
|
|
|
UID_LIST="${1}"
|
|
|
|
|
MAIL_LIST="${UID_LIST}_mail"
|
|
|
|
|
|
|
|
|
|
printf '%b' "Convert the list of ID in **${UID_LIST}** to mail\n"
|
|
|
|
|
|
|
|
|
|
touch "${MAIL_LIST}"
|
|
|
|
|
|
|
|
|
|
index=0
|
|
|
|
|
while read uid; do
|
|
|
|
|
index=$((index+1))
|
|
|
|
|
mail=$(ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(uid='"${uid}"')' -b "dc=univ-rennes1,dc=fr" -x mail | grep "^mail" | cut -d" " -f2)
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
2017-01-17 18:27:37 +01:00
|
|
|
|
printf '%b' "${mail}\n" >> "${MAIL_LIST}"
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
2017-01-17 18:27:37 +01:00
|
|
|
|
done < "${UID_LIST}"
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
2017-01-17 18:27:37 +01:00
|
|
|
|
printf '%b' "Please see ${MAIL_LIST} file\n"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
USER_ID="${1}"
|
|
|
|
|
|
|
|
|
|
printf '%b' "This sesame correspond to :\n"
|
|
|
|
|
ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(uid='"${USER_ID}"')' -b "dc=univ-rennes1,dc=fr" -x mail | grep "^mail" | cut -d" " -f2
|
|
|
|
|
fi
|
2016-07-01 14:58:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exit 0
|