Programmatically creating a new user on Mac OS using Objective-C or any Cocoa API? [closed]
I'm trying to create new user within my Ap开发者_如何学Cplication. I know that is possible using dscl and NSTask.But does anyone know how it is possbile to do with any Cocoa API , or programmaticaly using objective-c? within code , not using bash commands , like here
sudo niutil -create / /users/newuser
sudo niutil -createprop / /users/newuser uid 502
sudo niutil -createprop / /users/newuser gid 502
sudo niutil -createprop / /users/newuser realname "Longer Name"
sudo niutil -createprop / /users/newuser home "/Users/newuser "
sudo niutil -createprop / /users/newuser shell "/bin/tcsh"
sudo niutil -createprop / /users/sharedDir shell "Public"
sudo niutil -createprop / /users/newuser passwd "*"
sudo passwd newuser
sudo ditto /System/Library/User\ Template/English.lproj /Users/newuser
sudo chown -R newuser :group /Users/newuser
I was told that is possible to do using Open Directory Framework, but couldn't find usefull documentation. Thanks.
精彩评论