How to detect OSX admin password hint?

I am trying (programmatically) to detect an OSX administrator password prompt that appears when changing system security settings. Ideally, solutions will work for C ++ or Objective-C. I looked at various NSDistributedNotificationCenters that provide OS notifications, but none of them seem to be specific to the password hint. I tried registering for all the notifications that the OS can provide, but these notifications seem to stop as soon as I enter the System Preferences window.

I also looked at the concept of SFAuthorizationPlugin , but it seems like more to login from a cold boot.

I know this is possible, as I have seen other applications detect a password prompt and display something on the screen whenever it appears.

So, how can I programmatically determine the OSX admin password prompt?

+5
source share
1 answer

You can listen to SecurityAgent notifications from the workspace.

Sign up for application activation notifications as follows:

 @interface notificationHandler: NSObject {} @end @implementation notificationHandler -(id)init { [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector :@selector(handleNotification) name :NSWorkspaceDidActivateApplicationNotification object :nil]; } // init -(void)handleNotification:(NSNotification *) notification { NSDictionary info = [notification userInfo]; NSString *appName = [[info objectForKey:NSWorkspaceApplicationKey] localizedName]; if ([appName isEqualToString:@"SecurityAgent"]) { // You have found the administrator password prompt! } } // handleNotification @end 
+3
source

All Articles