1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

Use pidl for _samr_QueryGroupInfo().

Guenther
(This used to be commit e808524269)
This commit is contained in:
Günther Deschner 2008-02-07 13:58:53 +01:00
parent 6c457ac59f
commit 28124ad667
3 changed files with 81 additions and 101 deletions

View File

@ -1259,22 +1259,21 @@ bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
}
/*******************************************************************
inits a GROUP_INFO1 structure.
inits a samr_GroupInfoAll structure.
********************************************************************/
void init_samr_group_info1(GROUP_INFO1 * gr1,
char *acct_name, char *acct_desc,
uint32 num_members)
void init_samr_group_info1(struct samr_GroupInfoAll *r,
const char *name,
uint32_t attributes,
uint32_t num_members,
const char *description)
{
DEBUG(5, ("init_samr_group_info1\n"));
gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
gr1->num_members = num_members;
init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
init_lsa_String(&r->name, name);
r->attributes = attributes;
r->num_members = num_members;
init_lsa_String(&r->description, description);
}
/*******************************************************************
@ -1321,16 +1320,14 @@ bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
}
/*******************************************************************
inits a GROUP_INFO2 structure.
inits a lsa_String structure
********************************************************************/
void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
void init_samr_group_info2(struct lsa_String *r, const char *group_name)
{
DEBUG(5, ("init_samr_group_info2\n"));
gr2->level = 2;
init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
init_lsa_String(r, group_name);
}
/*******************************************************************
@ -1358,14 +1355,15 @@ bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int
}
/*******************************************************************
inits a GROUP_INFO3 structure.
inits a samr_GroupInfoAttributes structure.
********************************************************************/
void init_samr_group_info3(GROUP_INFO3 *gr3)
void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
uint32_t attributes)
{
DEBUG(5, ("init_samr_group_info3\n"));
gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
r->attributes = attributes;
}
/*******************************************************************
@ -1390,16 +1388,14 @@ bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int
}
/*******************************************************************
inits a GROUP_INFO4 structure.
inits a lsa_String structure
********************************************************************/
void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
void init_samr_group_info4(struct lsa_String *r, const char *description)
{
DEBUG(5, ("init_samr_group_info4\n"));
gr4->level = 4;
init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
init_lsa_String(r, description);
}
/*******************************************************************
@ -1426,23 +1422,23 @@ bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
return True;
}
/*******************************************************************
inits a GROUP_INFO5 structure.
inits a samr_GroupInfoAll structure.
********************************************************************/
void init_samr_group_info5(GROUP_INFO5 * gr5,
char *acct_name, char *acct_desc,
uint32 num_members)
void init_samr_group_info5(struct samr_GroupInfoAll *r,
const char *name,
uint32_t attributes,
uint32_t num_members,
const char *description)
{
DEBUG(5, ("init_samr_group_info5\n"));
gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
gr5->num_members = num_members;
init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
init_lsa_String(&r->name, name);
r->attributes = attributes;
r->num_members = num_members;
init_lsa_String(&r->description, description);
}
/*******************************************************************

View File

@ -662,28 +662,7 @@ static bool api_samr_create_dom_alias(pipes_struct *p)
static bool api_samr_query_groupinfo(pipes_struct *p)
{
SAMR_Q_QUERY_GROUPINFO q_u;
SAMR_R_QUERY_GROUPINFO 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_groupinfo("", &q_u, data, 0)) {
DEBUG(0,("api_samr_query_groupinfo: unable to unmarshall SAMR_Q_QUERY_GROUPINFO.\n"));
return False;
}
r_u.status = _samr_query_groupinfo(p, &q_u, &r_u);
if (!samr_io_r_query_groupinfo("", &r_u, rdata, 0)) {
DEBUG(0,("api_samr_query_groupinfo: unable to marshall SAMR_R_QUERY_GROUPINFO.\n"));
return False;
}
return True;
return proxy_samr_call(p, NDR_SAMR_QUERYGROUPINFO);
}
/*******************************************************************

View File

@ -4640,25 +4640,32 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p,
}
/*********************************************************************
_samr_query_groupinfo
sends the name/comment pair of a domain group
level 1 send also the number of users of that group
_samr_QueryGroupInfo
*********************************************************************/
NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u)
NTSTATUS _samr_QueryGroupInfo(pipes_struct *p,
struct samr_QueryGroupInfo *r)
{
NTSTATUS status;
DOM_SID group_sid;
GROUP_MAP map;
GROUP_INFO_CTR *ctr;
union samr_GroupInfo *info = NULL;
uint32 acc_granted;
bool ret;
uint32_t attributes = SE_GROUP_MANDATORY |
SE_GROUP_ENABLED_BY_DEFAULT |
SE_GROUP_ENABLED;
const char *group_name = NULL;
const char *group_description = NULL;
if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL))
if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) {
return r_u->status;
status = access_check_samr_function(acc_granted,
SA_RIGHT_GROUP_LOOKUP_INFO,
"_samr_QueryGroupInfo");
if (!NT_STATUS_IS_OK(status)) {
return status;
}
become_root();
@ -4667,41 +4674,47 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM
if (!ret)
return NT_STATUS_INVALID_HANDLE;
ctr=TALLOC_ZERO_P(p->mem_ctx, GROUP_INFO_CTR);
if (ctr==NULL)
return NT_STATUS_NO_MEMORY;
/* FIXME: map contains fstrings */
group_name = talloc_strdup(r, map.nt_name);
group_description = talloc_strdup(r, map.comment);
switch (q_u->switch_level) {
info = TALLOC_ZERO_P(p->mem_ctx, union samr_GroupInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
switch (r->in.level) {
case 1: {
uint32 *members;
size_t num_members;
ctr->switch_value1 = 1;
become_root();
r_u->status = pdb_enum_group_members(
status = pdb_enum_group_members(
p->mem_ctx, &group_sid, &members, &num_members);
unbecome_root();
if (!NT_STATUS_IS_OK(r_u->status)) {
return r_u->status;
if (!NT_STATUS_IS_OK(status)) {
return status;
}
init_samr_group_info1(&ctr->group.info1, map.nt_name,
map.comment, num_members);
init_samr_group_info1(&info->all,
group_name,
attributes,
num_members,
group_description);
break;
}
case 2:
ctr->switch_value1 = 2;
init_samr_group_info2(&ctr->group.info2, map.nt_name);
init_samr_group_info2(&info->name,
group_name);
break;
case 3:
ctr->switch_value1 = 3;
init_samr_group_info3(&ctr->group.info3);
init_samr_group_info3(&info->attributes,
attributes);
break;
case 4:
ctr->switch_value1 = 4;
init_samr_group_info4(&ctr->group.info4, map.comment);
init_samr_group_info4(&info->description,
group_description);
break;
case 5: {
/*
@ -4709,27 +4722,29 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM
size_t num_members;
*/
ctr->switch_value1 = 5;
/*
become_root();
r_u->status = pdb_enum_group_members(
status = pdb_enum_group_members(
p->mem_ctx, &group_sid, &members, &num_members);
unbecome_root();
if (!NT_STATUS_IS_OK(r_u->status)) {
return r_u->status;
if (!NT_STATUS_IS_OK(status)) {
return status;
}
*/
init_samr_group_info5(&ctr->group.info5, map.nt_name,
map.comment, 0 /* num_members */); /* in w2k3 this is always 0 */
init_samr_group_info5(&info->all2,
group_name,
attributes,
0, /* num_members - in w2k3 this is always 0 */
group_description);
break;
}
default:
return NT_STATUS_INVALID_INFO_CLASS;
}
init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_OK);
*r->out.info = info;
return NT_STATUS_OK;
}
@ -5213,16 +5228,6 @@ NTSTATUS _samr_LookupRids(pipes_struct *p,
/****************************************************************
****************************************************************/
NTSTATUS _samr_QueryGroupInfo(pipes_struct *p,
struct samr_QueryGroupInfo *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
}
/****************************************************************
****************************************************************/
NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p,
struct samr_SetMemberAttributesOfGroup *r)
{