• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
In the "I could have done it faster by hand" department
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

In the "I could have done it faster by hand" department


  • Subject: In the "I could have done it faster by hand" department
  • From: c w <email@hidden>
  • Date: Sun, 16 May 2004 13:30:01 +0100

Is there a reasonably straightforward way to script the creation of new users? I have 26 users that I need to add to a bunch of machines.

I have all the parameters in a table.

I tried this: (based on something I found on the web that would not compile, so I tweaked it in a couple areas (and maybe broke it)

I am also pretty sure I don't have SudoShell either. Where to get an OS X version is not immediately apparent.

Chris



-- creates a user in netinfo, requires that you have a default crypt password. if you want to see a crypt password, open up netinfo manager and look at a user.
-- this requires the subroutines nipropshell and SudoShell

tell application "NetInfo Manager"
activate
CreateUser(501, 502, "test user", "dorkass", "tcsh")

end tell

on CreateUser(gid, uid, FullName, CryptPassword, shelltype)
set nicreate to "/usr/bin/niutil -create . /users/" & PrimaryUser
set niinsert to "/usr/bin/niutil -insertval . /groups/"
SudoShell({nicreate})
nipropshell({"change 0", "_writers_passwd " & PrimaryUser, "class \"\"", "expire 0", "gid " & gid, "home /Users/" & PrimaryUser, "name " & PrimaryUser, "_writers_hint " & PrimaryUser})
nipropshell({"_writers_tim_password " & PrimaryUser, "_writers_picture " & PrimaryUser, "passwd CryptPassword", "sharedDir Public", "_shadow_passwd", "authentication_authority ';basic;'"})
nipropshell({"realname \"" & FullName & "\"", "shell " & shelltype, "uid " & uid, "hint \"!ChangeMe\""})
-- to make the user an admin user, include this line
-- SudoShell({niinsert & "wheel users " & PrimaryUser & " 0", niinsert & "admin users " & PrimaryUser & " 0", niinsert & "staff users " & PrimaryUser & " 0"})
SudoShell({"/usr/bin/ditto -rsrc /System/Library/User Template/English.lproj /Users/" & PrimaryUser & "/usr/sbin/chown -R " & PrimaryUser & " /Users/" & PrimaryUser})
end CreateUser






Chris Watts
The Corpse Bride
3 Mills Studios
Three Mills Lane
London E3 3DU


Chris Watts
The Corpse Bride
3 Mills Studios
Three Mills Lane
London E3 3DU

UK
m: +44 (0)7 88-77-33-083
Office +44 0207 8709-8700
Fax +44 0207 8709-8332

USA
m 310-486-6000
c 323-333-5000
o 310-399-3799
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: In the "I could have done it faster by hand" department
      • From: Dave Balderstone <email@hidden>
    • Re: In the "I could have done it faster by hand" department
      • From: Gnarlodious <email@hidden>
  • Prev by Date: Darmouth
  • Next by Date: Shutdown script
  • Previous by thread: Re: Darmouth
  • Next by thread: Re: In the "I could have done it faster by hand" department
  • Index(es):
    • Date
    • Thread