Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #376219
    vogtstev
    Participant

    Greetings!!
    [b]
    The short version:
    I need to write a shell script to detect if an account logging in, is a network account or local account. Then based on that set a variable to where their home directory is.[/b]

    The long version:
    I have decided to use MCX in the fullest this summer and use my Leopard server to push all my prefs and a network login script. I would like to do this for local users and network accounts. All my prefs are pushing perfectly, but I’m stuck on my login script. I currently have a script that copies things that WGM doesn’t handle like not plist preferences. it traditionally just copies things to the network account, however now I need to push to local accounts as well and I’m wondering how I can go about testing within a shell script if an account is local or networked?

    Thank you so much for any ideas!
    Steve

    #376221
    Greg Neagle
    Participant

    Do you really need to know if it’s a network account, or do you just need to know where the home directory is?

    Here’s how I detect local accounts in a login hook:

    #!/bin/sh
    USERNAME=$1
    LOCALACCT=`/usr/bin/dscl . read /Users/$USERNAME 2>/dev/null`
    if [ “$LOCALACCT” != “” ]; then
    # $USERNAME is a local account
    else
    # $USERNAME is a network account
    fi

    and here’s how I get the home dir (no matter the account type) in a login hook:

    #!/bin/csh
    set homedir=~$1

    Note that I used /bin/csh in the second example. /bin/sh won’t do the same thing.

    There are other ways to do these.

    #376296
    vogtstev
    Participant

    Thank you! That makes perfect sense!! Here is what I did:

    LOCAL=`/usr/bin/dscl . read /Users/$1`

    # Check if user is local
    if [ “$LOCAL” != “” ]; then
    HOMEDIR=”/Users/$1″
    fi

    Thanks!
    Steve

    #376371
    tlarkin
    Participant

    By default all local accounts have a UID of 500 to 999 and all open directory accounts, be portable or network have a UID of 1000 or greater. You can maybe do it by UID I think.

    Another method is if you do an authenticated bind you can set computer group policy to apply MCX to local user accounts via WGM and don’t even have to script anything out.

    #376423
    verra99
    Participant

    [url=http://simulationcredit1.com][color=#F7F7F7][u]simulationcredit[/u][/color][/url]

    Thanks for your posts. They are really very cool, very wonderful.

    #376436
    Greg Neagle
    Participant

    [QUOTE][u]Quote by: tlarkin[/u][p]By default all local accounts have a UID of 500 to 999 and all open directory accounts, be portable or network have a UID of 1000 or greater. You can maybe do it by UID I think[/p][/QUOTE]

    While that’s the current behavior of OS X and Open Directory, I wouldn’t rely on it. And if you are using any directory service other than Apple’s Open Directory it’s unlikely to follow Apple’s conventions as far as UIDs.

    -Greg

    #376503
    manola
    Participant

    I can go about testing within a shell script if an account is local or networked?
    [url=http://sonneriegratuite.org][color=#EEF2F7][u]sonnerie portable gratuite[/u][/color][/url]

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Comments are closed