The University of Texas at Austin

Austin Active Directory

Example Login Hook Scripts for Mac OS X

These scripts are examples. Full scripts should include error checking and comments.

Example 1

This is the simplest login hook. It returns TRUE, which means all users can log in.

        #!/bin/bash

        echo "ok"

        exit 0

Example 2

This script restricts login to only one user with the EID "joe."

        if test $1 = "joe" ; then

                echo "ok"

                exit 0

        fi

        echo "not ok"

        exit 1

Example 3

This script allows members of the local admin group to login by using the dscl command to check group permissions.

        inGroup=`dscl . -search /Groups GroupMembership $1 | grep admin`

        if test ! "$inGroup" ; then

                echo "not ok"

                exit 1

Example 4

This final example maps arbitrary Active Directory groups to the local administrative group, allowing the resulting set of users to administer the computer.

        theGroup=appserveradm

        inGroup=`dscl . -search /Groups GroupMembership $1 | grep $theGroup`

Last updated June 12, 2012 @ 3:18 pm

We Can Help

Get help from an expert at the ITS Help Desk!

* Call us at 512-475-9400

* Submit a help request online

We also have a walk-in service in the first floor lobby of the Flawn Academic Center (FAC). Stop by and let us help you!