Re: How to automate creation of user accounts
Re: How to automate creation of user accounts
- Subject: Re: How to automate creation of user accounts
- From: "John C. Welch" <email@hidden>
- Date: Sat, 15 Apr 2006 00:16:47 -0500
- Thread-topic: How to automate creation of user accounts
On 4/14/06 21:40, "Gnarlodious" <email@hidden> wrote:
>
>> I desire to automate the creation of user accounts. Is this possible
>> with AppleScript
>
> This script creates a new user called "abuser" with password "1234":
>
>
> set nl to ASCII character 10
> set newUser to "abuser"
>
> set createUser to quoted form of "user=" & newUser & nl & ¬
> "# create a user named $user with password 1234" & nl & ¬
> "# to remove the user later try nidump -destroy / /users/$user" & nl & ¬
> "niutil -create / /users/$user" & nl & ¬
> "niutil -createprop / /users/$user uid 532" & nl & ¬
> "niutil -createprop / /users/$user realname\"$user\"" & nl & ¬
> "niutil -createprop / /users/$user home\"/Users/$user\"" & nl & ¬
> "niutil -createprop / /users/$user shell\"/bin/bash\"" & nl & ¬
> "niutil -createprop / /users/$user gid 20" & nl & ¬
> "niutil -createprop / /users/$user passwd\"rQ3p5/hpOpvGE\" #(it's 1234)"
> & nl & ¬
> "chown -R $user:staff /Users/$user" & nl & ¬
> "chmod -Rf 755 /Users/$user"
>
> --do shell script createUser
>
> Uncomment the last command to actually create the user.
Another shell script option, although you may have to install the server
administrator tools, is to use serversetup, in /System/Library/ServerSetup,
which simplifies much of this. (I tested this on my laptop, and it works
okay for me, on 10.4.6 with the Server Admin Tools)
The initial creation script is:
sudo ./serversetup -createUserWithIDIP BooyahBoy bboy biteme 505 /Users/bboy
Which creates a user, long name BooyahBoy, short name bboy, password of
biteme, UID of 505 and homedir in /Users/bboy
If you don't specifiy the UID or the homedir, they get automatically created
to the defaults that the system would use, (i.e. Next avail UID, default
homedir is created). The default shell and correct GID is automatically
created.
The only thing you'd have to adjust is the home_loc value, which isn't
needed for Netinfo only accounts, and for that you just use
niutil -destroyprop / /users/bboy home_loc
The rest of it is created for you.
If you run serversetup without any parameters, it gives you the full usage
of it, and it's pretty complete. A lot of it won't apply unless you're
running Server, but I've yet to see any problems for user creation kinds of
stuff.
--
"The 2nd French Foreign Legion Parachute Regiment was in-country, and they
would have come to help us. If you get in the Legion's way, doom on you."
- The Sharp End, a Canadian paratrooper discussing UN ops in Rwanda
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden