X-Git-Url: https://arthur.barton.de/gitweb/?p=usertools.macosx.git;a=blobdiff_plain;f=userlist.macosx.sh;fp=userlist.macosx.sh;h=f9f0f2f77d4a4e0fc04ee9456b5c4e78318ab008;hp=0000000000000000000000000000000000000000;hb=6c7b37265f31469124b96d264748e2a6c85161ab;hpb=ad11b55631e98958603f15acb2566a3c30a160d2 diff --git a/userlist.macosx.sh b/userlist.macosx.sh new file mode 100755 index 0000000..f9f0f2f --- /dev/null +++ b/userlist.macosx.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +while [ -n "$1" ]; do + case "$1" in + "--all"|"-a") + ALL=1 + ;; + "--local"|"-l") + LOCAL=1 + ;; + *) + echo "Usage: $0 [--local|-l]" + exit 1 + esac + shift +done + +sw_vers -productName | grep -i "Server" >/dev/null 2>&1 +if [ $? -eq 0 -a -z "$LOCAL" ]; then + # Mac OS X Server + OD=1 +fi + +if [ -n "$OD" ]; then + HOST="localhost" + USER_BASE="/LDAPv3/127.0.0.1/Users" + UID_MIN=1000 +else + HOST="." + USER_BASE="/Users" + UID_MIN=500 +fi + +[ -n "$ALL" ] && UID_MIN=0 + +dscl "$HOST" -list "$USER_BASE" | while read x; do + declare -i id + id=`dscl "$HOST" -read "$USER_BASE/$x" UniqueID | cut -d: -f2` + if [ "$id" -gt $UID_MIN ]; then + echo " $id: $x" + fi +done | sort -n + +# -eof-