I am posting this here because I need some help.
I am trying to automate a lot of configuration tasks through AppleScript for new Macs at a University setting. For instance, we have configuration scripts that handle the naming convention, Windows AD Binding, and other environmental variables.
However, even after I add a person, I am forced, I find, to go back and manually edit the box within the System Preferences GUI in System Preferences > Users and Groups > Allow network users to log in at login window.
Ideally, I’d like to tie that to the Applescript where I designate which account can login and become admins automatically. I handle that with the following piece of a script. As I designate a user to have admin rights, I’d also like to give them rights under “Allow network users to log in at login window.” etc.
(*
Adding user who will become an admin upon logging in.
For faculty and staff who use this as their main machine which will eventually tie into their AppleID, this is where you can pre-stage the user
Reference from here: http://support.apple.com/en-us/HT202112
http://superuser.com/questions/214004/how-to-add-user-to-a-group-from-mac-os-x-command-line
*)
set reRun to true
display dialog "Here is your chance to enter an Active Directory account which will automatically be made an admin upon login" with icon Note buttons {"No admins.", "Yes, let's do that."}
if result = {button returned:"Yes, let's do that."} then
set reRun to true
else if result = {button returned:"No admins."} then
set reRun to false
end if
repeat while reRun is true
try
display dialog "Enter the name of the user who will be an admin on first login:" default answer "stevejobs"
set majorDomus to text returned of result
try
do shell script "dseditgroup -o edit -a " & majorDomus & " -t user admin" with administrator privileges
end try
end try
try
display dialog "Shall we enter another?" with icon note buttons {"Yes. Let's do so.", "No, Let's move on."} default button 1
if result = {button returned:"Yes. Let's do so."} then
set reRun to true
else if result = {button returned:"No, Let's move on."} then
set reRun to false
end if
end try
end repeat