diff options
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_pipe.c | 17 | ||||
-rw-r--r-- | source3/rpc_client/cli_reg.c | 153 | ||||
-rw-r--r-- | source3/rpc_client/cli_samr.c | 225 | ||||
-rw-r--r-- | source3/rpc_client/msrpc_samr.c | 316 |
4 files changed, 273 insertions, 438 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 9aad93246e..08d7e42270 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -628,6 +628,23 @@ static BOOL create_rpc_request(prs_struct *rhdr, uint8 op_num, int data_len, /**************************************************************************** send a request on an rpc pipe. ****************************************************************************/ +BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num, + prs_struct *data, prs_struct *rdata) +{ + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + + return rpc_api_pipe_req(cli, fnum, op_num, data, rdata); +} + +/**************************************************************************** + send a request on an rpc pipe. + ****************************************************************************/ BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num, prs_struct *data, prs_struct *rdata) { diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c index 46ab55dcab..9242d5587c 100644 --- a/source3/rpc_client/cli_reg.c +++ b/source3/rpc_client/cli_reg.c @@ -300,14 +300,6 @@ BOOL reg_flush_key( POLICY_HND *hnd) REG_Q_FLUSH_KEY q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -323,7 +315,7 @@ BOOL reg_flush_key( POLICY_HND *hnd) reg_io_q_flush_key("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_FLUSH_KEY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_FLUSH_KEY, &buf, &rbuf)) { REG_R_FLUSH_KEY r_o; BOOL p; @@ -367,14 +359,6 @@ BOOL reg_query_key( POLICY_HND *hnd, REG_Q_QUERY_KEY q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -390,7 +374,7 @@ BOOL reg_query_key( POLICY_HND *hnd, reg_io_q_query_key("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_QUERY_KEY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_QUERY_KEY, &buf, &rbuf)) { REG_R_QUERY_KEY r_o; BOOL p; @@ -440,14 +424,6 @@ BOOL reg_unknown_1a( POLICY_HND *hnd, uint32 *unk) REG_Q_UNK_1A q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -463,7 +439,7 @@ BOOL reg_unknown_1a( POLICY_HND *hnd, uint32 *unk) reg_io_q_unk_1a("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_UNK_1A, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_UNK_1A, &buf, &rbuf)) { REG_R_UNK_1A r_o; BOOL p; @@ -505,14 +481,6 @@ BOOL reg_query_info( POLICY_HND *hnd, REG_Q_INFO q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -528,7 +496,7 @@ BOOL reg_query_info( POLICY_HND *hnd, reg_io_q_info("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_INFO, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_INFO, &buf, &rbuf)) { REG_R_INFO r_o; BOOL p; @@ -572,14 +540,6 @@ BOOL reg_set_key_sec( POLICY_HND *hnd, REG_Q_SET_KEY_SEC q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -595,7 +555,7 @@ BOOL reg_set_key_sec( POLICY_HND *hnd, reg_io_q_set_key_sec("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_SET_KEY_SEC, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_SET_KEY_SEC, &buf, &rbuf)) { REG_R_SET_KEY_SEC r_o; BOOL p; @@ -630,14 +590,6 @@ BOOL reg_get_key_sec( POLICY_HND *hnd, REG_Q_GET_KEY_SEC q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -653,7 +605,7 @@ BOOL reg_get_key_sec( POLICY_HND *hnd, reg_io_q_get_key_sec("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_GET_KEY_SEC, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_GET_KEY_SEC, &buf, &rbuf)) { REG_R_GET_KEY_SEC r_o; BOOL p; @@ -706,14 +658,6 @@ BOOL reg_delete_val( POLICY_HND *hnd, char *val_name) REG_Q_DELETE_VALUE q_o; BOOL valid_delete = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -729,7 +673,7 @@ BOOL reg_delete_val( POLICY_HND *hnd, char *val_name) reg_io_q_delete_val("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_DELETE_VALUE, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_DELETE_VALUE, &buf, &rbuf)) { REG_R_DELETE_VALUE r_o; BOOL p; @@ -768,14 +712,6 @@ BOOL reg_delete_key( POLICY_HND *hnd, char *key_name) REG_Q_DELETE_KEY q_o; BOOL valid_delete = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -791,7 +727,7 @@ BOOL reg_delete_key( POLICY_HND *hnd, char *key_name) reg_io_q_delete_key("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_DELETE_KEY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_DELETE_KEY, &buf, &rbuf)) { REG_R_DELETE_KEY r_o; BOOL p; @@ -836,14 +772,6 @@ BOOL reg_create_key( POLICY_HND *hnd, SEC_DESC_BUF sec_buf; int sec_len; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - ZERO_STRUCT(sec); ZERO_STRUCT(sec_buf); ZERO_STRUCT(q_o); @@ -870,7 +798,7 @@ BOOL reg_create_key( POLICY_HND *hnd, reg_io_q_create_key("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_CREATE_KEY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_CREATE_KEY, &buf, &rbuf)) { REG_R_CREATE_KEY r_o; BOOL p; @@ -915,14 +843,6 @@ BOOL reg_enum_key( POLICY_HND *hnd, REG_Q_ENUM_KEY q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -938,7 +858,7 @@ BOOL reg_enum_key( POLICY_HND *hnd, reg_io_q_enum_key("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_ENUM_KEY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_ENUM_KEY, &buf, &rbuf)) { REG_R_ENUM_KEY r_o; BOOL p; @@ -983,14 +903,6 @@ BOOL reg_create_val( POLICY_HND *hnd, REG_Q_CREATE_VALUE q_o; BOOL valid_create = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -1006,7 +918,7 @@ BOOL reg_create_val( POLICY_HND *hnd, reg_io_q_create_val("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_CREATE_VALUE, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_CREATE_VALUE, &buf, &rbuf)) { REG_R_CREATE_VALUE r_o; BOOL p; @@ -1048,14 +960,6 @@ BOOL reg_enum_val( POLICY_HND *hnd, REG_Q_ENUM_VALUE q_o; BOOL valid_query = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -1071,7 +975,7 @@ BOOL reg_enum_val( POLICY_HND *hnd, reg_io_q_enum_val("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_ENUM_VALUE, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_ENUM_VALUE, &buf, &rbuf)) { REG_R_ENUM_VALUE r_o; BOOL p; @@ -1115,14 +1019,6 @@ BOOL reg_open_entry( POLICY_HND *hnd, REG_Q_OPEN_ENTRY q_o; BOOL valid_pol = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -1138,7 +1034,7 @@ BOOL reg_open_entry( POLICY_HND *hnd, reg_io_q_open_entry("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_OPEN_ENTRY, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_OPEN_ENTRY, &buf, &rbuf)) { REG_R_OPEN_ENTRY r_o; BOOL p; @@ -1157,9 +1053,16 @@ BOOL reg_open_entry( POLICY_HND *hnd, if (p) { + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data)); - valid_pol = register_policy_hnd(key_hnd) && - set_policy_cli_state(key_hnd, cli, fnum, NULL); + valid_pol = cli_pol_link(key_hnd, hnd); } } @@ -1179,14 +1082,6 @@ BOOL reg_close( POLICY_HND *hnd) REG_Q_CLOSE q_c; BOOL valid_close = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; - - if (!cli_state_get(hnd, &cli, &fnum)) - { - return False; - } - if (hnd == NULL) return False; /* create and send a MSRPC command with api REG_CLOSE */ @@ -1203,7 +1098,7 @@ BOOL reg_close( POLICY_HND *hnd) reg_io_q_close("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, REG_CLOSE, &buf, &rbuf)) + if (rpc_hnd_pipe_req(hnd, REG_CLOSE, &buf, &rbuf)) { REG_R_CLOSE r_c; BOOL p; @@ -1263,7 +1158,7 @@ BOOL reg_shutdown(const char *srv_name, struct cli_state *cli = NULL; uint16 fnum = 0xffff; - if (!cli_state_init(srv_name, PIPE_WINREG, &cli, &fnum)) + if (!cli_state_init(srv_name, PIPE_LSARPC, &cli, &fnum)) { return False; } diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c index 97e218b1b3..44425b5358 100644 --- a/source3/rpc_client/cli_samr.c +++ b/source3/rpc_client/cli_samr.c @@ -31,11 +31,29 @@ extern int DEBUGLEVEL; +#if 0 + if (p) + { + /* ok, at last: we're happy. return the policy handle */ + memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); + valid_pol = register_policy_hnd(hnd) && + set_policy_cli_state(hnd, cli, fnum, + cli_state_free); + } + + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(connect_pol, &cli, &fnum)) + { + return False; + } +#endif /**************************************************************************** do a SAMR change user password command ****************************************************************************/ -BOOL samr_chgpasswd_user(struct cli_state *cli, uint16 fnum, +BOOL samr_chgpasswd_user( struct cli_state *cli, uint16 fnum, char *srv_name, char *user_name, char nt_newpass[516], uchar nt_oldhash[16], char lm_newpass[516], uchar lm_oldhash[16]) @@ -86,6 +104,8 @@ BOOL samr_chgpasswd_user(struct cli_state *cli, uint16 fnum, prs_mem_free(&data ); prs_mem_free(&rdata ); + cli_state_free(cli, fnum); + return valid_pwc; } @@ -145,8 +165,7 @@ BOOL samr_unknown_38(struct cli_state *cli, uint16 fnum, char *srv_name) /**************************************************************************** do a SAMR unknown 0x8 command ****************************************************************************/ -BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum, - POLICY_HND *domain_pol, uint16 switch_value, +BOOL samr_query_dom_info( POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr) { prs_struct data; @@ -171,7 +190,7 @@ BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum, samr_io_q_query_dom_info("", &q_e, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_DOMAIN_INFO, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_QUERY_DOMAIN_INFO, &data, &rdata)) { SAMR_R_QUERY_DOMAIN_INFO r_e; BOOL p; @@ -202,8 +221,7 @@ BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR enumerate Domains ****************************************************************************/ -uint32 samr_enum_domains(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, +uint32 samr_enum_domains( POLICY_HND *pol, uint32 *start_idx, uint32 size, struct acct_info **sam, uint32 *num_sam_domains) @@ -233,7 +251,7 @@ uint32 samr_enum_domains(struct cli_state *cli, uint16 fnum, samr_io_q_enum_domains("", &q_e, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ENUM_DOMAINS, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_ENUM_DOMAINS, &data, &rdata)) { SAMR_R_ENUM_DOMAINS r_e; BOOL p; @@ -304,8 +322,7 @@ uint32 samr_enum_domains(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR enumerate groups ****************************************************************************/ -uint32 samr_enum_dom_groups(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, +uint32 samr_enum_dom_groups( POLICY_HND *pol, uint32 *start_idx, uint32 size, struct acct_info **sam, uint32 *num_sam_groups) @@ -335,7 +352,7 @@ uint32 samr_enum_dom_groups(struct cli_state *cli, uint16 fnum, samr_io_q_enum_dom_groups("", &q_e, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ENUM_DOM_GROUPS, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_ENUM_DOM_GROUPS, &data, &rdata)) { SAMR_R_ENUM_DOM_GROUPS r_e; BOOL p; @@ -406,8 +423,7 @@ uint32 samr_enum_dom_groups(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR enumerate aliases ****************************************************************************/ -uint32 samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, +uint32 samr_enum_dom_aliases( POLICY_HND *pol, uint32 *start_idx, uint32 size, struct acct_info **sam, uint32 *num_sam_aliases) @@ -437,7 +453,7 @@ uint32 samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum, samr_io_q_enum_dom_aliases("", &q_e, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ENUM_DOM_ALIASES, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_ENUM_DOM_ALIASES, &data, &rdata)) { SAMR_R_ENUM_DOM_ALIASES r_e; BOOL p; @@ -507,8 +523,7 @@ uint32 samr_enum_dom_aliases(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR enumerate users ****************************************************************************/ -uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint32 *start_idx, +uint32 samr_enum_dom_users( POLICY_HND *pol, uint32 *start_idx, uint16 acb_mask, uint16 unk_1, uint32 size, struct acct_info **sam, uint32 *num_sam_users) @@ -539,7 +554,7 @@ uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum, samr_io_q_enum_dom_users("", &q_e, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ENUM_DOM_USERS, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_ENUM_DOM_USERS, &data, &rdata)) { SAMR_R_ENUM_DOM_USERS r_e; BOOL p; @@ -615,8 +630,7 @@ uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Connect ****************************************************************************/ -BOOL samr_connect(struct cli_state *cli, uint16 fnum, - const char *srv_name, uint32 unknown_0, +BOOL samr_connect( const char *srv_name, uint32 unknown_0, POLICY_HND *connect_pol) { prs_struct data; @@ -625,6 +639,14 @@ BOOL samr_connect(struct cli_state *cli, uint16 fnum, SAMR_Q_CONNECT q_o; BOOL valid_pol = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_init(srv_name, PIPE_SAMR, &cli, &fnum)) + { + return False; + } + DEBUG(4,("SAMR Open Policy server:%s undoc value:%x\n", srv_name, unknown_0)); @@ -660,7 +682,9 @@ BOOL samr_connect(struct cli_state *cli, uint16 fnum, if (p) { memcpy(connect_pol, &r_o.connect_pol, sizeof(r_o.connect_pol)); - valid_pol = True; + valid_pol = register_policy_hnd(connect_pol) && + set_policy_cli_state(connect_pol, cli, fnum, + cli_state_free); } } @@ -673,8 +697,7 @@ BOOL samr_connect(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Open User ****************************************************************************/ -BOOL samr_open_user(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol, +BOOL samr_open_user( const POLICY_HND *pol, uint32 unk_0, uint32 rid, POLICY_HND *user_pol) { @@ -701,7 +724,7 @@ BOOL samr_open_user(struct cli_state *cli, uint16 fnum, samr_io_q_open_user("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_OPEN_USER, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_OPEN_USER, &data, &rdata)) { SAMR_R_OPEN_USER r_o; BOOL p; @@ -719,7 +742,7 @@ BOOL samr_open_user(struct cli_state *cli, uint16 fnum, if (p) { memcpy(user_pol, &r_o.user_pol, sizeof(r_o.user_pol)); - valid_pol = True; + valid_pol = cli_pol_link(user_pol, pol); } } @@ -732,8 +755,7 @@ BOOL samr_open_user(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Open Alias ****************************************************************************/ -BOOL samr_open_alias(struct cli_state *cli, uint16 fnum, - const POLICY_HND *domain_pol, +BOOL samr_open_alias( const POLICY_HND *domain_pol, uint32 flags, uint32 rid, POLICY_HND *alias_pol) { @@ -759,7 +781,7 @@ BOOL samr_open_alias(struct cli_state *cli, uint16 fnum, samr_io_q_open_alias("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_OPEN_ALIAS, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_OPEN_ALIAS, &data, &rdata)) { SAMR_R_OPEN_ALIAS r_o; BOOL p; @@ -777,7 +799,7 @@ BOOL samr_open_alias(struct cli_state *cli, uint16 fnum, if (p) { memcpy(alias_pol, &r_o.pol, sizeof(r_o.pol)); - valid_pol = True; + valid_pol = cli_pol_link(alias_pol, domain_pol); } } @@ -790,8 +812,7 @@ BOOL samr_open_alias(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Delete Alias Member ****************************************************************************/ -BOOL samr_del_aliasmem(struct cli_state *cli, uint16 fnum, - POLICY_HND *alias_pol, DOM_SID *sid) +BOOL samr_del_aliasmem( POLICY_HND *alias_pol, DOM_SID *sid) { prs_struct data; prs_struct rdata; @@ -815,7 +836,7 @@ BOOL samr_del_aliasmem(struct cli_state *cli, uint16 fnum, samr_io_q_del_aliasmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_DEL_ALIASMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_DEL_ALIASMEM, &data, &rdata)) { SAMR_R_DEL_ALIASMEM r_o; BOOL p; @@ -845,8 +866,7 @@ BOOL samr_del_aliasmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Add Alias Member ****************************************************************************/ -BOOL samr_add_aliasmem(struct cli_state *cli, uint16 fnum, - POLICY_HND *alias_pol, DOM_SID *sid) +BOOL samr_add_aliasmem( POLICY_HND *alias_pol, DOM_SID *sid) { prs_struct data; prs_struct rdata; @@ -870,7 +890,7 @@ BOOL samr_add_aliasmem(struct cli_state *cli, uint16 fnum, samr_io_q_add_aliasmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ADD_ALIASMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_ADD_ALIASMEM, &data, &rdata)) { SAMR_R_ADD_ALIASMEM r_o; BOOL p; @@ -900,8 +920,7 @@ BOOL samr_add_aliasmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Delete Domain Alias ****************************************************************************/ -BOOL samr_delete_dom_alias(struct cli_state *cli, uint16 fnum, - POLICY_HND *alias_pol) +BOOL samr_delete_dom_alias( POLICY_HND *alias_pol) { prs_struct data; prs_struct rdata; @@ -925,7 +944,7 @@ BOOL samr_delete_dom_alias(struct cli_state *cli, uint16 fnum, samr_io_q_delete_dom_alias("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_DELETE_DOM_ALIAS, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_DELETE_DOM_ALIAS, &data, &rdata)) { SAMR_R_DELETE_DOM_ALIAS r_o; BOOL p; @@ -955,8 +974,7 @@ BOOL samr_delete_dom_alias(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Create Domain User ****************************************************************************/ -BOOL samr_create_dom_user(struct cli_state *cli, uint16 fnum, - POLICY_HND *domain_pol, const char *acct_name, +BOOL samr_create_dom_user( POLICY_HND *domain_pol, const char *acct_name, uint32 unk_0, uint32 unk_1, POLICY_HND *user_pol, uint32 *rid) { @@ -982,7 +1000,7 @@ BOOL samr_create_dom_user(struct cli_state *cli, uint16 fnum, samr_io_q_create_user("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_CREATE_USER, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_CREATE_USER, &data, &rdata)) { SAMR_R_CREATE_USER r_o; BOOL p; @@ -1001,7 +1019,7 @@ BOOL samr_create_dom_user(struct cli_state *cli, uint16 fnum, { memcpy(user_pol, &r_o.user_pol, sizeof(r_o.user_pol)); *rid = r_o.user_rid; - valid_pol = True; + valid_pol = cli_pol_link(user_pol, domain_pol); } } @@ -1014,8 +1032,7 @@ BOOL samr_create_dom_user(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Create Domain Alias ****************************************************************************/ -BOOL samr_create_dom_alias(struct cli_state *cli, uint16 fnum, - POLICY_HND *domain_pol, const char *acct_name, +BOOL samr_create_dom_alias( POLICY_HND *domain_pol, const char *acct_name, POLICY_HND *alias_pol, uint32 *rid) { prs_struct data; @@ -1040,7 +1057,7 @@ BOOL samr_create_dom_alias(struct cli_state *cli, uint16 fnum, samr_io_q_create_dom_alias("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_CREATE_DOM_ALIAS, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_CREATE_DOM_ALIAS, &data, &rdata)) { SAMR_R_CREATE_DOM_ALIAS r_o; BOOL p; @@ -1059,7 +1076,7 @@ BOOL samr_create_dom_alias(struct cli_state *cli, uint16 fnum, { memcpy(alias_pol, &r_o.alias_pol, sizeof(r_o.alias_pol)); *rid = r_o.rid; - valid_pol = True; + valid_pol = cli_pol_link(alias_pol, domain_pol); } } @@ -1072,8 +1089,7 @@ BOOL samr_create_dom_alias(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Get Alias Info ****************************************************************************/ -BOOL samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *alias_pol, uint16 switch_value, +BOOL samr_query_aliasinfo( POLICY_HND *alias_pol, uint16 switch_value, ALIAS_INFO_CTR *ctr) { prs_struct data; @@ -1098,7 +1114,7 @@ BOOL samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, samr_io_q_query_aliasinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_ALIASINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_QUERY_ALIASINFO, &data, &rdata)) { SAMR_R_QUERY_ALIASINFO r_o; BOOL p; @@ -1131,8 +1147,7 @@ BOOL samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Set Alias Info ****************************************************************************/ -BOOL samr_set_aliasinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *alias_pol, ALIAS_INFO_CTR *ctr) +BOOL samr_set_aliasinfo( POLICY_HND *alias_pol, ALIAS_INFO_CTR *ctr) { prs_struct data; prs_struct rdata; @@ -1156,7 +1171,7 @@ BOOL samr_set_aliasinfo(struct cli_state *cli, uint16 fnum, samr_io_q_set_aliasinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_SET_ALIASINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_SET_ALIASINFO, &data, &rdata)) { SAMR_R_SET_ALIASINFO r_o; BOOL p; @@ -1186,8 +1201,7 @@ BOOL samr_set_aliasinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Open Group ****************************************************************************/ -BOOL samr_open_group(struct cli_state *cli, uint16 fnum, - const POLICY_HND *domain_pol, +BOOL samr_open_group( const POLICY_HND *domain_pol, uint32 flags, uint32 rid, POLICY_HND *group_pol) { @@ -1213,7 +1227,7 @@ BOOL samr_open_group(struct cli_state *cli, uint16 fnum, samr_io_q_open_group("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_OPEN_GROUP, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_OPEN_GROUP, &data, &rdata)) { SAMR_R_OPEN_GROUP r_o; BOOL p; @@ -1231,7 +1245,7 @@ BOOL samr_open_group(struct cli_state *cli, uint16 fnum, if (p) { memcpy(group_pol, &r_o.pol, sizeof(r_o.pol)); - valid_pol = True; + valid_pol = cli_pol_link(group_pol, domain_pol); } } @@ -1244,8 +1258,7 @@ BOOL samr_open_group(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Delete Group Member ****************************************************************************/ -BOOL samr_del_groupmem(struct cli_state *cli, uint16 fnum, - POLICY_HND *group_pol, uint32 rid) +BOOL samr_del_groupmem( POLICY_HND *group_pol, uint32 rid) { prs_struct data; prs_struct rdata; @@ -1269,7 +1282,7 @@ BOOL samr_del_groupmem(struct cli_state *cli, uint16 fnum, samr_io_q_del_groupmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_DEL_GROUPMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(group_pol, SAMR_DEL_GROUPMEM, &data, &rdata)) { SAMR_R_DEL_GROUPMEM r_o; BOOL p; @@ -1299,8 +1312,7 @@ BOOL samr_del_groupmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Add Group Member ****************************************************************************/ -BOOL samr_add_groupmem(struct cli_state *cli, uint16 fnum, - POLICY_HND *group_pol, uint32 rid) +BOOL samr_add_groupmem( POLICY_HND *group_pol, uint32 rid) { prs_struct data; prs_struct rdata; @@ -1324,7 +1336,7 @@ BOOL samr_add_groupmem(struct cli_state *cli, uint16 fnum, samr_io_q_add_groupmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_ADD_GROUPMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(group_pol, SAMR_ADD_GROUPMEM, &data, &rdata)) { SAMR_R_ADD_GROUPMEM r_o; BOOL p; @@ -1354,7 +1366,7 @@ BOOL samr_add_groupmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Delete Domain Group ****************************************************************************/ -BOOL samr_delete_dom_group(struct cli_state *cli, uint16 fnum, POLICY_HND *group_pol) +BOOL samr_delete_dom_group( POLICY_HND *group_pol) { prs_struct data; prs_struct rdata; @@ -1378,7 +1390,7 @@ BOOL samr_delete_dom_group(struct cli_state *cli, uint16 fnum, POLICY_HND *group samr_io_q_delete_dom_group("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_DELETE_DOM_GROUP, &data, &rdata)) + if (rpc_hnd_pipe_req(group_pol, SAMR_DELETE_DOM_GROUP, &data, &rdata)) { SAMR_R_DELETE_DOM_GROUP r_o; BOOL p; @@ -1408,8 +1420,7 @@ BOOL samr_delete_dom_group(struct cli_state *cli, uint16 fnum, POLICY_HND *group /**************************************************************************** do a SAMR Create Domain Group ****************************************************************************/ -BOOL samr_create_dom_group(struct cli_state *cli, uint16 fnum, - POLICY_HND *domain_pol, const char *acct_name, +BOOL samr_create_dom_group( POLICY_HND *domain_pol, const char *acct_name, POLICY_HND *group_pol, uint32 *rid) { prs_struct data; @@ -1434,7 +1445,7 @@ BOOL samr_create_dom_group(struct cli_state *cli, uint16 fnum, samr_io_q_create_dom_group("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_CREATE_DOM_GROUP, &data, &rdata)) + if (rpc_hnd_pipe_req(domain_pol, SAMR_CREATE_DOM_GROUP, &data, &rdata)) { SAMR_R_CREATE_DOM_GROUP r_o; BOOL p; @@ -1453,7 +1464,7 @@ BOOL samr_create_dom_group(struct cli_state *cli, uint16 fnum, { memcpy(group_pol, &r_o.pol, sizeof(r_o.pol)); *rid = r_o.rid; - valid_pol = True; + valid_pol = cli_pol_link(group_pol, domain_pol); } } @@ -1466,8 +1477,7 @@ BOOL samr_create_dom_group(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Set Group Info ****************************************************************************/ -BOOL samr_set_groupinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *group_pol, GROUP_INFO_CTR *ctr) +BOOL samr_set_groupinfo( POLICY_HND *group_pol, GROUP_INFO_CTR *ctr) { prs_struct data; prs_struct rdata; @@ -1491,7 +1501,7 @@ BOOL samr_set_groupinfo(struct cli_state *cli, uint16 fnum, samr_io_q_set_groupinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_SET_GROUPINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(group_pol, SAMR_SET_GROUPINFO, &data, &rdata)) { SAMR_R_SET_GROUPINFO r_o; BOOL p; @@ -1521,8 +1531,7 @@ BOOL samr_set_groupinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Open Domain ****************************************************************************/ -BOOL samr_open_domain(struct cli_state *cli, uint16 fnum, - const POLICY_HND *connect_pol, +BOOL samr_open_domain( const POLICY_HND *connect_pol, uint32 ace_perms, const DOM_SID *sid, POLICY_HND *domain_pol) @@ -1555,7 +1564,7 @@ BOOL samr_open_domain(struct cli_state *cli, uint16 fnum, samr_io_q_open_domain("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_OPEN_DOMAIN, &data, &rdata)) + if (rpc_hnd_pipe_req(connect_pol, SAMR_OPEN_DOMAIN, &data, &rdata)) { SAMR_R_OPEN_DOMAIN r_o; BOOL p; @@ -1573,7 +1582,7 @@ BOOL samr_open_domain(struct cli_state *cli, uint16 fnum, if (p) { memcpy(domain_pol, &r_o.domain_pol, sizeof(r_o.domain_pol)); - valid_pol = True; + valid_pol = cli_pol_link(domain_pol, connect_pol); } } @@ -1586,8 +1595,7 @@ BOOL samr_open_domain(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Lookup Domain ****************************************************************************/ -BOOL samr_query_lookup_domain(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, const char *dom_name, +BOOL samr_query_lookup_domain( POLICY_HND *pol, const char *dom_name, DOM_SID *dom_sid) { prs_struct data; @@ -1612,7 +1620,7 @@ BOOL samr_query_lookup_domain(struct cli_state *cli, uint16 fnum, samr_io_q_lookup_domain("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_LOOKUP_DOMAIN, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_LOOKUP_DOMAIN, &data, &rdata)) { SAMR_R_LOOKUP_DOMAIN r_o; BOOL p; @@ -1643,8 +1651,7 @@ BOOL samr_query_lookup_domain(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Lookup Names ****************************************************************************/ -BOOL samr_query_lookup_names(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint32 flags, +BOOL samr_query_lookup_names( POLICY_HND *pol, uint32 flags, uint32 num_names, char **names, uint32 *num_rids, uint32 rid[MAX_LOOKUP_SIDS], @@ -1673,7 +1680,7 @@ BOOL samr_query_lookup_names(struct cli_state *cli, uint16 fnum, samr_io_q_lookup_names("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_LOOKUP_NAMES, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_LOOKUP_NAMES, &data, &rdata)) { SAMR_R_LOOKUP_NAMES r_o; BOOL p; @@ -1728,8 +1735,7 @@ BOOL samr_query_lookup_names(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Lookup RIDS ****************************************************************************/ -BOOL samr_query_lookup_rids(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol, uint32 flags, +BOOL samr_query_lookup_rids( const POLICY_HND *pol, uint32 flags, uint32 num_rids, uint32 *rids, uint32 *num_names, char ***names, @@ -1758,7 +1764,7 @@ BOOL samr_query_lookup_rids(struct cli_state *cli, uint16 fnum, samr_io_q_lookup_rids("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_LOOKUP_RIDS, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_LOOKUP_RIDS, &data, &rdata)) { SAMR_R_LOOKUP_RIDS r_o; BOOL p; @@ -1827,8 +1833,7 @@ BOOL samr_query_lookup_rids(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Alias Members ****************************************************************************/ -BOOL samr_query_aliasmem(struct cli_state *cli, uint16 fnum, - const POLICY_HND *alias_pol, +BOOL samr_query_aliasmem( const POLICY_HND *alias_pol, uint32 *num_mem, DOM_SID2 *sid) { prs_struct data; @@ -1853,7 +1858,7 @@ BOOL samr_query_aliasmem(struct cli_state *cli, uint16 fnum, samr_io_q_query_aliasmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_ALIASMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(alias_pol, SAMR_QUERY_ALIASMEM, &data, &rdata)) { SAMR_R_QUERY_ALIASMEM r_o; BOOL p; @@ -1888,8 +1893,7 @@ BOOL samr_query_aliasmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query User Aliases ****************************************************************************/ -BOOL samr_query_useraliases(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol, +BOOL samr_query_useraliases( const POLICY_HND *pol, uint32 *ptr_sid, DOM_SID2 *sid, uint32 *num_aliases, uint32 **rid) { @@ -1916,7 +1920,7 @@ BOOL samr_query_useraliases(struct cli_state *cli, uint16 fnum, samr_io_q_query_useraliases("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_USERALIASES, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_QUERY_USERALIASES, &data, &rdata)) { SAMR_R_QUERY_USERALIASES r_o; BOOL p; @@ -1951,8 +1955,7 @@ BOOL samr_query_useraliases(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Group Members ****************************************************************************/ -BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum, - POLICY_HND *group_pol, +BOOL samr_query_groupmem( POLICY_HND *group_pol, uint32 *num_mem, uint32 **rid, uint32 **attr) { prs_struct data; @@ -1977,7 +1980,7 @@ BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum, samr_io_q_query_groupmem("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_GROUPMEM, &data, &rdata)) + if (rpc_hnd_pipe_req(group_pol, SAMR_QUERY_GROUPMEM, &data, &rdata)) { SAMR_R_QUERY_GROUPMEM r_o; BOOL p; @@ -2016,8 +2019,7 @@ BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query User Groups ****************************************************************************/ -BOOL samr_query_usergroups(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint32 *num_groups, +BOOL samr_query_usergroups( POLICY_HND *pol, uint32 *num_groups, DOM_GID **gid) { prs_struct data; @@ -2042,7 +2044,7 @@ BOOL samr_query_usergroups(struct cli_state *cli, uint16 fnum, samr_io_q_query_usergroups("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_USERGROUPS, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_QUERY_USERGROUPS, &data, &rdata)) { SAMR_R_QUERY_USERGROUPS r_o; BOOL p; @@ -2078,8 +2080,7 @@ BOOL samr_query_usergroups(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query Group Info ****************************************************************************/ -BOOL samr_query_groupinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, +BOOL samr_query_groupinfo( POLICY_HND *pol, uint16 switch_value, GROUP_INFO_CTR* ctr) { prs_struct data; @@ -2104,7 +2105,7 @@ BOOL samr_query_groupinfo(struct cli_state *cli, uint16 fnum, samr_io_q_query_groupinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_GROUPINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_QUERY_GROUPINFO, &data, &rdata)) { SAMR_R_QUERY_GROUPINFO r_o; BOOL p; @@ -2143,8 +2144,7 @@ BOOL samr_query_groupinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Set User Info ****************************************************************************/ -BOOL samr_set_userinfo2(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint16 switch_value, +BOOL samr_set_userinfo2( POLICY_HND *pol, uint16 switch_value, void* usr) { prs_struct data; @@ -2169,7 +2169,7 @@ BOOL samr_set_userinfo2(struct cli_state *cli, uint16 fnum, samr_io_q_set_userinfo2("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_SET_USERINFO2, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_SET_USERINFO2, &data, &rdata)) { SAMR_R_SET_USERINFO2 r_o; BOOL p; @@ -2199,8 +2199,7 @@ BOOL samr_set_userinfo2(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Set User Info ****************************************************************************/ -BOOL samr_set_userinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint16 switch_value, void* usr) +BOOL samr_set_userinfo( POLICY_HND *pol, uint16 switch_value, void* usr) { prs_struct data; prs_struct rdata; @@ -2224,7 +2223,7 @@ BOOL samr_set_userinfo(struct cli_state *cli, uint16 fnum, samr_io_q_set_userinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_SET_USERINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_SET_USERINFO, &data, &rdata)) { SAMR_R_SET_USERINFO r_o; BOOL p; @@ -2254,8 +2253,7 @@ BOOL samr_set_userinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Query User Info ****************************************************************************/ -BOOL samr_query_userinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol, uint16 switch_value, void* usr) +BOOL samr_query_userinfo( POLICY_HND *pol, uint16 switch_value, void* usr) { prs_struct data; prs_struct rdata; @@ -2279,7 +2277,7 @@ BOOL samr_query_userinfo(struct cli_state *cli, uint16 fnum, samr_io_q_query_userinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_USERINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(pol, SAMR_QUERY_USERINFO, &data, &rdata)) { SAMR_R_QUERY_USERINFO r_o; BOOL p; @@ -2318,7 +2316,7 @@ BOOL samr_query_userinfo(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR Close ****************************************************************************/ -BOOL samr_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) +BOOL samr_close( POLICY_HND *hnd) { prs_struct data; prs_struct rdata; @@ -2342,7 +2340,7 @@ BOOL samr_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) samr_io_q_close_hnd("", &q_c, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_CLOSE_HND, &data, &rdata)) + if (rpc_hnd_pipe_req(hnd, SAMR_CLOSE_HND, &data, &rdata)) { SAMR_R_CLOSE_HND r_c; BOOL p; @@ -2381,14 +2379,15 @@ BOOL samr_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) prs_mem_free(&data ); prs_mem_free(&rdata ); + close_policy_hnd(hnd); + return valid_close; } /**************************************************************************** do a SAMR query display info ****************************************************************************/ -BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_open_domain, uint16 level, +BOOL samr_query_dispinfo( POLICY_HND *pol_domain, uint16 level, uint32 *num_entries, SAM_DISPINFO_CTR *ctr) { @@ -2400,7 +2399,7 @@ BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum, DEBUG(4,("SAMR Query Display Info. level: %d\n", level)); - if (pol_open_domain == NULL || num_entries == NULL || ctr == NULL || + if (pol_domain == NULL || num_entries == NULL || ctr == NULL || level == 0) { return False; @@ -2412,13 +2411,13 @@ BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum, prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True ); /* store the parameters */ - make_samr_q_query_dispinfo(&q_o, pol_open_domain, level, 0, 0xffffffff); + make_samr_q_query_dispinfo(&q_o, pol_domain, level, 0, 0xffffffff); /* turn parameters into data stream */ samr_io_q_query_dispinfo("", &q_o, &data, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SAMR_QUERY_DISPINFO, &data, &rdata)) + if (rpc_hnd_pipe_req(pol_domain, SAMR_QUERY_DISPINFO, &data, &rdata)) { SAMR_R_QUERY_DISPINFO r_o; BOOL p; diff --git a/source3/rpc_client/msrpc_samr.c b/source3/rpc_client/msrpc_samr.c index d5a37832f3..8dd5201bb1 100644 --- a/source3/rpc_client/msrpc_samr.c +++ b/source3/rpc_client/msrpc_samr.c @@ -33,8 +33,7 @@ extern int DEBUGLEVEL; #define DEBUG_TESTING -BOOL req_user_info(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_dom, +BOOL req_user_info( POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, uint32 user_rid, @@ -42,7 +41,7 @@ BOOL req_user_info(struct cli_state *cli, uint16 fnum, { SAM_USER_INFO_21 usr; /* send user info query, level 0x15 */ - if (get_samr_query_userinfo(cli, fnum, + if (get_samr_query_userinfo( pol_dom, 0x15, user_rid, &usr)) { @@ -58,7 +57,7 @@ BOOL req_user_info(struct cli_state *cli, uint16 fnum, /**************************************************************************** SAM Query User Groups. ****************************************************************************/ -uint32 sam_query_usergroups(struct cli_state *cli, uint16 fnum, +uint32 sam_query_usergroups( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, @@ -73,7 +72,7 @@ uint32 sam_query_usergroups(struct cli_state *cli, uint16 fnum, uint32 num_names = 0; (*gid) = NULL; /* send user group query */ - if (get_samr_query_usergroups(cli, fnum, + if (get_samr_query_usergroups( pol_dom, user_rid, num_groups, gid) && gid != NULL) @@ -95,7 +94,7 @@ uint32 sam_query_usergroups(struct cli_state *cli, uint16 fnum, rid_mem[i] = (*gid)[i].g_rid; } - if (samr_query_lookup_rids(cli, fnum, + if (samr_query_lookup_rids( pol_dom, 0x3e8, (*num_groups), rid_mem, &num_names, name, type)) @@ -109,7 +108,7 @@ uint32 sam_query_usergroups(struct cli_state *cli, uint16 fnum, return num_names; } -static uint32 req_group_info(struct cli_state *cli, uint16 fnum, +static uint32 req_group_info( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, uint32 user_rid, const char *user_name, @@ -121,7 +120,7 @@ static uint32 req_group_info(struct cli_state *cli, uint16 fnum, char **name = NULL; uint32 *type = NULL; - num_names = sam_query_usergroups(cli, fnum, pol_dom, + num_names = sam_query_usergroups( pol_dom, domain, sid, user_rid, user_name, &num_groups, &gid, @@ -141,7 +140,7 @@ static uint32 req_group_info(struct cli_state *cli, uint16 fnum, return num_names; } -static void req_alias_info(struct cli_state *cli, uint16 fnum, +static void req_alias_info( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid1, uint32 user_rid, @@ -163,7 +162,7 @@ static void req_alias_info(struct cli_state *cli, uint16 fnum, ptr_sid[0] = 1; /* send user alias query */ - if (samr_query_useraliases(cli, fnum, + if (samr_query_useraliases( pol_dom, ptr_sid, als_sid, &num_aliases, &rid_mem)) { @@ -180,7 +179,7 @@ static void req_alias_info(struct cli_state *cli, uint16 fnum, { rid_copy[i] = rid_mem[i]; } - if (samr_query_lookup_rids(cli, fnum, + if (samr_query_lookup_rids( pol_dom, 0x3e8, num_aliases, rid_copy, &num_names, &name, &type)) @@ -219,10 +218,9 @@ static void req_alias_info(struct cli_state *cli, uint16 fnum, /**************************************************************************** experimental SAM users enum. ****************************************************************************/ -int msrpc_sam_enum_users(struct cli_state *cli, +int msrpc_sam_enum_users( const char* srv_name, const char* domain, const DOM_SID *sid1, - const char* srv_name, struct acct_info **sam, uint32 *num_sam_entries, USER_FN(usr_fn), @@ -230,7 +228,6 @@ int msrpc_sam_enum_users(struct cli_state *cli, USER_MEM_FN(usr_grp_fn), USER_MEM_FN(usr_als_fn)) { - uint16 fnum; DOM_SID sid_1_5_20; uint32 user_idx; BOOL res = True; @@ -254,22 +251,16 @@ int msrpc_sam_enum_users(struct cli_state *cli, DEBUG(5,("Number of entries:%d unk_0:%04x acb_mask:%04x unk_1:%04x\n", start_idx, unk_0, acb_mask, unk_1)); - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, - srv_name, 0x02000000, + res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; /* connect to the domain */ - res1 = res ? samr_open_domain(cli, fnum, - &sam_pol, ace_perms, sid1, + res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1, &pol_dom) : False; /* connect to the S-1-5-20 domain */ - res2 = res ? samr_open_domain(cli, fnum, - &sam_pol, ace_perms, &sid_1_5_20, + res2 = res ? samr_open_domain( &sam_pol, ace_perms, &sid_1_5_20, &pol_blt) : False; if (res1) @@ -277,7 +268,7 @@ int msrpc_sam_enum_users(struct cli_state *cli, /* read some users */ do { - status = samr_enum_dom_users(cli, fnum, + status = samr_enum_dom_users( &pol_dom, &start_idx, acb_mask, unk_1, 0x100000, sam, num_sam_entries); @@ -305,7 +296,7 @@ int msrpc_sam_enum_users(struct cli_state *cli, if (usr_inf_fn != NULL) { - req_user_info(cli, fnum, &pol_dom, + req_user_info(&pol_dom, domain, sid1, user_rid, usr_inf_fn); @@ -313,7 +304,7 @@ int msrpc_sam_enum_users(struct cli_state *cli, if (usr_grp_fn != NULL) { - req_group_info(cli, fnum, &pol_dom, + req_group_info(&pol_dom, domain, sid1, user_rid, user_name, usr_grp_fn); @@ -321,11 +312,11 @@ int msrpc_sam_enum_users(struct cli_state *cli, if (usr_als_fn != NULL) { - req_alias_info(cli, fnum, &pol_dom, + req_alias_info(&pol_dom, domain, sid1, user_rid, user_name, usr_als_fn); - req_alias_info(cli, fnum, &pol_blt, + req_alias_info(&pol_blt, domain, sid1, user_rid, user_name, usr_als_fn); @@ -333,12 +324,9 @@ int msrpc_sam_enum_users(struct cli_state *cli, } } - res2 = res2 ? samr_close(cli, fnum, &pol_blt) : False; - res1 = res1 ? samr_close(cli, fnum, &pol_dom) : False; - res = res ? samr_close(cli, fnum, &sam_pol) : False; - - /* close the session */ - cli_nt_session_close(cli, fnum); + res2 = res2 ? samr_close( &pol_blt) : False; + res1 = res1 ? samr_close( &pol_dom) : False; + res = res ? samr_close( &sam_pol) : False; if (res) { @@ -356,12 +344,10 @@ int msrpc_sam_enum_users(struct cli_state *cli, /**************************************************************************** experimental SAM domain info query. ****************************************************************************/ -BOOL sam_query_dominfo(struct cli_state *cli, +BOOL sam_query_dominfo(const char* srv_name, const DOM_SID *sid1, uint32 switch_value, SAM_UNK_CTR *ctr) { - uint16 fnum; - fstring srv_name; BOOL res = True; BOOL res1 = True; BOOL res2 = True; @@ -369,36 +355,26 @@ BOOL sam_query_dominfo(struct cli_state *cli, POLICY_HND sam_pol; POLICY_HND pol_dom; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, cli->desthost); - strupper(srv_name); - - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, + res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; /* connect to the domain */ - res1 = res ? samr_open_domain(cli, fnum, + res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1, &pol_dom) : False; /* send a samr 0x8 command */ - res2 = res ? samr_query_dom_info(cli, fnum, + res2 = res ? samr_query_dom_info( &pol_dom, switch_value, ctr) : False; - res1 = res1 ? samr_close(cli, fnum, + res1 = res1 ? samr_close( &sam_pol) : False; - res = res ? samr_close(cli, fnum, + res = res ? samr_close( &pol_dom) : False; - /* close the session */ - cli_nt_session_close(cli, fnum); - if (res2) { DEBUG(5,("sam_query_dominfo: succeeded\n")); @@ -412,7 +388,7 @@ BOOL sam_query_dominfo(struct cli_state *cli, } -BOOL query_aliasinfo(struct cli_state *cli, uint16 fnum, +BOOL query_aliasinfo( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, @@ -422,7 +398,7 @@ BOOL query_aliasinfo(struct cli_state *cli, uint16 fnum, ALIAS_INFO_CTR ctr; /* send alias info query */ - if (get_samr_query_aliasinfo(cli, fnum, + if (get_samr_query_aliasinfo( pol_dom, 3, /* info level */ alias_rid, &ctr)) @@ -436,7 +412,7 @@ BOOL query_aliasinfo(struct cli_state *cli, uint16 fnum, return False; } -BOOL sam_query_aliasmem(struct cli_state *cli, uint16 fnum, +BOOL sam_query_aliasmem(const char *srv_name, const POLICY_HND *pol_dom, uint32 alias_rid, uint32 *num_names, @@ -455,22 +431,17 @@ BOOL sam_query_aliasmem(struct cli_state *cli, uint16 fnum, *type = NULL; /* get alias members */ - res3 = get_samr_query_aliasmem(cli, fnum, + res3 = get_samr_query_aliasmem( pol_dom, alias_rid, &num_aliases, sid_mem); if (res3 && num_aliases != 0) { - fstring srv_name; POLICY_HND lsa_pol; uint32 i; uint32 numsids = 0; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, cli->desthost); - strupper(srv_name); - for (i = 0; i < num_aliases; i++) { add_sid_to_array(&numsids, sids, &sid_mem[i].sid); @@ -508,7 +479,7 @@ BOOL sam_query_aliasmem(struct cli_state *cli, uint16 fnum, return res4; } -BOOL req_aliasmem_info(struct cli_state *cli, uint16 fnum, +BOOL req_aliasmem_info(const char* srv_name, const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, @@ -521,7 +492,7 @@ BOOL req_aliasmem_info(struct cli_state *cli, uint16 fnum, uint8 *type = NULL; DOM_SID **sids = NULL; - if (sam_query_aliasmem(cli, fnum, pol_dom, alias_rid, + if (sam_query_aliasmem( srv_name, pol_dom, alias_rid, &num_names, &sids, &name, &type)) { @@ -543,7 +514,7 @@ BOOL req_aliasmem_info(struct cli_state *cli, uint16 fnum, return False; } -BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum, +BOOL sam_query_groupmem( const POLICY_HND *pol_dom, uint32 group_rid, uint32 *num_names, @@ -561,7 +532,7 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum, *type = NULL; /* get group members */ - res3 = get_samr_query_groupmem(cli, fnum, + res3 = get_samr_query_groupmem( pol_dom, group_rid, &num_mem, rid_mem, &attr_mem); @@ -578,7 +549,7 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum, rid_copy[i] = (*rid_mem)[i]; } /* resolve names */ - res3 = samr_query_lookup_rids(cli, fnum, + res3 = samr_query_lookup_rids( pol_dom, 1000, num_mem, rid_copy, num_names, name, type); } @@ -617,8 +588,7 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum, return res3; } -BOOL query_groupinfo(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol_dom, +BOOL query_groupinfo( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, uint32 group_rid, @@ -627,7 +597,7 @@ BOOL query_groupinfo(struct cli_state *cli, uint16 fnum, GROUP_INFO_CTR ctr; /* send group info query */ - if (get_samr_query_groupinfo(cli, fnum, + if (get_samr_query_groupinfo( pol_dom, 1, /* info level */ group_rid, &ctr)) @@ -641,8 +611,7 @@ BOOL query_groupinfo(struct cli_state *cli, uint16 fnum, return False; } -BOOL req_groupmem_info(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol_dom, +BOOL req_groupmem_info( const POLICY_HND *pol_dom, const char *domain, const DOM_SID *sid, uint32 group_rid, @@ -654,7 +623,7 @@ BOOL req_groupmem_info(struct cli_state *cli, uint16 fnum, uint32 *type = NULL; uint32 *rid_mem = NULL; - if (sam_query_groupmem(cli, fnum, pol_dom, group_rid, + if (sam_query_groupmem(pol_dom, group_rid, &num_names, &rid_mem, &name, &type)) { grp_mem(domain, sid, @@ -680,24 +649,18 @@ SAM Domains query. DOMAIN_INFO_FN(dom_inf_fn), DOMAIN_MEM_FN(dom_mem_fn)) ****************************************************************************/ -uint32 msrpc_sam_enum_domains(struct cli_state *cli, - const char* srv_name, +uint32 msrpc_sam_enum_domains( const char* srv_name, struct acct_info **sam, uint32 *num_sam_entries, DOMAIN_FN(dom_fn)) { - uint16 fnum; BOOL res = True; uint32 ace_perms = 0x02000000; /* access control permissions. */ POLICY_HND sam_pol; uint32 status; - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, - srv_name, ace_perms, + res = res ? samr_connect( srv_name, ace_perms, &sam_pol) : False; (*sam) = NULL; @@ -710,8 +673,7 @@ uint32 msrpc_sam_enum_domains(struct cli_state *cli, /* read some domains */ do { - status = samr_enum_domains(cli, fnum, - &sam_pol, + status = samr_enum_domains( &sam_pol, &start_idx, 0x10000, sam, num_sam_entries); @@ -736,13 +698,13 @@ uint32 msrpc_sam_enum_domains(struct cli_state *cli, #if 0 if (dom_inf_fn != NULL) { - query_domaininfo(cli, fnum, &sam_pol, + query_domaininfo(&sam_pol, domain_name, dom_inf_fn); } if (dom_mem_fn != NULL) { - req_domainmem_info(cli, fnum, &sam_pol, + req_domainmem_info(&sam_pol, domain_name, dom_mem_fn); } @@ -750,10 +712,7 @@ uint32 msrpc_sam_enum_domains(struct cli_state *cli, } } - res = res ? samr_close(cli, fnum, &sam_pol) : False; - - /* close the session */ - cli_nt_session_close(cli, fnum); + res = res ? samr_close(&sam_pol) : False; if (res) { @@ -769,34 +728,27 @@ uint32 msrpc_sam_enum_domains(struct cli_state *cli, /**************************************************************************** SAM groups query. ****************************************************************************/ -uint32 msrpc_sam_enum_groups(struct cli_state *cli, +uint32 msrpc_sam_enum_groups( const char* srv_name, const char* domain, const DOM_SID *sid1, - const char* srv_name, struct acct_info **sam, uint32 *num_sam_entries, GROUP_FN(grp_fn), GROUP_INFO_FN(grp_inf_fn), GROUP_MEM_FN(grp_mem_fn)) { - uint16 fnum; BOOL res = True; uint32 ace_perms = 0x02000000; /* access control permissions. */ POLICY_HND sam_pol; POLICY_HND pol_dom; uint32 status; - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, - srv_name, 0x02000000, + res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; /* connect to the domain */ - res = res ? samr_open_domain(cli, fnum, - &sam_pol, ace_perms, sid1, + res = res ? samr_open_domain( &sam_pol, ace_perms, sid1, &pol_dom) : False; (*sam) = NULL; @@ -809,7 +761,7 @@ uint32 msrpc_sam_enum_groups(struct cli_state *cli, /* read some groups */ do { - status = samr_enum_dom_groups(cli, fnum, + status = samr_enum_dom_groups( &pol_dom, &start_idx, 0x100000, sam, num_sam_entries); @@ -835,14 +787,14 @@ uint32 msrpc_sam_enum_groups(struct cli_state *cli, if (grp_inf_fn != NULL) { - query_groupinfo(cli, fnum, &pol_dom, + query_groupinfo(&pol_dom, domain, sid1, group_rid, grp_inf_fn); } if (grp_mem_fn != NULL) { - req_groupmem_info(cli, fnum, &pol_dom, + req_groupmem_info(&pol_dom, domain, sid1, group_rid, group_name, grp_mem_fn); @@ -850,11 +802,8 @@ uint32 msrpc_sam_enum_groups(struct cli_state *cli, } } - res = res ? samr_close(cli, fnum, &pol_dom) : False; - res = res ? samr_close(cli, fnum, &sam_pol) : False; - - /* close the session */ - cli_nt_session_close(cli, fnum); + res = res ? samr_close(&pol_dom) : False; + res = res ? samr_close(&sam_pol) : False; if (res) { @@ -870,33 +819,27 @@ uint32 msrpc_sam_enum_groups(struct cli_state *cli, /**************************************************************************** SAM aliases query. ****************************************************************************/ -uint32 msrpc_sam_enum_aliases(struct cli_state *cli, +uint32 msrpc_sam_enum_aliases( const char* srv_name, const char* domain, const DOM_SID *sid1, - const char* srv_name, struct acct_info **sam, uint32 *num_sam_entries, ALIAS_FN(als_fn), ALIAS_INFO_FN(als_inf_fn), ALIAS_MEM_FN(als_mem_fn)) { - uint16 fnum; BOOL res = True; uint32 ace_perms = 0x02000000; /* access control permissions */ POLICY_HND sam_pol; POLICY_HND pol_dom; uint32 status = 0x0; - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, - srv_name, 0x02000000, + res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; /* connect to the domain */ - res = res ? samr_open_domain(cli, fnum, + res = res ? samr_open_domain( &sam_pol, ace_perms, sid1, &pol_dom) : False; @@ -910,7 +853,7 @@ uint32 msrpc_sam_enum_aliases(struct cli_state *cli, /* read some groups */ do { - status = samr_enum_dom_aliases(cli, fnum, + status = samr_enum_dom_aliases( &pol_dom, &start_idx, 0x100000, sam, num_sam_entries); @@ -936,14 +879,14 @@ uint32 msrpc_sam_enum_aliases(struct cli_state *cli, if (als_inf_fn != NULL) { - query_aliasinfo(cli, fnum, &pol_dom, + query_aliasinfo(&pol_dom, domain, sid1, alias_rid, als_inf_fn); } if (als_mem_fn != NULL) { - req_aliasmem_info(cli, fnum, &pol_dom, + req_aliasmem_info(srv_name, &pol_dom, domain, sid1, alias_rid, alias_name, als_mem_fn); @@ -951,11 +894,8 @@ uint32 msrpc_sam_enum_aliases(struct cli_state *cli, } } - res = res ? samr_close(cli, fnum, &sam_pol) : False; - res = res ? samr_close(cli, fnum, &pol_dom) : False; - - /* close the session */ - cli_nt_session_close(cli, fnum); + res = res ? samr_close(&sam_pol) : False; + res = res ? samr_close(&pol_dom) : False; if (res) { @@ -972,8 +912,7 @@ uint32 msrpc_sam_enum_aliases(struct cli_state *cli, /**************************************************************************** do a SAMR create domain user ****************************************************************************/ -BOOL create_samr_domain_user(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_open_domain, +BOOL create_samr_domain_user( POLICY_HND *pol_open_domain, const char *acct_name, uint16 acb_info, uint32 *rid) { @@ -983,8 +922,7 @@ BOOL create_samr_domain_user(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || acct_name == NULL) return False; /* send create user */ - if (!samr_create_dom_user(cli, fnum, - pol_open_domain, + if (!samr_create_dom_user( pol_open_domain, acct_name, acb_info, 0xe005000b, &pol_open_user, rid)) { @@ -994,14 +932,13 @@ BOOL create_samr_domain_user(struct cli_state *cli, uint16 fnum, DEBUG(5,("create_samr_domain_user: name: %s rid 0x%x\n", acct_name, *rid)); - return samr_close(cli, fnum, &pol_open_user) && ret; + return samr_close(&pol_open_user) && ret; } /**************************************************************************** do a SAMR create domain alias ****************************************************************************/ -BOOL create_samr_domain_alias(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_open_domain, +BOOL create_samr_domain_alias( POLICY_HND *pol_open_domain, const char *acct_name, const char *acct_desc, uint32 *rid) { @@ -1012,7 +949,7 @@ BOOL create_samr_domain_alias(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False; /* send create alias */ - if (!samr_create_dom_alias(cli, fnum, + if (!samr_create_dom_alias( pol_open_domain, acct_name, &pol_open_alias, rid)) @@ -1027,7 +964,7 @@ BOOL create_samr_domain_alias(struct cli_state *cli, uint16 fnum, make_samr_alias_info3(&ctr.alias.info3, acct_desc); /* send set alias info */ - if (!samr_set_aliasinfo(cli, fnum, + if (!samr_set_aliasinfo( &pol_open_alias, &ctr)) { @@ -1035,13 +972,13 @@ BOOL create_samr_domain_alias(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_alias) && ret; + return samr_close(&pol_open_alias) && ret; } /**************************************************************************** do a SAMR create domain group ****************************************************************************/ -BOOL create_samr_domain_group(struct cli_state *cli, uint16 fnum, +BOOL create_samr_domain_group( POLICY_HND *pol_open_domain, const char *acct_name, const char *acct_desc, uint32 *rid) @@ -1053,7 +990,7 @@ BOOL create_samr_domain_group(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False; /* send create group*/ - if (!samr_create_dom_group(cli, fnum, + if (!samr_create_dom_group( pol_open_domain, acct_name, &pol_open_group, rid)) @@ -1069,7 +1006,7 @@ BOOL create_samr_domain_group(struct cli_state *cli, uint16 fnum, make_samr_group_info4(&ctr.group.info4, acct_desc); /* send user groups query */ - if (!samr_set_groupinfo(cli, fnum, + if (!samr_set_groupinfo( &pol_open_group, &ctr)) { @@ -1077,14 +1014,13 @@ BOOL create_samr_domain_group(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_group) && ret; + return samr_close(&pol_open_group) && ret; } /**************************************************************************** do a SAMR query user groups ****************************************************************************/ -BOOL get_samr_query_usergroups(struct cli_state *cli, uint16 fnum, - const POLICY_HND *pol_open_domain, +BOOL get_samr_query_usergroups( const POLICY_HND *pol_open_domain, uint32 user_rid, uint32 *num_groups, DOM_GID **gid) { @@ -1094,7 +1030,7 @@ BOOL get_samr_query_usergroups(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || num_groups == NULL || gid == NULL) return False; /* send open domain (on user sid) */ - if (!samr_open_user(cli, fnum, + if (!samr_open_user( pol_open_domain, 0x02011b, user_rid, &pol_open_user)) @@ -1103,7 +1039,7 @@ BOOL get_samr_query_usergroups(struct cli_state *cli, uint16 fnum, } /* send user groups query */ - if (!samr_query_usergroups(cli, fnum, + if (!samr_query_usergroups( &pol_open_user, num_groups, gid)) { @@ -1111,13 +1047,13 @@ BOOL get_samr_query_usergroups(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_user) && ret; + return samr_close(&pol_open_user) && ret; } /**************************************************************************** do a SAMR delete group ****************************************************************************/ -BOOL delete_samr_dom_group(struct cli_state *cli, uint16 fnum, +BOOL delete_samr_dom_group( POLICY_HND *pol_open_domain, uint32 group_rid) { @@ -1126,7 +1062,7 @@ BOOL delete_samr_dom_group(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL) return False; /* send open domain (on group rid) */ - if (!samr_open_group(cli, fnum,pol_open_domain, + if (!samr_open_group(pol_open_domain, 0x00000010, group_rid, &pol_open_group)) { @@ -1134,11 +1070,11 @@ BOOL delete_samr_dom_group(struct cli_state *cli, uint16 fnum, } /* send group delete */ - if (!samr_delete_dom_group(cli, fnum,&pol_open_group)) + if (!samr_delete_dom_group(&pol_open_group)) { DEBUG(5,("delete_samr_dom_group: error in delete domain group\n")); - samr_close(cli, fnum,&pol_open_group); + samr_close(&pol_open_group); return False; } @@ -1149,7 +1085,7 @@ BOOL delete_samr_dom_group(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR query group members ****************************************************************************/ -BOOL get_samr_query_groupmem(struct cli_state *cli, uint16 fnum, +BOOL get_samr_query_groupmem( const POLICY_HND *pol_open_domain, uint32 group_rid, uint32 *num_mem, uint32 **rid, uint32 **attr) @@ -1160,7 +1096,7 @@ BOOL get_samr_query_groupmem(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || num_mem == NULL || rid == NULL || attr == NULL) return False; /* send open domain (on group sid) */ - if (!samr_open_group(cli, fnum, pol_open_domain, + if (!samr_open_group( pol_open_domain, 0x00000010, group_rid, &pol_open_group)) { @@ -1168,20 +1104,20 @@ BOOL get_samr_query_groupmem(struct cli_state *cli, uint16 fnum, } /* send group info query */ - if (!samr_query_groupmem(cli, fnum,&pol_open_group, num_mem, rid, attr)) + if (!samr_query_groupmem(&pol_open_group, num_mem, rid, attr)) { DEBUG(5,("samr_query_group: error in query group members\n")); ret = False; } - return samr_close(cli, fnum,&pol_open_group) && ret; + return samr_close(&pol_open_group) && ret; } /**************************************************************************** do a SAMR delete alias ****************************************************************************/ -BOOL delete_samr_dom_alias(struct cli_state *cli, uint16 fnum, +BOOL delete_samr_dom_alias( POLICY_HND *pol_open_domain, uint32 alias_rid) { @@ -1190,18 +1126,18 @@ BOOL delete_samr_dom_alias(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL) return False; /* send open domain (on alias rid) */ - if (!samr_open_alias(cli, fnum,pol_open_domain, + if (!samr_open_alias(pol_open_domain, 0x000f001f, alias_rid, &pol_open_alias)) { return False; } /* send alias delete */ - if (!samr_delete_dom_alias(cli, fnum,&pol_open_alias)) + if (!samr_delete_dom_alias(&pol_open_alias)) { DEBUG(5,("delete_samr_dom_alias: error in delete domain alias\n")); - samr_close(cli, fnum,&pol_open_alias); + samr_close(&pol_open_alias); return False; } @@ -1212,7 +1148,7 @@ BOOL delete_samr_dom_alias(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SAMR query alias members ****************************************************************************/ -BOOL get_samr_query_aliasmem(struct cli_state *cli, uint16 fnum, +BOOL get_samr_query_aliasmem( const POLICY_HND *pol_open_domain, uint32 alias_rid, uint32 *num_mem, DOM_SID2 *sid) { @@ -1222,7 +1158,7 @@ BOOL get_samr_query_aliasmem(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || num_mem == NULL || sid == NULL) return False; /* send open domain (on alias sid) */ - if (!samr_open_alias(cli, fnum, pol_open_domain, + if (!samr_open_alias( pol_open_domain, 0x000f001f, alias_rid, &pol_open_alias)) { @@ -1230,20 +1166,20 @@ BOOL get_samr_query_aliasmem(struct cli_state *cli, uint16 fnum, } /* send alias info query */ - if (!samr_query_aliasmem(cli, fnum, &pol_open_alias, num_mem, sid)) + if (!samr_query_aliasmem( &pol_open_alias, num_mem, sid)) { DEBUG(5,("samr_query_alias: error in query alias members\n")); ret = False; } - return samr_close(cli, fnum,&pol_open_alias) && ret; + return samr_close(&pol_open_alias) && ret; } /**************************************************************************** do a SAMR set user info ****************************************************************************/ -BOOL set_samr_set_userinfo2(struct cli_state *cli, uint16 fnum, +BOOL set_samr_set_userinfo2( POLICY_HND *pol_open_domain, uint32 info_level, uint32 user_rid, void *usr) @@ -1254,7 +1190,7 @@ BOOL set_samr_set_userinfo2(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || usr == NULL) return False; /* send open domain (on user sid) */ - if (!samr_open_user(cli, fnum, + if (!samr_open_user( pol_open_domain, 0x000601b4, user_rid, &pol_open_user)) @@ -1263,7 +1199,7 @@ BOOL set_samr_set_userinfo2(struct cli_state *cli, uint16 fnum, } /* send user info query */ - if (!samr_set_userinfo2(cli, fnum, + if (!samr_set_userinfo2( &pol_open_user, info_level, usr)) { @@ -1272,13 +1208,13 @@ BOOL set_samr_set_userinfo2(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_user) && ret; + return samr_close(&pol_open_user) && ret; } /**************************************************************************** do a SAMR set user info ****************************************************************************/ -BOOL set_samr_set_userinfo(struct cli_state *cli, uint16 fnum, +BOOL set_samr_set_userinfo( POLICY_HND *pol_open_domain, uint32 info_level, uint32 user_rid, void *usr) @@ -1289,7 +1225,7 @@ BOOL set_samr_set_userinfo(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || usr == NULL) return False; /* send open domain (on user sid) */ - if (!samr_open_user(cli, fnum, + if (!samr_open_user( pol_open_domain, 0x000601b4, user_rid, &pol_open_user)) @@ -1298,7 +1234,7 @@ BOOL set_samr_set_userinfo(struct cli_state *cli, uint16 fnum, } /* send user info query */ - if (!samr_set_userinfo(cli, fnum, + if (!samr_set_userinfo( &pol_open_user, info_level, usr)) { @@ -1307,13 +1243,13 @@ BOOL set_samr_set_userinfo(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_user) && ret; + return samr_close(&pol_open_user) && ret; } /**************************************************************************** do a SAMR query user info ****************************************************************************/ -BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum, +BOOL get_samr_query_userinfo( POLICY_HND *pol_open_domain, uint32 info_level, uint32 user_rid, void *usr) @@ -1324,7 +1260,7 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum, if (pol_open_domain == NULL || usr == NULL) return False; /* send open domain (on user sid) */ - if (!samr_open_user(cli, fnum, + if (!samr_open_user( pol_open_domain, 0x02011b, user_rid, &pol_open_user)) @@ -1333,7 +1269,7 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum, } /* send user info query */ - if (!samr_query_userinfo(cli, fnum, + if (!samr_query_userinfo( &pol_open_user, info_level, usr)) { @@ -1342,13 +1278,13 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_user) && ret; + return samr_close(&pol_open_user) && ret; } /**************************************************************************** do a SAMR query group info ****************************************************************************/ -BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum, +BOOL get_samr_query_groupinfo( const POLICY_HND *pol_open_domain, uint32 info_level, uint32 group_rid, GROUP_INFO_CTR *ctr) @@ -1361,7 +1297,7 @@ BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum, bzero(ctr, sizeof(*ctr)); /* send open domain (on group sid) */ - if (!samr_open_group(cli, fnum, + if (!samr_open_group( pol_open_domain, 0x02000000, group_rid, &pol_open_group)) { @@ -1369,7 +1305,7 @@ BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum, } /* send group info query */ - if (!samr_query_groupinfo(cli, fnum, + if (!samr_query_groupinfo( &pol_open_group, info_level, ctr)) { @@ -1378,13 +1314,13 @@ BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_group) && ret; + return samr_close(&pol_open_group) && ret; } /**************************************************************************** do a SAMR query alias info ****************************************************************************/ -BOOL get_samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, +BOOL get_samr_query_aliasinfo( const POLICY_HND *pol_open_domain, uint32 info_level, uint32 alias_rid, ALIAS_INFO_CTR *ctr) @@ -1397,7 +1333,7 @@ BOOL get_samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, bzero(ctr, sizeof(*ctr)); /* send open domain (on alias sid) */ - if (!samr_open_alias(cli, fnum, + if (!samr_open_alias( pol_open_domain, 0x02000000, alias_rid, &pol_open_alias)) { @@ -1405,7 +1341,7 @@ BOOL get_samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, } /* send alias info query */ - if (!samr_query_aliasinfo(cli, fnum, + if (!samr_query_aliasinfo( &pol_open_alias, info_level, ctr)) { @@ -1414,18 +1350,16 @@ BOOL get_samr_query_aliasinfo(struct cli_state *cli, uint16 fnum, ret = False; } - return samr_close(cli, fnum,&pol_open_alias) && ret; + return samr_close(&pol_open_alias) && ret; } /**************************************************************************** SAM create domain user. ****************************************************************************/ -BOOL msrpc_sam_create_dom_user(struct cli_state *cli, DOM_SID *sid1, +BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1, char *acct_name, uint16 acb_info, uint32 *rid) { - uint16 fnum; - fstring srv_name; BOOL res = True; BOOL res1 = True; BOOL res2 = True; @@ -1434,33 +1368,23 @@ BOOL msrpc_sam_create_dom_user(struct cli_state *cli, DOM_SID *sid1, POLICY_HND sam_pol; POLICY_HND pol_dom; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, cli->desthost); - strupper(srv_name); - - /* open SAMR session. negotiate credentials */ - res = res ? cli_nt_session_open(cli, PIPE_SAMR, &fnum) : False; - /* establish a connection. */ - res = res ? samr_connect(cli, fnum, + res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; /* connect to the domain */ - res1 = res ? samr_open_domain(cli, fnum, + res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1, &pol_dom) : False; /* create a domain user */ - res2 = res1 ? create_samr_domain_user(cli, fnum, + res2 = res1 ? create_samr_domain_user( &pol_dom, acct_name, acb_info, &user_rid) : False; - res1 = res1 ? samr_close(cli, fnum, &pol_dom) : False; - res = res ? samr_close(cli, fnum, &sam_pol) : False; - - /* close the session */ - cli_nt_session_close(cli, fnum); + res1 = res1 ? samr_close( &pol_dom) : False; + res = res ? samr_close( &sam_pol) : False; if (res2) { |