#!/bin/bash
_timeout="/usr/bin/timeout 3"
_ldapsearch=/usr/bin/ldapsearch
user=${1%@*}
_dn=${1#*@};
_dbn=$(for i in $(echo $_dn|tr . " ");do t="$t dc=$i";done;echo $t|tr " " ,);
t=$($_timeout $_ldapsearch -D ${1} -w ${2} -b "$_dbn" -h ${_dn} "sAMAccountname=$user"
2>/dev/null|grep "sAMAccountName: $user");
[ "$t" = "sAMAccountName: $user" ]&&echo -e "OK"&&exit 0;
echo -e "ERR";
沒有留言:
張貼留言