Update AD.sh
This commit is contained in:
parent
5ff98f0a9d
commit
1c3d4c720b
35
AD.sh
35
AD.sh
|
|
@ -167,29 +167,40 @@ while true; do
|
||||||
pause
|
pause
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
read -p "Nom d'utilisateur v rifier: " username
|
read -p "Nom d'utilisateur à vérifier: " username
|
||||||
|
|
||||||
samba-tool user show "$username" > /dev/null 2>&1
|
# Vérifier si l'utilisateur existe
|
||||||
if [ $? -ne 0 ]; then
|
if ! samba-tool user show "$username" > /dev/null 2>&1; then
|
||||||
echo -e "${RED}Erreur : L'utilisateur $username n'existe pas.${NC}"
|
echo -e "${RED}Erreur : L'utilisateur $username n'existe pas.${NC}"
|
||||||
pause
|
pause
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
user_info=$(samba-tool user show "$username")
|
# Récupérer les informations détaillées
|
||||||
|
user_info=$(samba-tool user show "$username" --attributes=all)
|
||||||
|
|
||||||
echo "$user_info"
|
# Afficher les informations principales de manière formatée
|
||||||
|
echo -e "${BLUE}Informations du compte utilisateur:${NC}"
|
||||||
|
echo "$user_info" | grep -E "displayName|userPrincipalName|mail|telephoneNumber|whenCreated|lastLogon"
|
||||||
|
|
||||||
if echo "$user_info" | grep -q "account_locked: true"; then
|
# Vérifier le statut du compte de manière plus précise
|
||||||
echo -e "${RED}Le compte est verrouill .${NC}"
|
account_status=$(samba-tool user show "$username" | grep -oP 'userAccountControl:\K\w+')
|
||||||
elif echo "$user_info" | grep -q "password_expired: true"; then
|
|
||||||
echo -e "${YELLOW}Le mot de passe est expir .${NC}"
|
# Vérification détaillée du statut
|
||||||
elif echo "$user_info" | grep -q "userAccountControl:.*ACCOUNTDISABLE"; then
|
if [[ "$account_status" =~ "ACCOUNTDISABLE" ]]; then
|
||||||
echo -e "${YELLOW}Le compte est d sactiv .${NC}"
|
echo -e "${RED}Statut : Compte DÉSACTIVÉ${NC}"
|
||||||
|
elif samba-tool user show "$username" | grep -q "account_locked: true"; then
|
||||||
|
echo -e "${RED}Statut : Compte VERROUILLÉ${NC}"
|
||||||
|
elif samba-tool user show "$username" | grep -q "password_expired: true"; then
|
||||||
|
echo -e "${YELLOW}Statut : Mot de passe EXPIRÉ${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${GREEN}Le compte est actif.${NC}"
|
echo -e "${GREEN}Statut : Compte ACTIF${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Afficher les groupes de l'utilisateur
|
||||||
|
echo -e "\n${BLUE}Groupes:${NC}"
|
||||||
|
samba-tool group listmembers | grep "$username"
|
||||||
|
|
||||||
pause
|
pause
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue