This commit introduces the ability to add one or more users to a group using the main script. The user is prompted to select this option from the menu, and if chosen, the action/add\_user\_to\_group.sh script is sourced to perform the operation. If an unrecognized choice is made, an error message is displayed and the script exits with a status of 1.
34 lines
969 B
Bash
Executable file
34 lines
969 B
Bash
Executable file
#!/bin/bash
|
||
|
||
source ./sources/functions.sh
|
||
|
||
banner "Adding user in group"
|
||
sleep 1
|
||
|
||
log info "Search all users..."
|
||
sleep 1
|
||
|
||
SELECTED_USER=$(ldapsearch -x -LLL -H ldap://${LDAP_SERVER} -b "${LDAP_BASE_DN}" "(objectClass=inetOrgPerson)" dn | grep '^dn' | sed 's/dn: //g' | fzf --height=10 --reverse --cycle --prompt="❯ Choix : " -m)
|
||
|
||
if [ -z "$SELECTED_USER" ]; then
|
||
log error "No user selected"
|
||
else
|
||
log success "List of selected users :"
|
||
for i in $SELECTED_USER; do
|
||
log info "User : ${i}"
|
||
done
|
||
fi
|
||
|
||
SELECTED_GROUP=$(ldapsearch -x -LLL -H ldap://${LDAP_SERVER} -b "${LDAP_BASE_DN}" "(|(objectClass=groupOfNames)(objectClass=groupOfUniqueNames)(objectClass=posixGroup))" dn |
|
||
grep '^dn' |
|
||
sed 's/dn: //g' |
|
||
fzf --height=10 --reverse --cycle --prompt="❯ Groupe : " -m)
|
||
|
||
if [ -z "$SELECTED_GROUP" ]; then
|
||
log error "No group selected"
|
||
else
|
||
log success "List of selected groups :"
|
||
for i in $SELECTED_GROUP; do
|
||
log info "Group : ${i}"
|
||
done
|
||
fi
|