Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get user ID (501, 502, etc.)



on 06/11/11 8:21, Stephan Cleaves at email@hidden wrote:

> This can be achieved with the SystemConfiguration framework.

Thanks.  getuid() returns 0, but this gives the name, user ID and group ID
if you need them..........
 
#import <SystemConfiguration/SCDynamicStoreCopySpecific.h>

NSString* GetConsoleUser(uid_t* p_uid, gid_t* p_gid) ;
// Will return nil if no current console user.
// You may pass NULL as argument(s) if not interested in
// user ID (uid: 501, 502, etc) or group ID (gid).

NSString* GetConsoleUser(uid_t* p_uid, gid_t* p_gid) {
    NSString* name = (NSString*)SCDynamicStoreCopyConsoleUser(
           NULL, p_uid, p_gid);

    return([name autorelease]) ;
}



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: How to get user ID (501, 502, etc.) (From: Stephan Cleaves <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.