• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get user ID (501, 502, etc.)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

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

  • Prev by Date: Re: Spawning windows.
  • Next by Date: Re: NSScrollView bug or misunderstood behavior?
  • Previous by thread: Re: How to get user ID (501, 502, etc.)
  • Next by thread: Re: How to get user ID (501, 502, etc.)
  • Index(es):
    • Date
    • Thread