Name
vxdb_sgmapget - retrieve secondary groups of a user
Synopsis
#include <vitalnix/libvxdb/libvxdb.h>
#include <vitalnix/libvxpdb/xafunc.h>
int vxdb_sgmapget(struct vxdb_state *handle, const char *user, char ***result);
Link with -lvxdb.
Description
vxdb_sgmapget()
will retrieve the list of
secondary (or "supplementary") groups the user is a member of. It will allocate
an appropriately-sized NULL-terminated array and store it in
*list
if the user has one or more groups. If the user has
zero groups, or NULL is passed for result, nothing will be allocated.
Always check the return value of the function.
Return value
On success, the number of groups is returned, which may be zero or more. On error, a negative value is returned, indicating the error.
-ENOENT |
The user does not exist. |
-ENOMEM |
Out of memory. |
-EPERM |
Not enough privileges to complete this operation. |
Example
char **groups, **g;
if (vxdb_sgmapget(dbh, "jengelh", &groups) > 0)
for (g = groups; *g != NULL; ++g)
printf("%s,", *g);