Writing kCFPreferencesAnyUser preferences by limited user
Writing kCFPreferencesAnyUser preferences by limited user
- Subject: Writing kCFPreferencesAnyUser preferences by limited user
- From: Alexander Shmelev <email@hidden>
- Date: Sat, 14 Feb 2009 02:54:00 +0300
Hello,
I have Cocoa application, which have to store global settings, so I
use CFPreferences...(..., kCFPreferencesAnyUser,
kCFPreferencesCurrentHost).
Everything was ok while I launched application as admin user, but when
I switched to limited user, settings changes were not saved.
I have found that I should use Security.framework. Then I wrote code
below, it shows authentication dialog for limited user, but settings
still not saving for limited user.
What do I do wrong? Could you advise me how to fix code?
extern OSStatus AcquireRight(const char *rightName)
{
OSStatus err;
static const AuthorizationFlags kFlags =
kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagExtendRights;
AuthorizationItem kActionRight = { rightName, 0, 0, 0 };
AuthorizationRights kRights = { 1, &kActionRight };
assert(gAuthorization != NULL);
// Request the application-specific right.
err = AuthorizationCopyRights(
gAuthorization, // authorization
&kRights, // rights
kAuthorizationEmptyEnvironment, // environment
kFlags, // flags
NULL // authorizedRights
);
return err;
}
...
OSStatus err = AuthorizationCreate(NULL, NULL, 0, &gAuthorization);
err = AcquireRight("system.preferences");
CFPreferencesSetValue(CFSTR("jpegCompressionFactor"),
(CFNumberRef)jpegCompression, CFSTR(MFSDomainName),
kCFPreferencesAnyUser, kCFPreferencesCurrentHost);
CFPreferencesSynchronize(CFSTR(MFSDomainName), kCFPreferencesAnyUser,
kCFPreferencesCurrentHost);
...
---
BR, Alexander
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden