• 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: Security Framework: Authori(s/z)ion Rights
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Security Framework: Authori(s/z)ion Rights


  • Subject: RE: Security Framework: Authori(s/z)ion Rights
  • From: "Huyler, Christopher M" <email@hidden>
  • Date: Mon, 10 Nov 2003 11:09:18 -0500
  • Thread-topic: Security Framework: Authori(s/z)ion Rights

Thanks for this tip...I actually figured it out last Friday before I got
this email...I just hope Apple sticks with using the "admin" group to
distinguish Administrators.

int groups[MAX_GROUPS];
int size = MAX_GROUPS;
struct group *pgrp;
int i,ret;

ret = getgrouplist((const char *)username, -1, groups, &size);
if (ret == 0)
{
i = 0;
while ( i<size )
{
pgrp = getgrgid(groups[i]);
if (pgrp && strcmp(pgrp->gr_name,"admin") == 0)
return true;
i++;
}
}
return false;



-----Original Message-----
From: Nick Zitzmann [mailto:email@hidden]
Sent: Saturday, November 08, 2003 12:30 AM
To: Huyler, Christopher M
Cc: email@hidden
Subject: Re: Security Framework: Authori(s/z)ion Rights


On Nov 7, 2003, at 7:49 AM, Huyler, Christopher M wrote:

> Can anyone answer these questions?????

Sorry, not me. I've only used the default rights with the Authorization
functions...

> 3) If all I have is a user name, is there a way to check to see that
> the
> user is an administrator?

But this one I can answer: Call the function "getgrouplist()" with the
user's "short" name as the first parameter, and check to see if the
user belongs to group #80, which is the gid for the "admin" group in OS
X. If the user belongs to that group, then the user is an admin. See
the man page for getgrouplist(3) for details...

Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page: http://seiryu.home.comcast.net/
S/MIME signature available upon request

"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Security Framework: Authori(s/z)ion Rights
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Re: DataSource class of NSTableView - weird
  • Next by Date: Re: itunes for windows HOWTO ???
  • Previous by thread: Re: Security Framework: Authori(s/z)ion Rights
  • Next by thread: Re: Security Framework: Authori(s/z)ion Rights
  • Index(es):
    • Date
    • Thread