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

r14646: Adding samr querygroup infolevels 2 & 5.

Guenther
(This used to be commit 6c4fe819c6)
This commit is contained in:
Günther Deschner 2006-03-22 15:00:42 +00:00 committed by Gerald (Jerry) Carter
parent fb62a719dc
commit 20204ab040
4 changed files with 152 additions and 13 deletions

View File

@ -1112,6 +1112,21 @@ typedef struct samr_group_info4
} GROUP_INFO4;
typedef struct samr_group_info5
{
UNIHDR hdr_acct_name;
uint32 group_attr; /* 0x0000 0003 - group attribute */
uint32 num_members; /* 0x0000 0001 - number of group members? */
UNIHDR hdr_acct_desc;
UNISTR2 uni_acct_name;
UNISTR2 uni_acct_desc;
} GROUP_INFO5;
/* GROUP_INFO_CTR */
typedef struct group_info_ctr
{
@ -1123,7 +1138,7 @@ typedef struct group_info_ctr
GROUP_INFO2 info2;
GROUP_INFO3 info3;
GROUP_INFO4 info4;
GROUP_INFO5 info5;
} group;
} GROUP_INFO_CTR;

View File

@ -2306,6 +2306,69 @@ BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
return True;
}
/*******************************************************************
inits a GROUP_INFO5 structure.
********************************************************************/
void init_samr_group_info5(GROUP_INFO5 * gr5,
char *acct_name, char *acct_desc,
uint32 num_members)
{
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);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
prs_struct *ps, int depth)
{
uint16 dummy = 1;
if (gr5 == NULL)
return False;
prs_debug(ps, depth, desc, "samr_io_group_info5");
depth++;
if(!prs_uint16("level", ps, depth, &dummy))
return False;
if(!prs_align(ps))
return False;
if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
return False;
if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
return False;
if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
return False;
if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
return False;
if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
gr5->hdr_acct_name.buffer, ps, depth))
return False;
if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
gr5->hdr_acct_desc.buffer, ps, depth))
return False;
return True;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
@ -2342,6 +2405,10 @@ static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
return False;
break;
case 5:
if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
return False;
break;
default:
DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
break;

View File

@ -4362,6 +4362,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM
map.comment, num_members);
break;
}
case 2:
ctr->switch_value1 = 2;
init_samr_group_info2(&ctr->group.info2, map.nt_name);
break;
case 3:
ctr->switch_value1 = 3;
init_samr_group_info3(&ctr->group.info3);
@ -4370,6 +4374,28 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM
ctr->switch_value1 = 4;
init_samr_group_info4(&ctr->group.info4, map.comment);
break;
case 5: {
/*
uint32 *members;
size_t num_members;
*/
ctr->switch_value1 = 5;
/*
become_root();
r_u->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;
}
*/
init_samr_group_info5(&ctr->group.info5, map.nt_name,
map.comment, 0 /* num_members */); /* in w2k3 this is always 0 */
break;
}
default:
return NT_STATUS_INVALID_INFO_CLASS;
}

View File

@ -439,6 +439,18 @@ static void display_group_info1(GROUP_INFO1 *info1)
printf("\tNum Members:%d\n", info1->num_members);
}
/****************************************************************************
display group info
****************************************************************************/
static void display_group_info2(GROUP_INFO2 *info2)
{
fstring name;
unistr2_to_ascii(name, &info2->uni_acct_name, sizeof(name)-1);
printf("\tGroup Description:%s\n", name);
}
/****************************************************************************
display group info
****************************************************************************/
@ -459,24 +471,43 @@ static void display_group_info4(GROUP_INFO4 *info4)
printf("\tGroup Description:%s\n", desc);
}
/****************************************************************************
display group info
****************************************************************************/
static void display_group_info5(GROUP_INFO5 *info5)
{
fstring temp;
unistr2_to_ascii(temp, &info5->uni_acct_name, sizeof(temp)-1);
printf("\tGroup Name:\t%s\n", temp);
unistr2_to_ascii(temp, &info5->uni_acct_desc, sizeof(temp)-1);
printf("\tDescription:\t%s\n", temp);
printf("\tGroup Attribute:%d\n", info5->group_attr);
printf("\tNum Members:%d\n", info5->num_members);
}
/****************************************************************************
display sam sync structure
****************************************************************************/
static void display_group_info_ctr(GROUP_INFO_CTR *ctr)
{
switch (ctr->switch_value1) {
case 1: {
display_group_info1(&ctr->group.info1);
break;
}
case 3: {
display_group_info3(&ctr->group.info3);
break;
}
case 4: {
display_group_info4(&ctr->group.info4);
break;
}
case 1:
display_group_info1(&ctr->group.info1);
break;
case 2:
display_group_info2(&ctr->group.info2);
break;
case 3:
display_group_info3(&ctr->group.info3);
break;
case 4:
display_group_info4(&ctr->group.info4);
break;
case 5:
display_group_info5(&ctr->group.info5);
break;
}
}