1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

Use pidl for _samr_QueryDisplayInfo().

Guenther
(This used to be commit b6d1283121)
This commit is contained in:
Günther Deschner 2008-02-07 17:57:20 +01:00
parent ca790c96d2
commit f27a5561aa
3 changed files with 151 additions and 191 deletions

View File

@ -41,6 +41,15 @@ static void init_lsa_String(struct lsa_String *name, const char *s)
inits a structure.
********************************************************************/
static void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s)
{
name->string = s;
}
/*******************************************************************
inits a structure.
********************************************************************/
void init_samr_DomInfo1(struct samr_DomInfo1 *r,
uint16_t min_password_length,
uint16_t password_history_length,
@ -705,45 +714,44 @@ bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
}
/*******************************************************************
inits a SAM_DISPINFO_1 structure.
inits a samr_DispInfoGeneral structure.
********************************************************************/
NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
uint32 num_entries, uint32 start_idx,
NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx,
struct samr_DispInfoGeneral *r,
uint32_t num_entries,
uint32_t start_idx,
struct samr_displayentry *entries)
{
uint32 i;
DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
if (num_entries==0)
if (num_entries == 0) {
return NT_STATUS_OK;
}
*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
if (*sam == NULL)
return NT_STATUS_NO_MEMORY;
r->count = num_entries;
(*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
if ((*sam)->sam == NULL)
return NT_STATUS_NO_MEMORY;
(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
if ((*sam)->str == NULL)
r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryGeneral, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
for (i = 0; i < num_entries ; i++) {
init_unistr2(&(*sam)->str[i].uni_acct_name,
entries[i].account_name, UNI_FLAGS_NONE);
init_unistr2(&(*sam)->str[i].uni_full_name,
entries[i].fullname, UNI_FLAGS_NONE);
init_unistr2(&(*sam)->str[i].uni_acct_desc,
entries[i].description, UNI_FLAGS_NONE);
init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
&(*sam)->str[i].uni_acct_name,
&(*sam)->str[i].uni_full_name,
&(*sam)->str[i].uni_acct_desc,
entries[i].rid, entries[i].acct_flags);
init_lsa_String(&r->entries[i].account_name,
entries[i].account_name);
init_lsa_String(&r->entries[i].description,
entries[i].description);
init_lsa_String(&r->entries[i].full_name,
entries[i].fullname);
r->entries[i].rid = entries[i].rid;
r->entries[i].acct_flags = entries[i].acct_flags;
r->entries[i].idx = start_idx+i+1;
}
return NT_STATUS_OK;
@ -795,42 +803,41 @@ static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
}
/*******************************************************************
inits a SAM_DISPINFO_2 structure.
inits a samr_DispInfoFull structure.
********************************************************************/
NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
uint32 num_entries, uint32 start_idx,
NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx,
struct samr_DispInfoFull *r,
uint32_t num_entries,
uint32_t start_idx,
struct samr_displayentry *entries)
{
uint32 i;
uint32_t i;
DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
if (num_entries==0)
if (num_entries == 0) {
return NT_STATUS_OK;
}
*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
if (*sam == NULL)
r->count = num_entries;
r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFull, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
(*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
if ((*sam)->sam == NULL)
return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_entries ; i++) {
(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
if ((*sam)->str == NULL)
return NT_STATUS_NO_MEMORY;
init_lsa_String(&r->entries[i].account_name,
entries[i].account_name);
for (i = 0; i < num_entries; i++) {
init_unistr2(&(*sam)->str[i].uni_srv_name,
entries[i].account_name, UNI_FLAGS_NONE);
init_unistr2(&(*sam)->str[i].uni_srv_desc,
entries[i].description, UNI_FLAGS_NONE);
init_lsa_String(&r->entries[i].description,
entries[i].description);
init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
&(*sam)->str[i].uni_srv_name,
&(*sam)->str[i].uni_srv_desc,
entries[i].rid, entries[i].acct_flags);
r->entries[i].rid = entries[i].rid;
r->entries[i].acct_flags = entries[i].acct_flags;
r->entries[i].idx = start_idx+i+1;
}
return NT_STATUS_OK;
@ -884,42 +891,41 @@ static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
}
/*******************************************************************
inits a SAM_DISPINFO_3 structure.
inits a samr_DispInfoFullGroups structure.
********************************************************************/
NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
uint32 num_entries, uint32 start_idx,
NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx,
struct samr_DispInfoFullGroups *r,
uint32_t num_entries,
uint32_t start_idx,
struct samr_displayentry *entries)
{
uint32 i;
uint32_t i;
DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
if (num_entries==0)
if (num_entries == 0) {
return NT_STATUS_OK;
}
*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
if (*sam == NULL)
r->count = num_entries;
r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFullGroup, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_entries ; i++) {
if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
return NT_STATUS_NO_MEMORY;
init_lsa_String(&r->entries[i].account_name,
entries[i].account_name);
for (i = 0; i < num_entries; i++) {
DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
init_lsa_String(&r->entries[i].description,
entries[i].description);
init_unistr2(&(*sam)->str[i].uni_grp_name,
entries[i].account_name, UNI_FLAGS_NONE);
init_unistr2(&(*sam)->str[i].uni_grp_desc,
entries[i].description, UNI_FLAGS_NONE);
init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
&(*sam)->str[i].uni_grp_name,
&(*sam)->str[i].uni_grp_desc,
entries[i].rid);
r->entries[i].rid = entries[i].rid;
r->entries[i].acct_flags = entries[i].acct_flags;
r->entries[i].idx = start_idx+i+1;
}
return NT_STATUS_OK;
@ -973,45 +979,38 @@ static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
}
/*******************************************************************
inits a SAM_DISPINFO_4 structure.
inits a samr_DispInfoAscii structure.
********************************************************************/
NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
uint32 num_entries, uint32 start_idx,
NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx,
struct samr_DispInfoAscii *r,
uint32_t num_entries,
uint32_t start_idx,
struct samr_displayentry *entries)
{
uint32 i;
uint32_t i;
DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
if (num_entries==0)
if (num_entries == 0) {
return NT_STATUS_OK;
*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
if (*sam == NULL)
return NT_STATUS_NO_MEMORY;
(*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
if ((*sam)->sam == NULL)
return NT_STATUS_NO_MEMORY;
(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
if ((*sam)->str == NULL)
return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_entries; i++) {
size_t len_sam_name = strlen(entries[i].account_name);
DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
len_sam_name);
init_string2(&(*sam)->str[i].acct_name,
entries[i].account_name, len_sam_name+1,
len_sam_name);
}
r->count = num_entries;
r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
for (i = 0; i < num_entries ; i++) {
init_lsa_AsciiString(&r->entries[i].account_name,
entries[i].account_name);
r->entries[i].idx = start_idx+i+1;
}
return NT_STATUS_OK;
}
@ -1062,39 +1061,36 @@ static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
}
/*******************************************************************
inits a SAM_DISPINFO_5 structure.
inits a samr_DispInfoAscii structure.
********************************************************************/
NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
uint32 num_entries, uint32 start_idx,
NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx,
struct samr_DispInfoAscii *r,
uint32_t num_entries,
uint32_t start_idx,
struct samr_displayentry *entries)
{
uint32 len_sam_name;
uint32 i;
uint32_t i;
DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
if (num_entries==0)
if (num_entries == 0) {
return NT_STATUS_OK;
}
*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
if (*sam == NULL)
r->count = num_entries;
r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_entries ; i++) {
if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
return NT_STATUS_NO_MEMORY;
init_lsa_AsciiString(&r->entries[i].account_name,
entries[i].account_name);
for (i = 0; i < num_entries; i++) {
DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
len_sam_name = strlen(entries[i].account_name);
init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
len_sam_name+1, len_sam_name);
r->entries[i].idx = start_idx+i+1;
}
return NT_STATUS_OK;

