Active Directory login scripts in Mac OS X – Part 1: Basic Approaches

2 Comments
  1. avatar
    prasanna 4 years ago

    I tried to execute a shell script while logon using login hook. It is working fine for root user. Is it possible to execute the shell script using non-root user.

    I tried with the login items by adding the shell script, but no luck.

    Is there any way to execute shell scripts while logon by non-root users

  2. avatar
    stein 4 years ago

    I discovered that the hook running as root causes problems also. Primarily it changes the permisions and the user can’t see the folder on the desktop any longer because it is only available to root.

    And of course I don’t want to log into the server as root.

    According to this page

    http://support.apple.com/kb/Ht2420

    the short username is in $1 (you have to click more near the top to see it though)

    So I tried a script like
    #!/bin/sh
    su – $1
    txtUSER=$(whoami)
    mkdir /Users/$txtUSER/Desktop/Fdrive
    mount_smbfs //MY_SERVER/sys /Users/$txtUSER/Desktop/Fdrive
    mkdir /Users/$txtUSER/Desktop/Hdrive
    mount_smbfs //MY_SERVER/home/$txtUSER /Users/$txtUSER/Desktop/Hdrive
    KillAll Terminal
    exit

    This script will run (without the su -$1) fine when placed in the users login items.

    Note: To get the shortcuts to show on the desktop the user will need to go to finder -> preferences and check connected servers.

    Hope this helps someone else. Wished I could figure out how to switch users to run this command from the hook.
    –Stein

Leave a reply

Your email address will not be published. Required fields are marked *

*

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2016

Log in with your credentials

or    

Forgot your details?