Showing posts with label OS X. Show all posts
Showing posts with label OS X. Show all posts

Wednesday, February 20, 2013

Allowing Non-Admin users to add printers OS X clients

Problem: I need to allow non-administrator users add printers to Mac OS X.

Solution:

Add the GeneratedUID from the everyone group (ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C) to the NestedGroups attribute of the _lpadmin group.

dscl . -append /Groups/_lpadmin NestedGroups ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C 
References:

Thursday, April 10, 2008

Find the console user on OS X

I do allot of OS X packaging, and I one thing that I have been looking for is a way to identify the current user logged into the console (The GUI). I found the answer in a configuration files for SleepWatcher. "SleepWatcher ...is a command line tool (daemon) for Mac OS X that monitors sleep, wakeup and idleness of a Mac."
echo 'show State:/Users/ConsoleUser' | scutil | awk '/kCGSSessionUserNameKey/ { print $3 }'
echo 'show State:/Users/ConsoleUser' -- Echo a command to scutil
scutil -- Take piped input from echo above.
awk '/kCGSSessionUserNameKey/ { print $3 }' -- Find the line kCGSSessionUserNameKey and print 3rd item (The Username).
scutil -- Manage system configuration parameters. You can find the scutil man page here

Thursday, March 13, 2008

Add second shortname to OD Users

Micah Baker, the other day asked me about adding a secondary shortname to OD users.

So how do you add a secondary short name? We could use WorkGroup Manger, but I like the command line and automation.
So I use dscl the command line directory services utility. See the dscl man page here
dscl -u (OD-DIR-ADMIN) -P (PASSWORD) /LDAPv3/(ODMASTER-DN) -append Users/(SHORTNAME) uid (SHORTNAME TO ADD)
Micah had first_last as the username, and wanted to add first.last to all his users.
So through a script together.

#!/bin/bash -
# Eden Nelson 3/12/08
# add shortname

#Please set these vars!!!
# OD Master DNS
ODMASTER=
# OD Dir Admin
ODADMIN=
# OD Dir Admin Pass
ODPASS=
#Temp file where usernames are kept
TEMPFILE=/tmp/default.tmp
#Sleep between operations, keep the script from hammering the ODM
SLEEP=3

## ##
# Script Starts Here #
## ##

trap "{ rm -f $TEMPFILE ;}" EXIT SIGINT SIGTERM

dscl /LDAPv3/"$ODMASTER" -list Users > "$TEMPFILE"

cat "$TEMPFILE" | \
while read USERNAME
do

FIRSTNAME=`echo $USERNAME | cut -d'_' -f 1`
LASTNAME=`echo $USERNAME | cut -d'_' -f 2`

dscl -u "$ODADMIN" -P "$ODPASS" /LDAPv3/"$ODMASTER" -append Users/"$USERNAME" uid "$FIRSTNAME"."$LASTNAME"

sleep "$SLEEP"

done

exit 0