summaryrefslogtreecommitdiff
path: root/source3/libsmb/clirap2.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-04-10 14:44:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:34 -0500
commit1875e46d05c21f4ca0e1163ecfd41b470dbce09a (patch)
tree6b1c622b9c580ebdcc7f89e51b9276c7492e4359 /source3/libsmb/clirap2.c
parent31b806b5df0f2aeb7776c6b964a3b7e9acacf611 (diff)
downloadsamba-1875e46d05c21f4ca0e1163ecfd41b470dbce09a.tar.gz
samba-1875e46d05c21f4ca0e1163ecfd41b470dbce09a.tar.bz2
samba-1875e46d05c21f4ca0e1163ecfd41b470dbce09a.zip
r6275: Implement RAP version of enumusers/enumgroups level 0. No, I've not gone mad,
this is to test future changes to enumeration functions... This can successfully list users from nt4 and w2k3sp1. Volker (This used to be commit c73f2656fd89e227a8a3e2ab20f7393ff2c515c7)
Diffstat (limited to 'source3/libsmb/clirap2.c')
-rw-r--r--source3/libsmb/clirap2.c124
1 files changed, 124 insertions, 0 deletions
diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c
index 12a3d63aff..d8a8519550 100644
--- a/source3/libsmb/clirap2.c
+++ b/source3/libsmb/clirap2.c
@@ -329,6 +329,70 @@ int cli_RNetGroupEnum(struct cli_state *cli, void (*fn)(const char *, const char
return res;
}
+int cli_RNetGroupEnum0(struct cli_state *cli,
+ void (*fn)(const char *, void *),
+ void *state)
+{
+ char param[WORDSIZE /* api number */
+ +sizeof(RAP_NetGroupEnum_REQ) /* parm string */
+ +sizeof(RAP_GROUP_INFO_L0) /* return string */
+ +WORDSIZE /* info level */
+ +WORDSIZE]; /* buffer size */
+ char *p;
+ char *rparam = NULL;
+ char *rdata = NULL;
+ unsigned int rprcnt, rdrcnt;
+ int res = -1;
+
+
+ memset(param, '\0', sizeof(param));
+ p = make_header(param, RAP_WGroupEnum,
+ RAP_NetGroupEnum_REQ, RAP_GROUP_INFO_L0);
+ PUTWORD(p,0); /* Info level 0 */ /* Hmmm. I *very* much suspect this
+ is the resume count, at least
+ that's what smbd believes... */
+ PUTWORD(p,0xFFE0); /* Return buffer size */
+
+ if (cli_api(cli,
+ param, PTR_DIFF(p,param),8,
+ NULL, 0, 0xFFE0 /* data area size */,
+ &rparam, &rprcnt,
+ &rdata, &rdrcnt)) {
+ res = GETRES(rparam);
+ cli->rap_error = res;
+ if(cli->rap_error == 234)
+ DEBUG(1,("Not all group names were returned (such as those longer than 21 characters)\n"));
+ else if (cli->rap_error != 0) {
+ DEBUG(1,("NetGroupEnum 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<count;i++) {
+ char groupname[RAP_GROUPNAME_LEN];
+ GETSTRINGF(p, groupname, RAP_GROUPNAME_LEN);
+ fn(groupname, cli);
+ }
+ } else {
+ DEBUG(4,("NetGroupEnum res=%d\n", res));
+ }
+ } else {
+ DEBUG(4,("NetGroupEnum no data returned\n"));
+ }
+
+ SAFE_FREE(rparam);
+ SAFE_FREE(rdata);
+
+ return res;
+}
+
int cli_NetGroupDelUser(struct cli_state * cli, const char *group_name, const char *user_name)
{
char *rparam = NULL;
@@ -768,6 +832,66 @@ int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char
return res;
}
+int cli_RNetUserEnum0(struct cli_state *cli,
+ void (*fn)(const char *, void *),
+ void *state)
+{
+ char param[WORDSIZE /* api number */
+ +sizeof(RAP_NetUserEnum_REQ) /* parm string */
+ +sizeof(RAP_USER_INFO_L0) /* return string */
+ +WORDSIZE /* info level */
+ +WORDSIZE]; /* buffer size */
+ char *p;
+ char *rparam = NULL;
+ char *rdata = NULL;
+ unsigned int rprcnt, rdrcnt;
+ int res = -1;
+
+
+ memset(param, '\0', sizeof(param));
+ p = make_header(param, RAP_WUserEnum,
+ RAP_NetUserEnum_REQ, RAP_USER_INFO_L0);
+ PUTWORD(p,0); /* Info level 1 */
+ PUTWORD(p,0xFF00); /* Return buffer size */
+
+/* BB Fix handling of large numbers of users to be returned */
+ if (cli_api(cli,
+ param, PTR_DIFF(p,param),8,
+ NULL, 0, CLI_BUFFER_SIZE,
+ &rparam, &rprcnt,
+ &rdata, &rdrcnt)) {
+ res = GETRES(rparam);
+ cli->rap_error = res;
+ if (cli->rap_error != 0) {
+ DEBUG(1,("NetUserEnum gave error %d\n", cli->rap_error));
+ }
+ }
+ if (rdata) {
+ if (res == 0 || res == ERRmoredata) {
+ int i, converter, count;
+ char username[RAP_USERNAME_LEN];
+
+ p = rparam + WORDSIZE; /* skip result */
+ GETWORD(p, converter);
+ GETWORD(p, count);
+
+ for (i=0,p=rdata;i<count;i++) {
+ GETSTRINGF(p, username, RAP_USERNAME_LEN);
+ fn(username, cli);
+ }
+ } else {
+ DEBUG(4,("NetUserEnum res=%d\n", res));
+ }
+ } else {
+ DEBUG(4,("NetUserEnum no data returned\n"));
+ }
+
+ SAFE_FREE(rparam);
+ SAFE_FREE(rdata);
+
+ return res;
+}
+
/****************************************************************************
call a NetFileClose2 - close open file on another session to server
****************************************************************************/