Hello, all.

Does any of you know how to authorize a user as an admin user using the SFPreferenceView?

I'm writing a preference pane for the System Preference.
What this custom preference pane does are :

- Display system wide setting, but until a user clicks the "lock" icon, a user is not allowed to change it. When the user clicks the "lock" icon, it asks ID and password. ( This is done by the SFPreferenceView. )

- Display user-specific setting and allows changing them

- When the user choose other preference pane, it saves the system-wide setting and the user-specific setting.


To save the system-wide setting, I used :

   CFPreferenceSetValue( CFSTR("System Name", [systemNameField
   stringValue], kAppID, kCFPreferencesAnyUser, kCFPreferencesAnyHost );

   isSuccessful = CFPreferencesSynchronize( kAppID,
   kCFPreferencesAnyUser, kCFPreferencesAnyHost );


Currently the SFPreferenceView is initialized like :

   [authView setDelegate:self];
   [authView setString:appID_UTF8_CString];
   [authView updateStatus:self];
   [authView setEnabled:YES];


For being sure, I also obtain the authorization from the authView and tried setting kAuthorizationRuleAuthenticateAsAdmin.

   SFAuthorization *authorization = [authView authorization];
   AuthorizationRef authRef = [authorization authorizationRef];
   AuthorizationRights *authRights = [authView authorizationRights];

   CFStringRef keys[2] = { CFSTR(kAuthorizationRightRuel),
   CFSTR(kAuthorizationComment)};
   CFStringRef values[2] = {
   CFSTR(kAuthorizationRuleAuthenticateAsAdmin), CFSTR("Authorize as
   Admin") };

   CFDictionaryRef dictRef = CFDictionaryCreate( NULL, (void *)keys,
   (void *)values, 2, &kCFCopyStringDictionaryKeyCallBacks,
   &kCFTypeDictionaryValueCallBacks);

   // To modify the authorization of the authView, the authRef is used.
   result = AuthorizationRightSet( authRef, authRights->items[0].name,
   dictRef, CFSTR("Authorize as an admin"), NULL, NULL );


Although it returns 1 for the isSuccessful, it doesn't create a plist file in /Library/Preferences directory for the system-wide setting.

Can anyone help me?

Thank you.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to