• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: User Access Rights
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User Access Rights


  • Subject: Re: User Access Rights
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 15 May 2009 20:38:18 +0100


On 15 May 2009, at 20:15, iseecolors wrote:

Actually the only reason I want to know is that tech support wants to know when a user calls in.

I just want to place some text in the UI, so that indicates whether the user has admin rights or not.

Rich

Try the Identity Services Programming Guide.
also see http://www.cimgf.com/2008/04/09/cocoa-tutorial-introduction-to-identity-services/

I use the following code, though it may not be exactly what you require:

if ([[MGSUser currentUser] isMemberOfAdminGroup]) {
...
}

//
//  MGSUser.h
//
//  Created by Jonathan on 31/05/2008.
//  Copyright 2008 Mugginsoft. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <Collaboration/Collaboration.h>

@interface MGSUser : NSObject {
	CBIdentity *_user;
}

+ (id)currentUser;
- (id)initWithName:(NSString *)name;
- (BOOL)isMemberOfAdminGroup;

@end

//
//  MGSUser.m
//
//  Created by Jonathan on 31/05/2008.
//  Copyright 2008 Mugginsoft. All rights reserved.
//

#import "MGSUser.h"


static MGSUser *_currentUser = nil;

@implementation MGSUser

/*

 current user

 */
+ (id)currentUser
{
	if (!_currentUser) {
		_currentUser = [[self alloc] initWithName: NSFullUserName()];
	}
	return _currentUser;
}

/*

 init with user name

*/
- (id)initWithName:(NSString *)name
{
if ([super init]) {
CBIdentityAuthority *authority = [CBIdentityAuthority defaultIdentityAuthority]; // default is local and network
_user =[CBIdentity identityWithName:name authority:authority]; // searches for full and logon names
}
return self;
}
/*


 user is member of admin group

*/
- (BOOL)isMemberOfAdminGroup
{
CBIdentityAuthority *authority =[CBIdentityAuthority defaultIdentityAuthority]; // default is local and network
// admin is 80, user is 20.
// to see user group membership type 'id' at terminal
// for list of groups type 'more /etc/group'
return [_user isMemberOfGroup:[CBGroupIdentity groupIdentityWithPosixGID:80 authority:authority]];
}
@end


On May 15, 2009, at 12:02 PM, Kyle Sluder wrote:

On Fri, May 15, 2009 at 2:33 PM, iseecolors <email@hidden> wrote:
I am looking for how to determine if a given user is allowed to Administer
the host computer or not. I am guessing that there is something similar to
CFPreferencesCopyValue or NSUserName that I can use to determine this
information.

Don't try to head the user off at the pass. If you need the user to authenticate as an administrator, don't disable that functionality simply because the user is not an administrator. The authorization interface allows authenticating as any administrator, not just the currently logged-in user.

--Kyle Sluder

_______________________________________________

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

Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




_______________________________________________

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


  • Follow-Ups:
    • Re: User Access Rights
      • From: iseecolors <email@hidden>
References: 
 >NSXMLParser frees itself on error? (From: Mike Manzano <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Marcel Weiher <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Jeff Johnson <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Marcel Weiher <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Michael Ash <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Marcel Weiher <email@hidden>)
 >Re: NSXMLParser frees itself on error? (From: Michael Ash <email@hidden>)
 >HFS Format API? (From: iseecolors <email@hidden>)
 >Re: HFS Format API? (From: Andrew Farmer <email@hidden>)
 >User Access Rights (From: iseecolors <email@hidden>)
 >Re: User Access Rights (From: Kyle Sluder <email@hidden>)
 >Re: User Access Rights (From: iseecolors <email@hidden>)

  • Prev by Date: Re: NSCFArray autoreleased with no pool in place
  • Next by Date: Re: User Access Rights
  • Previous by thread: Re: User Access Rights
  • Next by thread: Re: User Access Rights
  • Index(es):
    • Date
    • Thread