Skip to content
Snippets Groups Projects
Commit 3a26c722 authored by Daniel's avatar Daniel
Browse files

ENH: LDAP authentication tries second time, if first time times out.

parent 430862b9
No related branches found
No related tags found
No related merge requests found
...@@ -23,20 +23,39 @@ ...@@ -23,20 +23,39 @@
# Try to authenticate a user ($1) with a password ($2) via LDAP # Try to authenticate a user ($1) with a password ($2) via LDAP
[[ "$#" == "2" ]] || {
echo "call this script with two arguments: user and password"
exit 1
}
# set LDAP_SERVER here # set LDAP_SERVER here
# e.g. `LDAP_SERVER=example.com` # e.g. `LDAP_SERVER=example.com`
. ldap.conf exe_dir=$(dirname $0)
. "$exe_dir/"ldap.conf
testpw() {
username="${1}@${LDAP_SERVER}"
pw="$2"
if timeout 5s ldapwhoami -x -H "ldap://$LDAP_SERVER" -D "$username" -w "$pw"; then
return 0
else
ret_code="$?"
fi
# Possibly try a second time
if [[ "$ret_code" != "124" ]] ; then
return "$ret_code"
fi
username="${1}@${LDAP_SERVER}" ldapwhoami -x -H "ldap://$LDAP_SERVER" -D "$username" -w "$pw"
pw="$2"
if ldapwhoami -x -H "ldap://$LDAP_SERVER" -D "$username" -w "$pw" ; then }
if testpw "$1" "$2" ; then
echo "[OK]" echo "[OK]"
exit 0 exit 0
else else
echo "[FAILED]" echo "[FAILED]"
exit 1 exit 1
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment