Home › Forums › OS X Server and Client Discussion › Questions and Answers › Detect Network Account
- This topic has 6 replies, 5 voices, and was last updated 15 years, 9 months ago by
manola.
-
AuthorPosts
-
May 19, 2009 at 1:07 pm #376219
vogtstev
ParticipantGreetings!!
[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!
SteveMay 19, 2009 at 3:55 pm #376221Greg Neagle
ParticipantDo 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
fiand here’s how I get the home dir (no matter the account type) in a login hook:
#!/bin/csh
set homedir=~$1Note that I used /bin/csh in the second example. /bin/sh won’t do the same thing.
There are other ways to do these.
May 27, 2009 at 4:22 am #376296vogtstev
ParticipantThank 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″
fiThanks!
SteveJune 3, 2009 at 2:38 pm #376371tlarkin
ParticipantBy 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.
June 11, 2009 at 1:39 am #376423verra99
Participant[url=http://simulationcredit1.com][color=#F7F7F7][u]simulationcredit[/u][/color][/url]
Thanks for your posts. They are really very cool, very wonderful.
June 12, 2009 at 3:34 pm #376436Greg 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
June 25, 2009 at 7:13 am #376503manola
ParticipantI 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] -
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed