summaryrefslogtreecommitdiff
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
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)
-rw-r--r--source3/libsmb/clirap2.c124
-rw-r--r--source3/utils/net_rap.c18
2 files changed, 135 insertions, 7 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
****************************************************************************/
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index 6e8f0d088d..8205fe3fda 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -589,9 +589,7 @@ static int net_rap_user_usage(int argc, const char **argv)
return net_help_user(argc, argv);
}
-static void user_fn(const char *user_name, const char *comment,
- const char * home_dir, const char * logon_script,
- void *state)
+static void user_fn(const char *user_name, void *state)
{
d_printf("%-21.21s\n", user_name);
}
@@ -696,7 +694,7 @@ int net_rap_user(int argc, const char **argv)
cli_shutdown(cli);
goto done;
}
- ret = cli_RNetUserEnum(cli, user_fn, NULL);
+ ret = cli_RNetUserEnum0(cli, user_fn, NULL);
cli_shutdown(cli);
goto done;
}
@@ -721,7 +719,7 @@ static void long_group_fn(const char *group_name, const char *comment,
d_printf("%-21.21s %s\n", group_name, comment);
}
-static void group_fn(const char *group_name, const char *comment, void *state)
+static void group_fn(const char *group_name, void *state)
{
d_printf("%-21.21s\n", group_name);
}
@@ -787,7 +785,7 @@ int net_rap_group(int argc, const char **argv)
cli_shutdown(cli);
return ret;
}
- ret = cli_RNetGroupEnum(cli, group_fn, NULL);
+ ret = cli_RNetGroupEnum0(cli, group_fn, NULL);
cli_shutdown(cli);
return ret;
}
@@ -912,6 +910,12 @@ static int rap_service_stop(int argc, const char **argv)
return errmsg_not_implemented();
}
+static void service_fn(const char *service_name, const char *dummy,
+ void *state)
+{
+ d_printf("%-21.21s\n", service_name);
+}
+
int net_rap_service(int argc, const char **argv)
{
struct functable func[] = {
@@ -931,7 +935,7 @@ int net_rap_service(int argc, const char **argv)
d_printf("-----------------------------\n");
ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
}
- ret = cli_RNetServiceEnum(cli, group_fn, NULL);
+ ret = cli_RNetServiceEnum(cli, service_fn, NULL);
cli_shutdown(cli);
return ret;
}