View File

@ -200,28 +200,7 @@ static bool api_samr_enum_dom_aliases(pipes_struct *p)
static bool api_samr_query_dispinfo(pipes_struct *p)
{
SAMR_Q_QUERY_DISPINFO q_u;
SAMR_R_QUERY_DISPINFO r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!samr_io_q_query_dispinfo("", &q_u, data, 0)) {
DEBUG(0,("api_samr_query_dispinfo: unable to unmarshall SAMR_Q_QUERY_DISPINFO.\n"));
return False;
}
r_u.status = _samr_query_dispinfo(p, &q_u, &r_u);
/* store the response in the SMB stream */
if(!samr_io_r_query_dispinfo("", &r_u, rdata, 0)) {
DEBUG(0,("api_samr_query_dispinfo: unable to marshall SAMR_R_QUERY_DISPINFO.\n"));
return False;
}
return True;
return proxy_samr_call(p, NDR_SAMR_QUERYDISPLAYINFO);
}
/*******************************************************************

View File

@ -1128,20 +1128,22 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S
}
/*******************************************************************
samr_reply_query_dispinfo
_samr_QueryDisplayInfo
********************************************************************/
NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
SAMR_R_QUERY_DISPINFO *r_u)
NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p,
struct samr_QueryDisplayInfo *r)
{
NTSTATUS status;
struct samr_info *info = NULL;
uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */
uint32 max_entries=q_u->max_entries;
uint32 enum_context=q_u->start_idx;
uint32 max_size=q_u->max_size;
uint32 max_entries = r->in.max_entries;
uint32 enum_context = r->in.start_idx;
uint32 max_size = r->in.buf_size;
union samr_DispInfo *disp_info = r->out.info;
SAM_DISPINFO_CTR *ctr;
uint32 temp_size=0, total_data_size=0;
NTSTATUS disp_ret = NT_STATUS_UNSUCCESSFUL;
uint32 num_account = 0;
@ -1149,11 +1151,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K;
struct samr_displayentry *entries = NULL;
DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__));
r_u->status = NT_STATUS_UNSUCCESSFUL;
DEBUG(5,("_samr_QueryDisplayInfo: %d\n", __LINE__));
/* find the policy handle. open a policy on it. */
if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info))
if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
/*
@ -1184,15 +1185,15 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
* JFM, 12/20/2001
*/
if ((q_u->switch_level < 1) || (q_u->switch_level > 5)) {
DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n",
(unsigned int)q_u->switch_level ));
if ((r->in.level < 1) || (r->in.level > 5)) {
DEBUG(0,("_samr_QueryDisplayInfo: Unknown info level (%u)\n",
(unsigned int)r->in.level ));
return NT_STATUS_INVALID_INFO_CLASS;
}
/* first limit the number of entries we will return */
if(max_entries > max_sam_entries) {
DEBUG(5, ("samr_reply_query_dispinfo: client requested %d "
DEBUG(5, ("_samr_QueryDisplayInfo: client requested %d "
"entries, limiting to %d\n", max_entries,
max_sam_entries));
max_entries = max_sam_entries;
@ -1205,20 +1206,15 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
if (temp_size>max_size) {
max_entries=MIN((max_size/struct_size),max_entries);;
DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to "
DEBUG(5, ("_samr_QueryDisplayInfo: buffer size limits to "
"only %d entries\n", max_entries));
}
if (!(ctr = TALLOC_ZERO_P(p->mem_ctx,SAM_DISPINFO_CTR)))
return NT_STATUS_NO_MEMORY;
ZERO_STRUCTP(ctr);
become_root();
/* THe following done as ROOT. Don't return without unbecome_root(). */
switch (q_u->switch_level) {
switch (r->in.level) {
case 0x1:
case 0x4:
if (info->disp_info->users == NULL) {
@ -1227,10 +1223,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(10,("samr_reply_query_dispinfo: starting user enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: starting user enumeration at index %u\n",
(unsigned int)enum_context ));
} else {
DEBUG(10,("samr_reply_query_dispinfo: using cached user enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: using cached user enumeration at index %u\n",
(unsigned int)enum_context ));
}
@ -1246,10 +1242,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(10,("samr_reply_query_dispinfo: starting machine enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: starting machine enumeration at index %u\n",
(unsigned int)enum_context ));
} else {
DEBUG(10,("samr_reply_query_dispinfo: using cached machine enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: using cached machine enumeration at index %u\n",
(unsigned int)enum_context ));
}
@ -1265,10 +1261,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(10,("samr_reply_query_dispinfo: starting group enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: starting group enumeration at index %u\n",
(unsigned int)enum_context ));
} else {
DEBUG(10,("samr_reply_query_dispinfo: using cached group enumeration at index %u\n",
DEBUG(10,("_samr_QueryDisplayInfo: using cached group enumeration at index %u\n",
(unsigned int)enum_context ));
}
@ -1283,30 +1279,31 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
}
unbecome_root();
/* Now create reply structure */
switch (q_u->switch_level) {
switch (r->in.level) {
case 0x1:
disp_ret = init_sam_dispinfo_1(p->mem_ctx, &ctr->sam.info1,
disp_ret = init_sam_dispinfo_1(p->mem_ctx, &disp_info->info1,
num_account, enum_context,
entries);
break;
case 0x2:
disp_ret = init_sam_dispinfo_2(p->mem_ctx, &ctr->sam.info2,
disp_ret = init_sam_dispinfo_2(p->mem_ctx, &disp_info->info2,
num_account, enum_context,
entries);
break;
case 0x3:
disp_ret = init_sam_dispinfo_3(p->mem_ctx, &ctr->sam.info3,
disp_ret = init_sam_dispinfo_3(p->mem_ctx, &disp_info->info3,
num_account, enum_context,
entries);
break;
case 0x4:
disp_ret = init_sam_dispinfo_4(p->mem_ctx, &ctr->sam.info4,
disp_ret = init_sam_dispinfo_4(p->mem_ctx, &disp_info->info4,
num_account, enum_context,
entries);
break;
case 0x5:
disp_ret = init_sam_dispinfo_5(p->mem_ctx, &ctr->sam.info5,
disp_ret = init_sam_dispinfo_5(p->mem_ctx, &disp_info->info5,
num_account, enum_context,
entries);
break;
@ -1322,22 +1319,20 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
total_data_size=num_account*struct_size;
if (num_account) {
r_u->status = STATUS_MORE_ENTRIES;
status = STATUS_MORE_ENTRIES;
} else {
r_u->status = NT_STATUS_OK;
status = NT_STATUS_OK;
}
/* Ensure we cache this enumeration. */
set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT);
DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__));
DEBUG(5, ("_samr_QueryDisplayInfo: %d\n", __LINE__));
init_samr_r_query_dispinfo(r_u, num_account, total_data_size,
temp_size, q_u->switch_level, ctr,
r_u->status);
return r_u->status;
*r->out.total_size = total_data_size;
*r->out.returned_size = temp_size;
return status;
}
/*******************************************************************
@ -5279,16 +5274,6 @@ NTSTATUS _samr_ChangePasswordUser(pipes_struct *p,
/****************************************************************
****************************************************************/
NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p,
struct samr_QueryDisplayInfo *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
}
/****************************************************************
****************************************************************/
NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p,
struct samr_GetDisplayEnumerationIndex *r)
{