Get all Users on OS X

后端 未结 3 1716
我在风中等你
我在风中等你 2020-12-06 03:54

So I want to implement Parental Controls per user in my app, but I need a way of getting all Users and add them to an NSTableView. These users should be the same displayed b

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 04:15

    From the command line, you can run

    dscl localhost -list /Local/Default/Users
    

    There are a lot of users that start with the underscore character that can be ignored by you app. This command can of course be run from within cocoa and the output read, but it can also be accessed more directly.

    You can also use an Apple framework, but it is probably easier to use a wrapper. I can't find a very recent one right now, but search for something like this:

    http://www.martinkahr.com/2006/10/15/cocoa-directory-services-wrapper/index.html

提交回复
热议问题