summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-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;
}