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 <iseecol...@sbcglobal.net> 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 (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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com

Jonathan Mitchell

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




_______________________________________________

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 arch...@mail-archive.com

Reply via email to