Update script to use nslcd conf instead of sssd

This commit is contained in:
Jeremy Gardais 2020-08-14 08:09:43 +02:00
parent 04a72b1f0d
commit f9d3301da7
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 3 additions and 3 deletions

View File

@ -12,8 +12,8 @@ group_cn="ur1:div:lab:r423:ipr:app:calcul:util_calcul"
group_base="ou=grouper,dc=univ-rennes1,dc=fr"
ldap_url="ldap://ldap.univ-rennes1.fr"
ldap_user=$(sed -n 's/\(^ldap_default_bind_dn = \)\(.*\)/\2/p' /etc/sssd/sssd.conf)
ldap_tok=$(find /etc/sssd/conf.d -type f -exec sed -n 's/\(^ldap_default_authtok = \)\(.*\)/\2/p' {} \; -quit)
ldap_user=$(sed -n 's/\(^binddn \)\(.*\)/\2/p' /etc/nslcd.conf)
ldap_passwd=$(sed -n 's/\(^bindpw \)\(.*\)/\2/p' /etc/nslcd.conf)
new_user_list_path="/tmp/cluster.user.list"
old_user_list_path="/tmp/cluster.user.list.old"
@ -43,7 +43,7 @@ if [ -s "${new_user_list_path}" ]; then
exit 1
else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: New User list — Get the user list."
if command ldapsearch -ZZ -D "${ldap_user}" -w "${ldap_tok}" -H "${ldap_url}" -s one -b "${group_base}" "(cn=${group_cn})" member | sed -n 's/\(^member: uid=\)\(.*\)\(,ou=.*\)/\2/p' > "${new_user_list_path}"; then
if command ldapsearch -ZZ -D "${ldap_user}" -w "${ldap_passwd}" -H "${ldap_url}" -s one -b "${group_base}" "(cn=${group_cn})" member | sed -n 's/\(^member: uid=\)\(.*\)\(,ou=.*\)/\2/p' > "${new_user_list_path}"; then
if [ -s "${new_user_list_path}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: New User list — ${new_user_list_path} successfully created."
command chmod 0400 -- "${new_user_list_path}"