summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-25 16:22:08 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-25 16:22:08 +0000
commit8e1f542ddf97fef925a88e2c3d9c1e82fb2f6683 (patch)
treecb9e0bdd8f96a41cf6b460017a3772ea7e1dc5d3 /source3
parent45b794bdde0cb906216425c8fc2af8610aa8ad3c (diff)
downloadsamba-8e1f542ddf97fef925a88e2c3d9c1e82fb2f6683.tar.gz
samba-8e1f542ddf97fef925a88e2c3d9c1e82fb2f6683.tar.bz2
samba-8e1f542ddf97fef925a88e2c3d9c1e82fb2f6683.zip
one of those wonderful moments when running against a different MSRPC
implementation (NT5) when you discover that your code is trash. samr_enum_dom_users(), samr_enum_dom_aliases() and samr_enum_dom_groups() all take a HANDLE for multiple-call enumeration purposes. (This used to be commit 19490d8b4fb8a103f3df4e6104f6f22937b0c518)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/nterr.h2
-rw-r--r--source3/include/proto.h18
-rw-r--r--source3/include/rpc_samr.h12
-rw-r--r--source3/libsmb/clientgen.c18
-rw-r--r--source3/rpc_client/cli_netlogon.c4
-rw-r--r--source3/rpc_client/cli_samr.c55
-rw-r--r--source3/rpc_parse/parse_samr.c60
-rw-r--r--source3/rpc_server/srv_samr.c14
-rw-r--r--source3/rpcclient/cmd_samr.c27
-rw-r--r--source3/rpcclient/rpcclient.c2
10 files changed, 133 insertions, 79 deletions
diff --git a/source3/include/nterr.h b/source3/include/nterr.h
index 2b5285a41f..57d67527ba 100644
--- a/source3/include/nterr.h
+++ b/source3/include/nterr.h
@@ -505,5 +505,5 @@
#define NT_STATUS_QUOTA_LIST_INCONSISTENT (614)
#define NT_STATUS_FILE_IS_OFFLINE (615)
#define NT_STATUS_NOTIFY_ENUM_DIR (0x10C)
-#define NT_STATUS_MORE_ENTRIES (0x105)
+#define STATUS_MORE_ENTRIES (0x105)
#define NT_STATUS_NO_SUCH_JOB (0xEDE) /* scheduler */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7cbddd2084..872c9f6afb 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1897,15 +1897,17 @@ BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum,
POLICY_HND *domain_pol, uint16 switch_value,
SAM_UNK_CTR *ctr);
BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 size,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size,
struct acct_info **sam,
int *num_sam_groups);
BOOL samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 size,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size,
struct acct_info **sam,
int *num_sam_aliases);
-BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 start_idx,
+uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
+ POLICY_HND *pol, uint32 *start_idx,
uint16 acb_mask, uint16 unk_1, uint32 size,
struct acct_info **sam,
int *num_sam_users);
@@ -2592,15 +2594,19 @@ BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_s
BOOL make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
uint32 num_gids, DOM_GID *gid, uint32 status);
BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
-BOOL make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol, uint32 size);
+BOOL make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
+ uint32 start_idx, uint32 size);
BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth);
BOOL make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
+ uint32 next_idx,
uint32 num_sam_entries, DOMAIN_GRP *grps,
uint32 status);
BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth);
-BOOL make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
+BOOL make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol,
+ uint32 start_idx, uint32 size);
BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
BOOL make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
+ uint32 next_idx,
uint32 num_sam_entries, LOCAL_GRP *alss,
uint32 status);
BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index 0d55e40bc0..afe104a93a 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -637,7 +637,7 @@ typedef struct q_samr_enum_dom_groups_info
POLICY_HND pol; /* policy handle */
/* this is possibly an enumeration context handle... */
- uint32 unknown_0; /* 0x0000 0000 */
+ uint32 start_idx; /* 0x0000 0000 */
uint32 max_size; /* 0x0000 ffff */
@@ -647,8 +647,8 @@ typedef struct q_samr_enum_dom_groups_info
/* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
typedef struct r_samr_enum_dom_groups_info
{
- uint32 num_entries;
- uint32 ptr_entries;
+ uint32 next_idx;
+ uint32 ptr_entries1;
uint32 num_entries2;
uint32 ptr_entries2;
@@ -671,7 +671,7 @@ typedef struct q_samr_enum_dom_aliases_info
POLICY_HND pol; /* policy handle */
/* this is possibly an enumeration context handle... */
- uint32 unknown_0; /* 0x0000 0000 */
+ uint32 start_idx; /* 0x0000 0000 */
uint32 max_size; /* 0x0000 ffff */
@@ -681,8 +681,8 @@ typedef struct q_samr_enum_dom_aliases_info
/* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
typedef struct r_samr_enum_dom_aliases_info
{
- uint32 num_entries;
- uint32 ptr_entries;
+ uint32 next_idx;
+ uint32 ptr_entries1;
uint32 num_entries2;
uint32 ptr_entries2;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 90ea3d12bf..d792eeeaa1 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -255,10 +255,10 @@ static void cli_setup_packet(struct cli_state *cli)
uint16 flgs2 = 0;
flgs2 |= FLAGS2_LONG_PATH_COMPONENTS;
flgs2 |= FLAGS2_32_BIT_ERROR_CODES;
+ flgs2 |= FLAGS2_EXT_SEC;
#if 0
flgs2 |= FLAGS2_UNICODE_STRINGS;
#endif
- flgs2 |= FLAGS2_EXT_SEC;
cli->rap_error = 0;
cli->nt_error = 0;
@@ -750,8 +750,6 @@ prots[] =
{PROTOCOL_LANMAN2,"Samba"},
{PROTOCOL_NT1,"NT LANMAN 1.0"},
{PROTOCOL_NT1,"NT LM 0.12"},
-#if 0
-#endif
{-1,NULL}
};
@@ -842,7 +840,7 @@ BOOL cli_session_setup_x(struct cli_state *cli,
SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
SSVAL(cli->outbuf,smb_vwv7,passlen);
SSVAL(cli->outbuf,smb_vwv8,ntpasslen);
- SSVAL(cli->outbuf,smb_vwv11,0);
+ SIVAL(cli->outbuf,smb_vwv11, CAP_STATUS32);
p = smb_buf(cli->outbuf);
memcpy(p,pass,passlen);
p += SVAL(cli->outbuf,smb_vwv7);
@@ -3091,7 +3089,17 @@ BOOL cli_establish_connection(struct cli_state *cli,
#endif
prs_init(&auth_resp, 1024, 4, SAFETY_MARGIN, False);
- pwd_make_lm_nt_owf(&cli->pwd, cli->cryptkey);
+ if (cli->use_ntlmv2 != False)
+ {
+ DEBUG(10,("cli_establish_connection: NTLMv2\n"));
+ pwd_make_lm_nt_owf2(&(cli->pwd), cli->cryptkey,
+ cli->user_name, calling->name, cli->domain);
+ }
+ else
+ {
+ DEBUG(10,("cli_establish_connection: NTLMv1\n"));
+ pwd_make_lm_nt_owf(&(cli->pwd), cli->cryptkey);
+ }
create_ntlmssp_resp(&cli->pwd, cli->domain,
cli->user_name, cli->calling.name,
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index e5b028f987..a91a448994 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -522,7 +522,7 @@ BOOL cli_net_sam_sync(struct cli_state *cli, uint16 nt_pipe_fnum, uint32 databas
net_io_r_sam_sync("", cli->sess_key, &r_s, &rbuf, 0);
ok = (rbuf.offset != 0);
- if (ok && r_s.status != 0 && r_s.status != NT_STATUS_MORE_ENTRIES)
+ if (ok && r_s.status != 0 && r_s.status != STATUS_MORE_ENTRIES)
{
/* report error code */
DEBUG(5,("cli_net_sam_sync: %s\n", get_nt_error_msg(r_s.status)));
@@ -541,7 +541,7 @@ BOOL cli_net_sam_sync(struct cli_state *cli, uint16 nt_pipe_fnum, uint32 databas
{
*num_deltas = r_s.num_deltas2;
- if (r_s.status == NT_STATUS_MORE_ENTRIES)
+ if (r_s.status == STATUS_MORE_ENTRIES)
{
DEBUG(5, ("(More entries)\n"));
}
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 8e051d4f98..d3f4f3c052 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -547,7 +547,8 @@ BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum,
do a SAMR enumerate groups
****************************************************************************/
BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 size,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size,
struct acct_info **sam,
int *num_sam_groups)
{
@@ -567,7 +568,7 @@ BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
/* store the parameters */
- make_samr_q_enum_dom_groups(&q_e, pol, size);
+ make_samr_q_enum_dom_groups(&q_e, pol, start_idx, size);
/* turn parameters into data stream */
samr_io_q_enum_dom_groups("", &q_e, &data, 0);
@@ -635,7 +636,8 @@ BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
do a SAMR enumerate aliases
****************************************************************************/
BOOL samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 size,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size,
struct acct_info **sam,
int *num_sam_aliases)
{
@@ -655,7 +657,7 @@ BOOL samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum,
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
/* store the parameters */
- make_samr_q_enum_dom_aliases(&q_e, pol, size);
+ make_samr_q_enum_dom_aliases(&q_e, pol, start_idx, size);
/* turn parameters into data stream */
samr_io_q_enum_dom_aliases("", &q_e, &data, 0);
@@ -722,12 +724,13 @@ BOOL samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a SAMR enumerate users
****************************************************************************/
-BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, uint32 start_idx,
+uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
+ POLICY_HND *pol, uint32 *start_idx,
uint16 acb_mask, uint16 unk_1, uint32 size,
struct acct_info **sam,
int *num_sam_users)
{
+ uint32 status = 0x0;
prs_struct data;
prs_struct rdata;
@@ -736,7 +739,10 @@ BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
- if (pol == NULL || num_sam_users == NULL) return False;
+ if (pol == NULL || num_sam_users == NULL)
+ {
+ return NT_STATUS_INVALID_PARAMETER | 0xC0000000;
+ }
/* create and send a MSRPC command with api SAMR_ENUM_DOM_USERS */
@@ -744,7 +750,8 @@ BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
/* store the parameters */
- make_samr_q_enum_dom_users(&q_e, pol, start_idx, acb_mask, unk_1, size);
+ make_samr_q_enum_dom_users(&q_e, pol, *start_idx,
+ acb_mask, unk_1, size);
/* turn parameters into data stream */
samr_io_q_enum_dom_users("", &q_e, &data, 0);
@@ -757,33 +764,38 @@ BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
samr_io_r_enum_dom_users("", &r_e, &rdata, 0);
+ status = r_e.status;
p = rdata.offset != 0;
+
if (p && r_e.status != 0)
{
/* report error code */
DEBUG(4,("SAMR_R_ENUM_DOM_USERS: %s\n", get_nt_error_msg(r_e.status)));
- p = False;
+ p = (r_e.status == STATUS_MORE_ENTRIES);
}
if (p)
{
- int i;
+ int i = (*num_sam_users);
+ int j = 0;
int name_idx = 0;
- *num_sam_users = r_e.num_entries2;
- *sam = (struct acct_info*) malloc(sizeof(struct acct_info) * (*num_sam_users));
+ (*num_sam_users) += r_e.num_entries2;
+ (*sam) = (struct acct_info*) Realloc((*sam),
+ sizeof(struct acct_info) * (*num_sam_users));
if ((*sam) == NULL)
{
- *num_sam_users = 0;
+ (*num_sam_users) = 0;
+ i = 0;
}
- for (i = 0; i < *num_sam_users; i++)
+ for (j = 0; i < (*num_sam_users) && j < r_e.num_entries2; j++, i++)
{
- (*sam)[i].rid = r_e.sam[i].rid;
+ (*sam)[i].rid = r_e.sam[j].rid;
(*sam)[i].acct_name[0] = 0;
(*sam)[i].acct_desc[0] = 0;
- if (r_e.sam[i].hdr_name.buffer)
+ if (r_e.sam[j].hdr_name.buffer)
{
unistr2_to_ascii((*sam)[i].acct_name, &r_e.uni_acct_name[name_idx], sizeof((*sam)[i].acct_name)-1);
name_idx++;
@@ -792,6 +804,11 @@ BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
i, (*sam)[i].rid, (*sam)[i].acct_name));
}
valid_pol = True;
+ (*start_idx) = r_e.next_idx;
+ }
+ else if (status == 0x0)
+ {
+ status = NT_STATUS_INVALID_PARAMETER | 0xC0000000;
}
if (r_e.sam != NULL)
@@ -803,11 +820,15 @@ BOOL samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
free(r_e.uni_acct_name);
}
}
+ else
+ {
+ status = NT_STATUS_ACCESS_DENIED | 0xC0000000;
+ }
prs_mem_free(&data );
prs_mem_free(&rdata );
- return valid_pol;
+ return status;
}
/****************************************************************************
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 69c7599a98..073e0c7577 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -2757,7 +2757,8 @@ BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_s
/*******************************************************************
makes a SAMR_Q_ENUM_DOM_GROUPS structure.
********************************************************************/
-BOOL make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol, uint32 size)
+BOOL make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
+ uint32 start_idx, uint32 size)
{
if (q_e == NULL || pol == NULL) return False;
@@ -2765,7 +2766,7 @@ BOOL make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol, u
memcpy(&(q_e->pol), pol, sizeof(*pol));
- q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
q_e->max_size = size;
return True;
@@ -2787,7 +2788,7 @@ BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_stru
smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
prs_align(ps);
- prs_uint32("unknown_0", ps, depth, &(q_e->unknown_0));
+ prs_uint32("start_idx", ps, depth, &(q_e->start_idx));
prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
prs_align(ps);
@@ -2800,6 +2801,7 @@ BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_stru
makes a SAMR_R_ENUM_DOM_GROUPS structure.
********************************************************************/
BOOL make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
+ uint32 next_idx,
uint32 num_sam_entries, DOMAIN_GRP *grps,
uint32 status)
{
@@ -2816,12 +2818,12 @@ BOOL make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
num_sam_entries));
}
- r_u->num_entries = num_sam_entries;
+ r_u->next_idx = next_idx;
+ r_u->ptr_entries1 = 1;
+ r_u->num_entries2 = num_sam_entries;
if (num_sam_entries > 0)
{
- r_u->ptr_entries = 1;
- r_u->num_entries2 = num_sam_entries;
r_u->ptr_entries2 = 1;
r_u->num_entries3 = num_sam_entries;
@@ -2842,7 +2844,7 @@ BOOL make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
}
else
{
- r_u->ptr_entries = 0;
+ r_u->num_entries4 = 0;
}
r_u->status = status;
@@ -2864,23 +2866,23 @@ BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_stru
prs_align(ps);
- prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
- prs_uint32("ptr_entries", ps, depth, &(r_u->ptr_entries));
+ prs_uint32("next_idx ", ps, depth, &(r_u->next_idx ));
+ prs_uint32("ptr_entries1", ps, depth, &(r_u->ptr_entries1));
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
- if (r_u->num_entries != 0 && r_u->ptr_entries != 0)
+ if (r_u->num_entries2 != 0 && r_u->ptr_entries1 != 0)
{
- prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
- SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
+ SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries2);
- for (i = 0; i < r_u->num_entries; i++)
+ for (i = 0; i < r_u->num_entries2; i++)
{
sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
}
- for (i = 0; i < r_u->num_entries; i++)
+ for (i = 0; i < r_u->num_entries2; i++)
{
smb_io_unistr2("", &(r_u->uni_grp_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
}
@@ -2898,7 +2900,8 @@ BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_stru
/*******************************************************************
makes a SAMR_Q_ENUM_DOM_ALIASES structure.
********************************************************************/
-BOOL make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size)
+BOOL make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol,
+ uint32 start_idx, uint32 size)
{
if (q_e == NULL || pol == NULL) return False;
@@ -2906,7 +2909,7 @@ BOOL make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol,
memcpy(&(q_e->pol), pol, sizeof(*pol));
- q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
q_e->max_size = size;
return True;
@@ -2928,7 +2931,7 @@ BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_s
smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
prs_align(ps);
- prs_uint32("unknown_0", ps, depth, &(q_e->unknown_0));
+ prs_uint32("start_idx", ps, depth, &(q_e->start_idx));
prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
prs_align(ps);
@@ -2941,6 +2944,7 @@ BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_s
makes a SAMR_R_ENUM_DOM_ALIASES structure.
********************************************************************/
BOOL make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
+ uint32 next_idx,
uint32 num_sam_entries, LOCAL_GRP *alss,
uint32 status)
{
@@ -2957,12 +2961,12 @@ BOOL make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
num_sam_entries));
}
- r_u->num_entries = num_sam_entries;
+ r_u->next_idx = next_idx;
+ r_u->ptr_entries1 = 1;
+ r_u->num_entries2 = num_sam_entries;
if (num_sam_entries > 0)
{
- r_u->ptr_entries = 1;
- r_u->num_entries2 = num_sam_entries;
r_u->ptr_entries2 = 1;
r_u->num_entries3 = num_sam_entries;
@@ -2983,7 +2987,7 @@ BOOL make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
}
else
{
- r_u->ptr_entries = 0;
+ r_u->num_entries4 = 0;
}
r_u->status = status;
@@ -3005,23 +3009,23 @@ BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_s
prs_align(ps);
- prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
- prs_uint32("ptr_entries", ps, depth, &(r_u->ptr_entries));
+ prs_uint32("next_idx ", ps, depth, &(r_u->next_idx ));
+ prs_uint32("ptr_entries1", ps, depth, &(r_u->ptr_entries1));
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
- if (r_u->num_entries != 0 && r_u->ptr_entries != 0)
+ if (r_u->num_entries2 != 0 && r_u->ptr_entries1 != 0)
{
- prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
- SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries);
+ SMB_ASSERT_ARRAY(r_u->sam, r_u->num_entries2);
- for (i = 0; i < r_u->num_entries; i++)
+ for (i = 0; i < r_u->num_entries2; i++)
{
sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
}
- for (i = 0; i < r_u->num_entries; i++)
+ for (i = 0; i < r_u->num_entries2; i++)
{
smb_io_unistr2("", &(r_u->uni_grp_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
}
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index b1ee0cfe31..bfbeb5718c 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -639,7 +639,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u,
fstring sid_str;
r_e.status = 0x0;
- r_e.num_entries = 0;
+ r_e.num_entries2 = 0;
/* find the policy handle. open a policy on it. */
if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid))
@@ -666,7 +666,9 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u,
if (r_e.status == 0x0)
{
- make_samr_r_enum_dom_groups(&r_e, num_entries, grps, r_e.status);
+ make_samr_r_enum_dom_groups(&r_e,
+ q_u->start_idx + num_entries,
+ num_entries, grps, r_e.status);
}
/* store the response in the SMB stream */
@@ -708,7 +710,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u,
fstring sid_str;
r_e.status = 0x0;
- r_e.num_entries = 0;
+ r_e.num_entries2 = 0;
/* find the policy handle. open a policy on it. */
if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid))
@@ -750,7 +752,9 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u,
if (r_e.status == 0x0)
{
- make_samr_r_enum_dom_aliases(&r_e, num_entries, alss, r_e.status);
+ make_samr_r_enum_dom_aliases(&r_e,
+ q_u->start_idx + num_entries,
+ num_entries, alss, r_e.status);
}
/* store the response in the SMB stream */
@@ -914,7 +918,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u,
if ((status == 0) && (num_entries < num_sam_entries))
{
- status = NT_STATUS_MORE_ENTRIES;
+ status = STATUS_MORE_ENTRIES;
}
make_samr_r_query_dispinfo(&r_e, num_entries, data_size,
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 66b10319ed..ea44db0205 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1365,11 +1365,12 @@ int msrpc_sam_enum_users(struct client_info *info,
int user_idx;
BOOL res = True;
BOOL res1 = True;
- uint16 start_idx = 0x0;
+ uint32 start_idx = 0x0;
uint16 unk_0 = 0x0;
uint16 acb_mask = 0;
uint16 unk_1 = 0x0;
uint32 ace_perms = 0x304; /* access control permissions */
+ uint32 status = STATUS_MORE_ENTRIES;
sid_copy(&sid1, &info->dom.level5_sid);
sid_to_string(sid, &sid1);
@@ -1407,27 +1408,33 @@ int msrpc_sam_enum_users(struct client_info *info,
&info->dom.samr_pol_connect) : False;
/* connect to the domain */
- res = res ? samr_open_domain(smb_cli, fnum,
+ res1 = res ? samr_open_domain(smb_cli, fnum,
&info->dom.samr_pol_connect, ace_perms, &sid1,
&info->dom.samr_pol_open_domain) : False;
+#if 0
/* connect to the S-1-5-20 domain */
res1 = res ? samr_open_domain(smb_cli, fnum,
&info->dom.samr_pol_connect, ace_perms, &sid_1_5_20,
&info->dom.samr_pol_open_builtindom) : False;
+#endif
/* read some users */
- res = res ? samr_enum_dom_users(smb_cli, fnum,
+ while (res1 && status == STATUS_MORE_ENTRIES)
+ {
+ status = samr_enum_dom_users(smb_cli, fnum,
&info->dom.samr_pol_open_domain,
- start_idx, acb_mask, unk_1, 0xf0000000,
- &info->dom.sam, &info->dom.num_sam_entries) : False;
+ &start_idx, acb_mask, unk_1, 0x01,
+ &info->dom.sam, &info->dom.num_sam_entries);
+ }
+
- if (res && info->dom.num_sam_entries == 0)
+ if (res1 && info->dom.num_sam_entries == 0)
{
report(out_hnd, "No users\n");
}
- if (res)
+ if (res1)
{
/* query all the users */
for (user_idx = 0; res && user_idx <
@@ -1456,8 +1463,10 @@ int msrpc_sam_enum_users(struct client_info *info,
}
}
+#if 0
res1 = res1 ? samr_close(smb_cli, fnum,
&info->dom.samr_pol_open_builtindom) : False;
+#endif
res = res ? samr_close(smb_cli, fnum,
&info->dom.samr_pol_open_domain) : False;
@@ -1864,7 +1873,7 @@ void cmd_sam_enum_aliases(struct client_info *info)
/* read some aliases */
res = res ? samr_enum_dom_aliases(smb_cli, fnum,
&info->dom.samr_pol_open_domain,
- 0xffff,
+ 0x0, 0xffff,
&info->dom.sam, &info->dom.num_sam_entries) : False;
if (res && info->dom.num_sam_entries == 0)
@@ -2087,7 +2096,7 @@ void cmd_sam_enum_groups(struct client_info *info)
/* read some groups */
res = res ? samr_enum_dom_groups(smb_cli, fnum,
&info->dom.samr_pol_open_domain,
- 0xffff,
+ 0x0, 0x03,
&info->dom.sam, &info->dom.num_sam_entries) : False;
if (res && info->dom.num_sam_entries == 0)
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 84504b16fb..9c6c99927f 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -885,6 +885,8 @@ char *complete_cmd_null(char *text, int state)
/* establish connections. nothing to stop these being re-established. */
rpcclient_connect(&cli_info);
+ smb_cli->ntlmssp_cli_flgs = 0x0;
+
DEBUG(5,("rpcclient_connect: smb_cli->fd:%d\n", smb_cli->fd));
if (smb_cli->fd <= 0)
{