Re: Group Identity Programming
Re: Group Identity Programming
- Subject: Re: Group Identity Programming
- From: Keary Suska <email@hidden>
- Date: Tue, 28 Apr 2009 13:00:14 -0600
On Apr 28, 2009, at 8:58 AM, Jessica Billings wrote:
I am trying to write a program that, among other things, generates a
list of
user and group identities using the identity picker and then checks
to see
if the logged-on user matches any user identity or is a member of
any group.
I can do the first task, but I am having trouble with the group
identity
part.
My main issue, I believe, is that I cannot get to the group-specific
attributes ("gid" and "members"). I have tried the function
"identityWithName:authority:" two different ways:
CBGroupIdentity *groupID = [CBGroupIdentity identityWithName:[tmpArray
objectAtIndex:i] authority:[CBIdentityAuthority
defaultIdentityAuthority]];
CBGroupIdentity *groupID = [CBIdentity identityWithName:[tmpArray
objectAtIndex:i] authority:[CBIdentityAuthority
defaultIdentityAuthority]];
Why do think this would work at all? It is not consistent with the
documentation. -identityWithName:authority: returns a CBIdentity
object, not a CBGroupIdentity object. So of course it will not respond
to CBGroupIdentity instance methods.
The "tmpArray objectAtIndex:i" is an NSString representation of the
group's
name, but I have also tried it with the UUID.
This gives me the warning "initilization from distinct Objective-C
type".
When I try to call "members" or "posixGID" on either of these, the
program
hangs.
This should have been the first clue that you're doing something wrong.
Also, I have tried to just circumvent creating a group identity and
get to
the heart of the matter by doing the following, using a test group I
generated myself on the local machine (the other groups were made by
someone
else and are not local groups):
NSString *user = NSUserName();
CBIdentity *localIdentity = [CBIdentity identityWithName:user
authority:[CBIdentityAuthority defaultIdentityAuthority]];
[localIdentity isMemberOfGroup:[CBGroupIdentity
identityWithName:@"test_group"
authority:[CBIdentityAuthority localIdentityAuthority]]];
Except that you aren't circumventing anything, you are juts doing the
same wrong thing: [CBGroupIdentity
identityWithName:@"test_group"authority:[CBIdentityAuthority
localIdentityAuthority]]. You cannot get a group identity this way.
The third thing I tried is getting the gid using:
gid_t curGroupID = getgid(); OR
int curGroupID = getgid();
CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
defaultIdentityAuthority]];
When I try to show the gid using NSLog, it hangs the program. When I
show
the groupIdentity object, it returns (null).
The above is better. What does the debugger show for curGroupID? There
is no reason to hang on NSLog if for curGroupID, as it is really juts
an unsigned int. What is the NSLog code you are using?
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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