summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-09-25 23:14:20 +0000
committerLuke Leighton <lkcl@samba.org>1998-09-25 23:14:20 +0000
commit4b9e0941b9440d25d253dab62633858c2a5117c2 (patch)
tree4d95e5f9b683ad5ab43984472a0d75a900beb957
parentc1bbd1868f90b672ab88e53e039732854dca1f8d (diff)
downloadsamba-4b9e0941b9440d25d253dab62633858c2a5117c2.tar.gz
samba-4b9e0941b9440d25d253dab62633858c2a5117c2.tar.bz2
samba-4b9e0941b9440d25d253dab62633858c2a5117c2.zip
rpcclient: got samr command "enumusers -g -u" working
(This used to be commit 3a00023efedb34684bd45bd8a562f07a9880f1ad)
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/rpc_client/cli_samr.c38
-rw-r--r--source3/rpc_parse/parse_samr.c1
-rw-r--r--source3/rpcclient/cmd_samr.c7
4 files changed, 31 insertions, 17 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5c3dbc003b..91906eefea 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1228,7 +1228,7 @@ BOOL do_samr_unknown_8(struct cli_state *cli,
BOOL do_samr_enum_dom_users(struct cli_state *cli,
POLICY_HND *pol, uint16 num_entries, uint16 unk_0,
uint16 acb_mask, uint16 unk_1, uint32 size,
- struct acct_info sam[MAX_SAM_ENTRIES],
+ struct acct_info **sam,
int *num_sam_users);
BOOL do_samr_connect(struct cli_state *cli,
char *srv_name, uint32 unknown_0,
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 158270ca2e..ef20a999df 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -116,7 +116,7 @@ BOOL do_samr_unknown_8(struct cli_state *cli,
DEBUG(4,("SAMR Unknown 8 switch:%d\n", switch_value));
- if (domain_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
+ if (domain_pol == NULL) return False;
/* store the parameters */
make_samr_q_unknown_8(&q_e, domain_pol, switch_value);
@@ -161,7 +161,7 @@ do a SAMR enumerate users
BOOL do_samr_enum_dom_users(struct cli_state *cli,
POLICY_HND *pol, uint16 num_entries, uint16 unk_0,
uint16 acb_mask, uint16 unk_1, uint32 size,
- struct acct_info sam[MAX_SAM_ENTRIES],
+ struct acct_info **sam,
int *num_sam_users)
{
prs_struct data;
@@ -177,7 +177,7 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli,
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
- if (pol == NULL || sam == NULL || num_sam_users == NULL || cli->nt_pipe_fnum == 0xffff) return False;
+ if (pol == NULL || num_sam_users == NULL) return False;
/* store the parameters */
make_samr_q_enum_dom_users(&q_e, pol,
@@ -215,22 +215,31 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli,
DEBUG(2,("do_samr_enum_dom_users: sam user entries limited to %d\n",
*num_sam_users));
}
+
+ *sam = (struct acct_info*) malloc(sizeof(struct acct_info) * (*num_sam_users));
+
+ if ((*sam) == NULL)
+ {
+ *num_sam_users = 0;
+ }
+
for (i = 0; i < *num_sam_users; i++)
{
- sam[i].smb_userid = r_e.sam[i].rid;
+
+ (*sam)[i].smb_userid = r_e.sam[i].rid;
if (r_e.sam[i].hdr_name.buffer)
{
char *acct_name = unistrn2(r_e.uni_acct_name[name_idx].buffer,
r_e.uni_acct_name[name_idx].uni_str_len);
- fstrcpy(sam[i].acct_name, acct_name);
+ fstrcpy((*sam)[i].acct_name, acct_name);
name_idx++;
}
else
{
- bzero(sam[i].acct_name, sizeof(sam[i].acct_name));
+ bzero((*sam)[i].acct_name, sizeof((*sam)[i].acct_name));
}
DEBUG(5,("do_samr_enum_dom_users: idx: %4d rid: %8x acct: %s\n",
- i, sam[i].smb_userid, sam[i].acct_name));
+ i, (*sam)[i].smb_userid, (*sam)[i].acct_name));
}
valid_pol = True;
}
@@ -263,7 +272,7 @@ BOOL do_samr_connect(struct cli_state *cli,
DEBUG(4,("SAMR Open Policy server:%s undoc value:%x\n",
srv_name, unknown_0));
- if (srv_name == NULL || connect_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
+ if (srv_name == NULL || connect_pol == NULL) return False;
/* store the parameters */
make_samr_q_connect(&q_o, srv_name, unknown_0);
@@ -321,7 +330,7 @@ BOOL do_samr_open_user(struct cli_state *cli,
DEBUG(4,("SAMR Open User. unk_0: %08x RID:%x\n",
unk_0, rid));
- if (pol == NULL || user_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
+ if (pol == NULL || user_pol == NULL) return False;
/* store the parameters */
make_samr_q_open_user(&q_o, pol, unk_0, rid);
@@ -370,7 +379,7 @@ BOOL do_samr_open_domain(struct cli_state *cli,
prs_struct rdata;
SAMR_Q_OPEN_DOMAIN q_o;
- BOOL valid_pol = False;
+ BOOL valid_pol = False;
/* create and send a MSRPC command with api SAMR_OPEN_DOMAIN */
@@ -380,7 +389,7 @@ BOOL do_samr_open_domain(struct cli_state *cli,
sid_to_string(sid_str, sid);
DEBUG(4,("SAMR Open Domain. SID:%s RID:%x\n", sid_str, rid));
- if (connect_pol == NULL || sid == NULL || domain_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
+ if (connect_pol == NULL || sid == NULL || domain_pol == NULL) return False;
/* store the parameters */
make_samr_q_open_domain(&q_o, connect_pol, rid, sid);
@@ -440,8 +449,7 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli,
DEBUG(4,("SAMR Query Unknown 12.\n"));
if (pol == NULL || rid == 0 || num_gids == 0 || gids == NULL ||
- num_aliases == NULL || als_names == NULL || num_als_users == NULL ||
- cli->nt_pipe_fnum == 0xffff) return False;
+ num_aliases == NULL || als_names == NULL || num_als_users == NULL ) return False;
/* store the parameters */
make_samr_q_unknown_12(&q_o, pol, rid, num_gids, gids);
@@ -521,7 +529,7 @@ BOOL do_samr_query_usergroups(struct cli_state *cli,
DEBUG(4,("SAMR Query User Groups.\n"));
- if (pol == NULL || gid == NULL || num_groups == 0|| cli->nt_pipe_fnum == 0xffff) return False;
+ if (pol == NULL || gid == NULL || num_groups == 0) return False;
/* store the parameters */
make_samr_q_query_usergroups(&q_o, pol);
@@ -581,7 +589,7 @@ BOOL do_samr_query_userinfo(struct cli_state *cli,
DEBUG(4,("SAMR Query User Info. level: %d\n", switch_value));
- if (pol == NULL || usr == NULL || switch_value == 0|| cli->nt_pipe_fnum == 0xffff) return False;
+ if (pol == NULL || usr == NULL || switch_value == 0) return False;
/* store the parameters */
make_samr_q_query_userinfo(&q_o, pol, switch_value);
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 4454d74fe8..ab07e375f5 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -2167,6 +2167,7 @@ static void sam_io_user_info21(char *desc, SAM_USER_INFO_21 *usr, prs_struct *p
if (usr->ptr_logon_hrs)
{
sam_io_logon_hrs("logon_hrs", &(usr->logon_hrs) , ps, depth);
+ prs_align(ps);
}
}
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index f8710d548d..fd7f0e14ac 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -177,7 +177,7 @@ void cmd_sam_enum_users(struct client_info *info)
res = res ? do_samr_enum_dom_users(smb_cli,
&info->dom.samr_pol_open_domain,
num_entries, unk_0, acb_mask, unk_1, 0xffff,
- info->dom.sam, &info->dom.num_sam_entries) : False;
+ &info->dom.sam, &info->dom.num_sam_entries) : False;
if (res && info->dom.num_sam_entries == 0)
{
@@ -240,6 +240,11 @@ void cmd_sam_enum_users(struct client_info *info)
/* close the session */
cli_nt_session_close(smb_cli);
+ if (info->dom.sam != NULL)
+ {
+ free(info->dom.sam);
+ }
+
if (res)
{
DEBUG(5,("cmd_sam_enum_users: succeeded\n"));