From 22926c814d238c462f9957f2753c7ce7dc7a6797 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 3 Nov 2001 21:12:44 +0000 Subject: Added support for UserListGroups, ServiceEnum (This used to be commit 4e882289b0e291bb57d48fc2b2120919632daa5f) --- source3/libsmb/clirap2.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) (limited to 'source3/libsmb') diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c index 5a834e7b7a..f19ec3e758 100644 --- a/source3/libsmb/clirap2.c +++ b/source3/libsmb/clirap2.c @@ -497,6 +497,62 @@ int cli_NetGroupGetUsers(struct cli_state * cli, char * group_name, void (*fn)(c return res; } +int cli_NetUserGetGroups(struct cli_state * cli, char * user_name, void (*fn)(const char *, void *), void *state ) +{ + char *rparam = NULL; + char *rdata = NULL; + char *p; + int rdrcnt,rprcnt; + int res = -1; + char param[WORDSIZE /* api number */ + +sizeof(RAP_NetUserGetGroups_REQ)/* parm string */ + +sizeof(RAP_GROUP_USERS_INFO_0) /* return string */ + +RAP_USERNAME_LEN /* user name */ + +WORDSIZE /* info level */ + +WORDSIZE]; /* buffer size */ + + /* now send a SMBtrans command with api GroupGetUsers */ + p = make_header(param, RAP_WUserGetGroups, + RAP_NetUserGetGroups_REQ, RAP_GROUP_USERS_INFO_0); + PUTSTRING(p,user_name,RAP_USERNAME_LEN-1); + PUTWORD(p,0); /* info level 0 */ + PUTWORD(p,0xFFE0); /* return buffer size */ + + if (cli_api(cli, + param, PTR_DIFF(p,param),PTR_DIFF(p,param), + NULL, 0, CLI_BUFFER_SIZE, + &rparam, &rprcnt, + &rdata, &rdrcnt)) { + res = GETRES(rparam); + cli->rap_error = res; + if (res != 0) { + DEBUG(1,("NetUserGetGroups gave error %d\n", res)); + } + } + if (rdata) { + if (res == 0 || res == ERRmoredata) { + int i, converter, count; + fstring groupname; + p = rparam +WORDSIZE; + GETWORD(p, converter); + GETWORD(p, count); + + for (i=0,p=rdata; irap_error = res; + if(cli->rap_error == 234) + DEBUG(1,("Not all service names were returned (such as those longer than 15 characters)\n")); + else if (cli->rap_error != 0) { + DEBUG(1,("NetServiceEnum gave error %d\n", cli->rap_error)); + } + } + + if (rdata) { + if (res == 0 || res == ERRmoredata) { + int i, converter, count; + + p = rparam + WORDSIZE; /* skip result */ + GETWORD(p, converter); + GETWORD(p, count); + + for (i=0,p=rdata;i