Is there any way to get currently logged in user type (root, admin or normal) through objective C?
I know about NSFullUserName() which gives user name, but how to retrieve user type?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can retrieve the user group using
getpwnamorgetpwuidthen usegetgrgidto get the group name from the gid.These are C functions in the standard library.
— EDIT: Here is a short, poorly coded C example —
Here is a small example, on mac os in the terminal it should build using make (if you name the file
getpwnam_example.cyou can do$ make getpwnam_examplein the same directory as the c file).