mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-22 10:01:45 +00:00
Add new LDAP users to admin group.
This commit is contained in:
parent
82cf4df0bc
commit
f4835b4515
@ -34,3 +34,24 @@ if [ $? -ne 0 ]; then
|
||||
echo "Failed to create user"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if admin group exists
|
||||
results=$(ldapsearch -Y EXTERNAL -H ldapi:/// -b 'ou=groups,dc=thisbox' -LLL "(cn=admin)" cn)
|
||||
|
||||
if [ -z "$results" ]; then
|
||||
# create admin group, with new user as a member
|
||||
cat <<EOF |ldapadd -Y EXTERNAL -H ldapi:///
|
||||
dn: cn=admin,ou=groups,dc=thisbox
|
||||
objectClass: groupOfUniqueNames
|
||||
cn: admin
|
||||
uniqueMember: uid=$username,ou=users,dc=thisbox
|
||||
EOF
|
||||
else
|
||||
# add new user to existing admin group
|
||||
cat <<EOF |ldapmodify -Y EXTERNAL -H ldapi:///
|
||||
dn: cn=admin,ou=groups,dc=thisbox
|
||||
changetype: modify
|
||||
add: uniqueMember
|
||||
uniqueMember: uid=$username,ou=users,dc=thisbox
|
||||
EOF
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user