Authorization and removing folders
Authorization and removing folders
- Subject: Authorization and removing folders
- From: "Glover,David" <email@hidden>
- Date: Thu, 6 Nov 2008 17:20:07 -0000
- Thread-topic: Authorization and removing folders
Hi all,
I need to remove a folder from within /Applications/OurCompany, so I'm
using Authorization Services to get Admin rights, and then using
removeFileAtPath to remove the folder.
When I'm logged on as admin, this works perfectly fine. When I'm logged
in as a standard user, I authenticate with the admin username and
password, authorization is granted ok, but then it still can't delete
the folder.
Can anybody suggest what I might be missing here? Perhaps I have
mis-understood the Apple security documentation?
Here is my code in case that may shed any light on this (strFolderPath
is declared earlier in the code....)
// create the authorization reference...
AuthorizationRef myAuthorizationRef;
OSStatus myStatus;
myStatus = AuthorizationCreate (NULL,
kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults,
&myAuthorizationRef);
AuthorizationItem myItems[1];
AuthorizationRights myRights;
myRights.items = myItems;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
myItems[0].name = "com.Test.myRight1";
myItems[0].valueLength = 0;
myItems[0].value = NULL;
myItems[0].flags = 0;
myRights.count = 1;
if (AuthorizationCopyRights (myAuthorizationRef, &myRights,
kAuthorizationEmptyEnvironment, myFlags, NULL) ==
errAuthorizationSuccess)
{
panel = NSRunAlertPanel (@"Test", @"Got
Authorization!", @"OK", nil, nil);
if ([NSFm removeFileAtPath: (NSString *)
strFolderPath handler: nil] == NO)
{
panel = NSRunAlertPanel (@"Test",
@"Folder NOT removed", @"OK", nil, nil);
}
else
{
panel = NSRunAlertPanel (@"Test",
@"Folder removed", @"OK", nil, nil);
}
}
else
{
panel = NSRunAlertPanel (@"Test", @"Not Got
Authorization!", @"OK", nil, nil);
}
Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18
______________________________________________
Promethean Ltd and or associated and or subsidiary companies :
The views expressed in this communication may not necessarily be
the views held by Promethean Ltd and or associated and or subsidiary companies.
This e-mail is for the exclusive use of the addressee(s). Unauthorised
disclosure, copying or distribution is prohibited.
This e-mail message has been swept for the presence of computer viruses.
Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission.
Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you!
*****************************************************************
This email has been checked by the e-Sweeper Service
*****************************************************************
_______________________________________________
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