Search code examples
objective-cmacoscocoauser-accounts

Get list of users that can log in to a Mac


How can I get list of users that can log in to OS X? That is, users that appear in the login window.

I know about Get all Users on OS X

This solution works for only 64 bit architecture. When I switch to 32 bit, it gives all users.

And I do not want to enumerate the Users directory, as a user's home directory can be moved to another location, and other directories can be created inside /Users.


Solution

  • using provided link in question we can retrieve all users.

    and the answer to question:

    we get CBIdentity object, That object has isHidden flag this is true if user is visible on login window.

    Ex:

    bool isTrue = [identityObject isHidden];
    if(isTrue)
    {
        NSLog("User is login user");
    }