To find out how to do this, read on...
We can use the command line or NetInfo Manager to accomplish this. I will show the commands via the Terminal command line because it is easier for me.
To disable the account, we insert the *:
sudo niutil -insertval . /users/user-in-question passwd '*' 0And to re-enable it, we remove the *:
sudo niutil -destroyval . /users/user-in-question passwd '*'I have a couple of friends who don't know their way around OS X but they needed this functionality. I wrote them a simple AppleScript to toggle between these two settings. I won't go into the details of the script for that is beyond the scope of this hint. The only work on your part, is to paste this code into Script Editor being sure to change "user-in-question" to the user you want to disable. Save it as an application and you now have an easy way to toggle a user's login!
--begin AppleScript[Sudo Editor's Warning: Please be comfortable with the command line before you try this hint. The user you are tring to alter login abilities for might not be able to log back in if you make a mistake.]
--change user-in-question to the short name of the user you want to toggle on and off
set user_name to "user-in-question"
--the rest of this doesn't need to be edited but feel free if you want to
set passwd to do shell script "niutil -readval . /users/" & user_name & " passwd 0"
set full_name to do shell script "niutil -readval . /users/" & user_name & " realname 0"
if passwd is "*" then
set action_word to "Enable "
set ni_command to "-destroyval"
set other_word to "now"
else
set action_word to "Disable "
set ni_command to "-insertval"
set other_word to "no longer"
end if
display dialog action_word & full_name & "'s Login?" buttons {"Yes", "No"} default button 2 with icon 2
if the button returned of the result is "Yes" then
do shell script "niutil " & ni_command & " . /users/" & user_name & " passwd '*' 0" with administrator privileges
activate
display dialog full_name & " can " & other_word & " log in." buttons {"OK"} default button 1 with icon 1
else
display dialog "No changes were made." buttons {"OK"} default button 1 with icon 1
end if
--end AppleScript

