Crysalix/actions/add_user_to_group·sh
TheHackdes ea960e5320 feat(main.sh): add functionality to add users to a group
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.
2026-05-04 20:41:53 +02:00

34 lines
969 B
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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