1
1

2 Sitoutukset 7974becd2e ... ddb4840f5c

Tekijä SHA1 Viesti Päivämäärä
  theo ddb4840f5c Fixed remaining bit of french 2 vuotta sitten
  theo 954d66db77 Added a script to remove a user from one or more group(s) 2 vuotta sitten
3 muutettua tiedostoa jossa 46 lisäystä ja 3 poistoa
  1. 2 2
      createperson
  2. 43 0
      removefromgroups
  3. 1 1
      removeperson

+ 2 - 2
createperson

@@ -23,7 +23,7 @@ userPassword: $pw"
 
 echo "$user" | ldapadd $LDAPOPTS
 
-read -p "User added. Do you want to make it a posixAccount? [o/N] " a
+read -p "User added. Do you want to make it a posixAccount? [y/N] " a
 
 case $a in
     y*|o* )
@@ -32,7 +32,7 @@ case $a in
         true;;
 esac
 
-read -p "User added. Do you want to add them to groups ? [o/N] " a
+read -p "User added. Do you want to add them to groups ? [y/N] " a
 
 case $a in
     y*|o* )

+ 43 - 0
removefromgroups

@@ -0,0 +1,43 @@
+#!/bin/bash
+. .env
+. funcs
+
+uid=$1
+
+if user_exists $uid; then
+    true
+else
+    echo "User $uid does not exist." 
+    exit 1
+fi
+
+group_ofnames="dn: cn=%GROUP%,$GROUPSDN
+changeType: modify
+delete: member
+member: uid=%UID%,$PEOPLEDN"
+
+group_posix="dn: cn=%GROUP%,$GROUPSDN
+changeType: modify
+delete: memberUid
+memberUid: %UID%"
+
+# remove uid ($1) from args so that only the list
+# of groups remains in $@
+shift
+
+# remove user from each of the groups given
+for g in $@; do
+    if group_exists $g ; then
+	if group_is_posix $g; then
+		user_is_posix $uid || echo "User $uid is not a posixAccount, skipping posixGroup $g..." && continue
+		group="$group_posix"
+	else
+		group="$group_ofnames"
+	fi
+	echo "$group" | sed \
+	    -e "s/%GROUP%/$g/" \
+	    -e "s/%UID%/$uid/" | ldapmodify $LDAPOPTS
+    else
+        echo "Group $g does not exist, skipping..."
+    fi
+done

+ 1 - 1
removeperson

@@ -10,7 +10,7 @@ else
     exit 1
 fi
 
-read -p "Are you sure you want to delete user $uid [o/N] " a
+read -p "Are you sure you want to delete user $uid [y/N] " a
 
 case $a in
     y*|o* )