Re: How to get user ID (501, 502, etc.)
Re: How to get user ID (501, 502, etc.)
- Subject: Re: How to get user ID (501, 502, etc.)
- From: Jerry Krinock <email@hidden>
- Date: Sat, 11 Nov 2006 15:01:16 -0500
- Thread-topic: 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:
This email sent to email@hidden