From 404b7b49b20829fa415ffed4ba1f473e28de43fe Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 3 Dec 1998 17:29:03 +0000 Subject: adding group parsing: add/modify/delete/add members. (This used to be commit 13a656b0e5c73e157b222765fb57a1bdafc67b80) --- source3/include/proto.h | 28 +++- source3/include/rpc_samr.h | 8 +- source3/rpc_parse/parse_samr.c | 307 +++++++++++++++++++++++++++++------------ 3 files changed, 244 insertions(+), 99 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index ea260f07cd..c1f46da32d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1609,9 +1609,9 @@ BOOL do_samr_open_domain(struct cli_state *cli, POLICY_HND *domain_pol); BOOL do_samr_query_unknown_12(struct cli_state *cli, POLICY_HND *pol, uint32 rid, uint32 num_gids, uint32 *gids, - uint32 *num_aliases, - fstring als_names [MAX_LOOKUP_SIDS], - uint32 num_als_users[MAX_LOOKUP_SIDS]); + uint32 *num_names, + fstring names[MAX_LOOKUP_SIDS], + uint32 type [MAX_LOOKUP_SIDS]); BOOL do_samr_query_useraliases(struct cli_state *cli, POLICY_HND *pol, DOM_SID *sid, uint32 *num_aliases, uint32 *rid); @@ -2053,6 +2053,26 @@ void samr_io_group_info1(char *desc, GROUP_INFO1 *gr1, prs_struct *ps, int dept void make_samr_group_info4(GROUP_INFO4 *gr4, char *acct_desc); void samr_io_group_info4(char *desc, GROUP_INFO4 *gr4, prs_struct *ps, int depth); void samr_group_info_ctr(char *desc, GROUP_INFO_CTR *ctr, prs_struct *ps, int depth); +void make_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_e, + POLICY_HND *pol, + char *acct_desc); +void samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP *q_e, prs_struct *ps, int depth); +void make_samr_r_create_dom_group(SAMR_R_CREATE_DOM_GROUP *r_u, POLICY_HND *pol, + uint32 rid, uint32 status); +void samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP *r_u, prs_struct *ps, int depth); +void make_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_e, + POLICY_HND *pol, + uint32 rid); +void samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM *q_e, prs_struct *ps, int depth); +void make_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM *r_u, POLICY_HND *pol, + uint32 status); +void samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM *r_u, prs_struct *ps, int depth); +void make_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO *q_e, + POLICY_HND *pol, GROUP_INFO_CTR *ctr); +void samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO *q_e, prs_struct *ps, int depth); +void make_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO *r_u, + uint32 status); +void samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO *r_u, prs_struct *ps, int depth); void make_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_e, POLICY_HND *pol, uint16 switch_level); @@ -2115,7 +2135,7 @@ void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, uint32 num_gids, uint32 *gid); void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth); void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u, - uint32 num_aliases, fstring *als_name, uint8 *num_als_usrs, + uint32 num_names, fstring *name, uint8 *type, uint32 status); void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth); void make_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, POLICY_HND *hnd); diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index 1fd48f8020..6ca715bdf6 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -2,9 +2,9 @@ Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - Copyright (C) Paul Ashton 1997 + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 + Copyright (C) Paul Ashton 1997-1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -695,8 +695,6 @@ typedef struct r_samr_query_dispinfo_info } SAMR_R_QUERY_DISPINFO; -#define SAMR_CREATE_DOM_GROUP 0x0a - /* SAMR_Q_CREATE_DOM_GROUP - SAM create group */ typedef struct q_samr_create_dom_group_info { diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index e1f4d01d9b..90e60a36cd 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -2,9 +2,9 @@ * Unix SMB/Netbios implementation. * Version 1.9. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. + * Copyright (C) Andrew Tridgell 1992-1998, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1284,93 +1284,6 @@ void samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP *r_u, prs_struct *ps, i } -#if 0 -/* SAMR_Q_CREATE_DOM_GROUP - SAM create group */ -typedef struct q_samr_create_dom_group_info -{ - POLICY_HND pol; /* policy handle */ - - UNIHDR hdr_acct_desc; - UNISTR2 uni_acct_desc; - - uint16 unknown_1; /* 0x0002 */ - uint16 unknown_2; /* 0x0001 */ - -} SAMR_Q_CREATE_DOM_GROUP; - -/* SAMR_R_CREATE_DOM_GROUP - SAM create group */ -typedef struct r_samr_create_dom_group_info -{ - POLICY_HND pol; /* policy handle */ - - uint32 rid; - uint32 status; - -} SAMR_R_CREATE_DOM_GROUP; - - -/* SAMR_Q_SET_GROUPINFO - SAM Group Info */ -typedef struct q_samr_set_group_info -{ - POLICY_HND pol; /* policy handle */ - uint16 switch_value1; /* 0x0004 seen */ - uint16 switch_value2; /* 0x0004 seen */ - - union - { - GROUP_INFO4 info4; - - } group; - -} SAMR_Q_SET_GROUPINFO; - -/* SAMR_R_SET_GROUPINFO - SAM Group Info */ -typedef struct r_samr_set_group_info -{ - uint32 status; - -} SAMR_R_SET_GROUPINFO; - - -/* SAMR_Q_ADD_GROUPMEM - probably an add group member */ -typedef struct q_samr_add_group_mem_info -{ - POLICY_HND pol; /* policy handle */ - - uint32 rid; /* rid */ - uint32 unknown; /* 0x0000 0005 */ - -} SAMR_Q_ADD_GROUPMEM; - - -/* SAMR_R_ADD_GROUPMEM - probably an add group member */ -typedef struct r_samr_add_group_mem_info -{ - uint32 status; /* return status */ - -} SAMR_R_ADD_GROUPMEM; - - -/* SAMR_Q_OPEN_GROUP - probably an open */ -typedef struct q_samr_open_group_info -{ - POLICY_HND domain_pol; - uint32 unknown; /* 0x0000 0001, 0x0000 0003, 0x0000 001f */ - uint32 rid_group; /* rid */ - -} SAMR_Q_OPEN_GROUP; - - -/* SAMR_R_OPEN_GROUP - probably an open */ -typedef struct r_samr_open_group_info -{ - POLICY_HND pol; /* policy handle */ - uint32 status; /* return status */ - -} SAMR_R_OPEN_GROUP; -#endif - - /******************************************************************* makes a GROUP_INFO1 structure. ********************************************************************/ @@ -1487,6 +1400,220 @@ void samr_group_info_ctr(char *desc, GROUP_INFO_CTR *ctr, prs_struct *ps, int d } +/******************************************************************* +makes a SAMR_Q_CREATE_DOM_GROUP structure. +********************************************************************/ +void make_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_e, + POLICY_HND *pol, + char *acct_desc) +{ + int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0; + if (q_e == NULL || pol == NULL) return; + + DEBUG(5,("make_samr_q_create_dom_group\n")); + + memcpy(&(q_e->pol), pol, sizeof(*pol)); + + make_uni_hdr(&(q_e->hdr_acct_desc), acct_len , acct_len, acct_desc ? 1 : 0); + make_unistr2(&(q_e->uni_acct_desc), acct_desc, acct_len); + + q_e->unknown_1 = 0x0002; + q_e->unknown_2 = 0x0001; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP *q_e, prs_struct *ps, int depth) +{ + if (q_e == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_q_create_dom_group"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); + prs_align(ps); + + smb_io_unihdr ("hdr_acct_desc", &(q_e->hdr_acct_desc), ps, depth); + smb_io_unistr2("uni_acct_desc", &(q_e->uni_acct_desc), q_e->hdr_acct_desc.buffer, ps, depth); + prs_align(ps); + + prs_uint16("unknown_1", ps, depth, &(q_e->unknown_1)); + prs_uint16("unknown_2", ps, depth, &(q_e->unknown_2)); +} + + +/******************************************************************* +makes a SAMR_R_CREATE_DOM_GROUP structure. +********************************************************************/ +void make_samr_r_create_dom_group(SAMR_R_CREATE_DOM_GROUP *r_u, POLICY_HND *pol, + uint32 rid, uint32 status) +{ + if (r_u == NULL) return; + + DEBUG(5,("make_samr_r_create_dom_group\n")); + + memcpy(&(r_u->pol), pol, sizeof(*pol)); + + r_u->rid = rid ; + r_u->status = status; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_r_create_dom_group"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("pol", &(r_u->pol), ps, depth); + prs_align(ps); + + prs_uint32("rid ", ps, depth, &(r_u->rid )); + prs_uint32("status", ps, depth, &(r_u->status)); +} + + +/******************************************************************* +makes a SAMR_Q_ADD_GROUPMEM structure. +********************************************************************/ +void make_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_e, + POLICY_HND *pol, + uint32 rid) +{ + if (q_e == NULL || pol == NULL) return; + + DEBUG(5,("make_samr_q_add_groupmem\n")); + + memcpy(&(q_e->pol), pol, sizeof(*pol)); + + q_e->rid = rid; + q_e->unknown = 0x0005; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM *q_e, prs_struct *ps, int depth) +{ + if (q_e == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_q_add_groupmem"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); + prs_align(ps); + + prs_uint32("rid ", ps, depth, &(q_e->rid)); + prs_uint32("unknown", ps, depth, &(q_e->unknown)); +} + + +/******************************************************************* +makes a SAMR_R_ADD_GROUPMEM structure. +********************************************************************/ +void make_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM *r_u, POLICY_HND *pol, + uint32 status) +{ + if (r_u == NULL) return; + + DEBUG(5,("make_samr_r_add_groupmem\n")); + + r_u->status = status; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_r_add_groupmem"); + depth++; + + prs_align(ps); + + prs_uint32("status", ps, depth, &(r_u->status)); +} + + +/******************************************************************* +makes a SAMR_Q_SET_GROUPINFO structure. +********************************************************************/ +void make_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO *q_e, + POLICY_HND *pol, GROUP_INFO_CTR *ctr) +{ + if (q_e == NULL || pol == NULL) return; + + DEBUG(5,("make_samr_q_set_groupinfo\n")); + + memcpy(&(q_e->pol), pol, sizeof(*pol)); + q_e->ctr = ctr; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO *q_e, prs_struct *ps, int depth) +{ + if (q_e == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("pol", &(q_e->pol), ps, depth); + prs_align(ps); + + samr_group_info_ctr("ctr", q_e->ctr, ps, depth); +} + + +/******************************************************************* +makes a SAMR_R_SET_GROUPINFO structure. +********************************************************************/ +void make_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO *r_u, + uint32 status) +{ + if (r_u == NULL) return; + + DEBUG(5,("make_samr_r_set_groupinfo\n")); + + r_u->status = status; +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) return; + + prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo"); + depth++; + + prs_align(ps); + + prs_uint32("status", ps, depth, &(r_u->status)); +} + /******************************************************************* makes a SAMR_Q_QUERY_GROUPINFO structure. ********************************************************************/ -- cgit