#!/bin/sh # This script will convert UR1 user mail into UR1 user sesame # The first argument must be : # a file with a mail by line ! # a mail address # Dependancies: # ldapsearch (provide by ldap-utils on GNU/Linux) # Test if the first arg is a existing file if [ -f "${1}" ]; then MAIL_LIST="${1}" UID_LIST="${MAIL_LIST}_uid" touch "${UID_LIST}" 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) #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 else MAIL="${1}" 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 exit 0