开发者

Programmatically creating a new user on Mac OS using Objective-C or any Cocoa API? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