> Does anyone have any working code for checking if a user is in a PTS group?
>
> I have some code currently that uses the pr_Initialize and pr_IsAMemberOf
> functions, but it doesn't work, gives a bus error in pr_Initialize.
>
> Basically, I would like a routine that can be passed two strings, a user
> name and a group name, and return 1 or 0 depending on whether or not they
> are in the group.
>
> Even a quick snippet on how to use some of the calls that have a
> rx_connection parameter would be helpful.
>
> What would be really nice would be a copy of the source to pts. *grin*
Well, I can't give you that, although I've heard Transarc will be more
than happy to sell it to you. :-)
A couple of years ago, I wrote a program which needed to know this.
Due to the nature of our application, it was desirable to simply fetch
the list of group members once, and do the search ourselves. Naturally,
we updated our cached list once in a while. The relevant code looks like
this:
int auth_init()
{
char cellname[sizeof(AFS_CELL)];
int err;
strcpy(cellname, AFS_CELL);
err = pr_Initialize(0L, AFSCONF_CLIENTNAME, cellname);
if (err) {
fprintf(stderr, "Error %d while starting AFS protection package", err);
exit(1);
}
}
/* Get the members of a given PTS group */
static int getptsmem(char *name, namelist *members)
{
long err;
int id;
static char xname[257];
err_printf(DBG_FUNC, "getptsmem(%s, NAMELIST)", name);
strcpy(xname, name);
if ((err = pr_SNameToId(xname, &id)) || id == ANONYMOUSID)
{
err_printf(EL_ERROR, "No such pts user/group as %s", name);
err_printf(EL_ERROR, "Error code was %d", err);
return 0;
}
members->namelist_len = 0;
members->namelist_val = 0;
if (err = pr_IDListMembers(id, members))
{
err_printf(EL_ERROR, "Unable to get membership of user/group %s", name);
freenamelist(members);
return 0;
}
return 1;
}
-- Jeffrey T. Hutzelman (N3NHS) <[EMAIL PROTECTED]>
Systems Programmer, CMU SCS Research Facility
Please send requests and problem reports to [EMAIL PROTECTED]