Obtains a list of all members of the given group and places it in the buffer supplied by the caller.
#include <ascauth.h>
int ASC_GRPMEM(ASCENV *asce, char *object, char *buf, u_int size);
Returns one of the following integer values defined in ascauth.h:
The list is truncated, and the call returns AS_TOOSMALL if the buffer size cannot hold the entire list. You can retry with a larger buffer.
You can use ASC_SECEQUAL to see if an individual user is a member of a given group.
The groups a given user is a member of are included in the list returned by ASC_LISTSEQV.
#include <stdio.h> #include <stdlib.h> #include <ascauth.h> main(int argc, char *argv[]) { ASCENV *asce; char *group, buffer[2000]; int rc; if (argc != 2) { fprintf(stderr, "usage: %s <group>\n", argv[0]); exit(EXIT_FAILURE); } group = argv[1]; /* initialize the authentication environment */ asce = ASC_INIT(NULL); if (asce == NULL) { fprintf(stderr, "Error: cannot initialize authentication environment\n"); exit(EXIT_FAILURE); } /* Get group membership info */ rc = ASC_GRPMEM(asce, group, buffer, sizeof(buffer)); if (rc == AS_OK) printf("Members of group %s:\n%s\n", group, buffer); else if (rc == AS_TOOSMALL) { printf("Members of group %s:\n%s\n", group, buffer); printf("** list was truncated because of lack of buffer space **\n"); } else printf("RC=%d, %s", rc, ASC_STRERROR(rc)); /* now terminate the authentication environment */ ASC_TERM(asce); return 0; }