Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- #
- # Script to detect if a user is a member of the admin group. If not, and they are not a student, it will add them.
- # LoginHook passes the current username as $1
- #
- # Check if user is already an admin
- IsAdmin=$(dseditgroup -o checkmember -n . -u $1 admin)
- # echo "$IsAdmin"
- if [[ $IsAdmin == yes* ]]
- then
- # echo "No further action needed"
- exit
- else
- # Domain Admin Member Check
- DAmember=$(dseditgroup -n /Active\ Directory/DOMAIN/DOMAIN.local -o checkmember -u $1 Domain\ Admins)
- # All Administrative Staff
- AAmember=$(dseditgroup -n /Active\ Directory/DOMAIN/DOMAIN.local -o checkmember -u $1 AdminGroup1)
- # All Teacher Member Check
- ATmember=$(dseditgroup -n /Active\ Directory/DOMAIN/DOMAIN.local -o checkmember -u $1 AdminGroup2)
- # All Office Member Check
- AOmember=$(dseditgroup -n /Active\ Directory/DOMAIN/DOMAIN.local -o checkmember -u $1 AdminGroup3)
- # Adds to local admin if user is a member of Domain Admins, LISD Administrative Staff, LISD All Teacher, or LISD All Office groups
- if [[ $DAmember == yes* ]] || [[ $AAmember == yes* ]] || [[ $ATmember == yes* ]] || [[ $AOmember == yes* ]]
- then
- # echo "User is a member of Domain Admins, All Administrative Staff, All Teachers, or All Office."
- sudo dscl . append /Groups/admin GroupMembership $1
- fi
- fi
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement