Check If Active Console / GUI User


/ Published in: C



Copy this code and paste it in your HTML
  1. - (BOOL) isActiveUser {
  2. NSDictionary *sessionInfo = (NSDictionary *) CGSessionCopyCurrentDictionary();
  3.  
  4. NSString *shortUserName = [sessionInfo valueForKey:kCGSessionUserNameKey];
  5. NSString *userUID = [sessionInfo valueForKey:kCGSessionUserIDKey];
  6. BOOL userIsActive = [[sessionInfo valueForKey:kCGSessionOnConsoleKey] boolValue];
  7. NSString *loginCompleted = [sessionInfo valueForKey:kCGSessionLoginDoneKey];
  8.  
  9. NSLog(@"Session information: %@", sessionInfo);
  10.  
  11. return userIsActive;
  12. }

URL: http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPMultipleUsers/Concepts/FastUserSwitching.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.