Hi there everyone. I'm trying to make a bash script that accepts some arguments ans give's back some info about LDAP users and servers.
I have this function :
has_group_access(){
result=$(ldapsearch -LLL "cn=${GROUP_NAME}" cn member | cut -d"," -f1 | cut -d":" -f2 | cut -d"=" -f2 | grep -v ${GROUP_NAME} | grep -v ${dummy})
for item in $result
do
if [ "$item" == $(hostname) ];then
echo "Le groupe:[ ${GROUP_NAME} ] a l'acces sur la machine:[ $(hostname) ]"
echo "\n"
else
echo "Le group : [ ${GROUP_NAME} ] n'as pas acces sur cette machine"
fi
done
#echo ${result}
exit 0
}
What I want is to search in the return value if the hostname (the actual server that executes the script) is in the list.
And if it is it means that the group can access this machine.
How can I do that ?
Thank you for your help.
This is rely important for my job.
---------- Post updated 10-19-10 at 08:09 AM ---------- Previous update was 10-18-10 at 04:06 PM ----------
And how can I query the LDAP server for all the users to see the hosts that they have access to, and after parse this info to show all the users that have access to the running system that will execute the script ?
Thank you for your help