diff options
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_ds.c | 138 | ||||
-rw-r--r-- | source3/rpc_client/cli_lsarpc.c | 262 | ||||
-rw-r--r-- | source3/rpc_client/cli_netlogon.c | 127 | ||||
-rw-r--r-- | source3/rpc_client/cli_pipe.c | 11 | ||||
-rw-r--r-- | source3/rpc_client/cli_samr.c | 500 |
5 files changed, 24 insertions, 1014 deletions
diff --git a/source3/rpc_client/cli_ds.c b/source3/rpc_client/cli_ds.c deleted file mode 100644 index 71516b89f2..0000000000 --- a/source3/rpc_client/cli_ds.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - Unix SMB/CIFS implementation. - RPC pipe client - Copyright (C) Gerald Carter 2002, - Copyright (C) Jeremy Allison 2005. - - 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 - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" - -/* implementations of client side DsXXX() functions */ - -/******************************************************************** - Get information about the server and directory services -********************************************************************/ - -NTSTATUS rpccli_ds_getprimarydominfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint16 level, DS_DOMINFO_CTR *ctr) -{ - prs_struct qbuf, rbuf; - DS_Q_GETPRIMDOMINFO q; - DS_R_GETPRIMDOMINFO r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - q.level = level; - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC_DS, DS_GETPRIMDOMINFO, - q, r, - qbuf, rbuf, - ds_io_q_getprimdominfo, - ds_io_r_getprimdominfo, - NT_STATUS_UNSUCCESSFUL); - - /* Return basic info - if we are requesting at info != 1 then - there could be trouble. */ - - result = r.status; - - if ( r.ptr && ctr ) { - ctr->basic = TALLOC_P(mem_ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC); - if (!ctr->basic) - goto done; - memcpy(ctr->basic, r.info.basic, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC)); - } - -done: - - return result; -} - -/******************************************************************** - Enumerate trusted domains in an AD forest -********************************************************************/ - -NTSTATUS rpccli_ds_enum_domain_trusts(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server, uint32 flags, - struct ds_domain_trust **trusts, - uint32 *num_domains) -{ - prs_struct qbuf, rbuf; - DS_Q_ENUM_DOM_TRUSTS q; - DS_R_ENUM_DOM_TRUSTS r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - init_q_ds_enum_domain_trusts( &q, server, flags ); - - CLI_DO_RPC( cli, mem_ctx, PI_NETLOGON, DS_ENUM_DOM_TRUSTS, - q, r, - qbuf, rbuf, - ds_io_q_enum_domain_trusts, - ds_io_r_enum_domain_trusts, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if ( NT_STATUS_IS_OK(result) ) { - int i; - - *num_domains = r.num_domains; - if (r.num_domains) { - *trusts = TALLOC_ARRAY(mem_ctx, struct ds_domain_trust, r.num_domains); - - if (*trusts == NULL) { - return NT_STATUS_NO_MEMORY; - } - } else { - *trusts = NULL; - } - - for ( i=0; i< *num_domains; i++ ) { - (*trusts)[i].flags = r.domains.trusts[i].flags; - (*trusts)[i].parent_index = r.domains.trusts[i].parent_index; - (*trusts)[i].trust_type = r.domains.trusts[i].trust_type; - (*trusts)[i].trust_attributes = r.domains.trusts[i].trust_attributes; - (*trusts)[i].guid = r.domains.trusts[i].guid; - - if (r.domains.trusts[i].sid_ptr) { - sid_copy(&(*trusts)[i].sid, &r.domains.trusts[i].sid.sid); - } else { - ZERO_STRUCT((*trusts)[i].sid); - } - - if (r.domains.trusts[i].netbios_ptr) { - (*trusts)[i].netbios_domain = unistr2_to_ascii_talloc( mem_ctx, &r.domains.trusts[i].netbios_domain ); - } else { - (*trusts)[i].netbios_domain = NULL; - } - - if (r.domains.trusts[i].dns_ptr) { - (*trusts)[i].dns_domain = unistr2_to_ascii_talloc( mem_ctx, &r.domains.trusts[i].dns_domain ); - } else { - (*trusts)[i].dns_domain = NULL; - } - } - } - - return result; -} diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 6abc67fc35..286cc210e2 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -542,7 +542,8 @@ NTSTATUS rpccli_lsa_query_info_policy2_new(struct rpc_pipe_client *cli, TALLOC_C NTSTATUS rpccli_lsa_query_info_policy(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *pol, uint16 info_class, - char **domain_name, DOM_SID **domain_sid) + const char **domain_name, + DOM_SID **domain_sid) { prs_struct qbuf, rbuf; LSA_Q_QUERY_INFO q; @@ -632,8 +633,9 @@ NTSTATUS rpccli_lsa_query_info_policy(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_query_info_policy2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *pol, uint16 info_class, - char **domain_name, char **dns_name, - char **forest_name, + const char **domain_name, + const char **dns_name, + const char **forest_name, struct GUID **domain_guid, DOM_SID **domain_sid) { @@ -716,41 +718,6 @@ NTSTATUS rpccli_lsa_query_info_policy2(struct rpc_pipe_client *cli, return result; } -NTSTATUS rpccli_lsa_set_info_policy(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, uint16 info_class, - LSA_INFO_CTR ctr) -{ - prs_struct qbuf, rbuf; - LSA_Q_SET_INFO q; - LSA_R_SET_INFO r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - init_q_set(&q, pol, info_class, ctr); - - CLI_DO_RPC(cli, mem_ctx, PI_LSARPC, LSA_SETINFOPOLICY, - q, r, - qbuf, rbuf, - lsa_io_q_set, - lsa_io_r_set, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Return output parameters */ - - done: - - return result; -} - - /** * Enumerate list of trusted domains * @@ -1468,222 +1435,3 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); } #endif - -NTSTATUS rpccli_lsa_open_trusted_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, DOM_SID *dom_sid, uint32 access_mask, - POLICY_HND *trustdom_pol) -{ - prs_struct qbuf, rbuf; - LSA_Q_OPEN_TRUSTED_DOMAIN q; - LSA_R_OPEN_TRUSTED_DOMAIN r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - init_lsa_q_open_trusted_domain(&q, pol, dom_sid, access_mask); - - /* Marshall data and send request */ - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_OPENTRUSTDOM, - q, r, - qbuf, rbuf, - lsa_io_q_open_trusted_domain, - lsa_io_r_open_trusted_domain, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - *trustdom_pol = r.handle; - } - - return result; -} - -NTSTATUS rpccli_lsa_query_trusted_domain_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, - uint16 info_class, - LSA_TRUSTED_DOMAIN_INFO **info) -{ - prs_struct qbuf, rbuf; - LSA_Q_QUERY_TRUSTED_DOMAIN_INFO q; - LSA_R_QUERY_TRUSTED_DOMAIN_INFO r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_q_query_trusted_domain_info(&q, pol, info_class); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFO, - q, r, - qbuf, rbuf, - lsa_io_q_query_trusted_domain_info, - lsa_io_r_query_trusted_domain_info, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - *info = r.info; - -done: - return result; -} - -NTSTATUS rpccli_lsa_open_trusted_domain_by_name(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, const char *name, uint32 access_mask, - POLICY_HND *trustdom_pol) -{ - prs_struct qbuf, rbuf; - LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME q; - LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - init_lsa_q_open_trusted_domain_by_name(&q, pol, name, access_mask); - - /* Marshall data and send request */ - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_OPENTRUSTDOMBYNAME, - q, r, - qbuf, rbuf, - lsa_io_q_open_trusted_domain_by_name, - lsa_io_r_open_trusted_domain_by_name, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - *trustdom_pol = r.handle; - } - - return result; -} - - -NTSTATUS rpccli_lsa_query_trusted_domain_info_by_sid(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, - uint16 info_class, DOM_SID *dom_sid, - LSA_TRUSTED_DOMAIN_INFO **info) -{ - prs_struct qbuf, rbuf; - LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID q; - LSA_R_QUERY_TRUSTED_DOMAIN_INFO r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_q_query_trusted_domain_info_by_sid(&q, pol, info_class, dom_sid); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFOBYSID, - q, r, - qbuf, rbuf, - lsa_io_q_query_trusted_domain_info_by_sid, - lsa_io_r_query_trusted_domain_info, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - *info = r.info; - -done: - - return result; -} - -NTSTATUS rpccli_lsa_query_trusted_domain_info_by_name(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, - uint16 info_class, const char *domain_name, - LSA_TRUSTED_DOMAIN_INFO **info) -{ - prs_struct qbuf, rbuf; - LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME q; - LSA_R_QUERY_TRUSTED_DOMAIN_INFO r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_q_query_trusted_domain_info_by_name(&q, pol, info_class, domain_name); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFOBYNAME, - q, r, - qbuf, rbuf, - lsa_io_q_query_trusted_domain_info_by_name, - lsa_io_r_query_trusted_domain_info, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - *info = r.info; - -done: - - return result; -} - -NTSTATUS cli_lsa_query_domain_info_policy(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, - uint16 info_class, LSA_DOM_INFO_UNION **info) -{ - prs_struct qbuf, rbuf; - LSA_Q_QUERY_DOM_INFO_POLICY q; - LSA_R_QUERY_DOM_INFO_POLICY r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_q_query_dom_info(&q, pol, info_class); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYDOMINFOPOL, - q, r, - qbuf, rbuf, - lsa_io_q_query_dom_info, - lsa_io_r_query_dom_info, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - *info = r.info; - -done: - return result; -} - diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 3cb5827e73..54c6c7f23e 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -383,7 +383,7 @@ NTSTATUS rpccli_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, TALLOC_CTX *me WERROR rpccli_netlogon_getanydcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *mydcname, - const char *domainname, fstring newdcname) + const char *domainname, char **newdcname) { prs_struct qbuf, rbuf; NET_Q_GETANYDCNAME q; @@ -410,8 +410,9 @@ WERROR rpccli_netlogon_getanydcname(struct rpc_pipe_client *cli, result = r.status; - if (W_ERROR_IS_OK(result)) { - rpcstr_pull_unistr2_fstring(newdcname, &r.uni_dcname); + if (W_ERROR_IS_OK(result) && newdcname) { + *newdcname = rpcstr_pull_unistr2_talloc(mem_ctx, &r.uni_dcname); + W_ERROR_HAVE_NO_MEMORY(*newdcname); } return result; @@ -421,7 +422,7 @@ WERROR rpccli_netlogon_getanydcname(struct rpc_pipe_client *cli, WERROR rpccli_netlogon_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *mydcname, - const char *domainname, fstring newdcname) + const char *domainname, char **newdcname) { prs_struct qbuf, rbuf; NET_Q_GETDCNAME q; @@ -448,8 +449,9 @@ WERROR rpccli_netlogon_getdcname(struct rpc_pipe_client *cli, result = r.status; - if (W_ERROR_IS_OK(result)) { - rpcstr_pull_unistr2_fstring(newdcname, &r.uni_dcname); + if (W_ERROR_IS_OK(result) && newdcname) { + *newdcname = rpcstr_pull_unistr2_talloc(mem_ctx, &r.uni_dcname); + W_ERROR_HAVE_NO_MEMORY(*newdcname); } return result; @@ -591,109 +593,6 @@ WERROR rpccli_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, return WERR_OK; } -/* Dsr_GetDCNameEx */ - -WERROR rpccli_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *domain_name, - struct GUID *domain_guid, - const char *site_name, - uint32_t flags, - struct DS_DOMAIN_CONTROLLER_INFO **info_out) -{ - prs_struct qbuf, rbuf; - NET_Q_DSR_GETDCNAMEEX q; - NET_R_DSR_GETDCNAME r; - char *tmp_str; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialize input parameters */ - - tmp_str = talloc_asprintf(mem_ctx, "\\\\%s", server_name); - if (tmp_str == NULL) { - return WERR_NOMEM; - } - - init_net_q_dsr_getdcnameex(&q, server_name, domain_name, domain_guid, - site_name, flags); - - /* Marshall data and send request */ - - CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_DSR_GETDCNAMEEX, - q, r, - qbuf, rbuf, - net_io_q_dsr_getdcnameex, - net_io_r_dsr_getdcname, - WERR_GENERAL_FAILURE); - - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - r.result = pull_domain_controller_info_from_getdcname_reply(mem_ctx, info_out, &r); - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - return WERR_OK; -} - -/* Dsr_GetDCNameEx */ - -WERROR rpccli_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *client_account, - uint32 mask, - const char *domain_name, - struct GUID *domain_guid, - const char *site_name, - uint32_t flags, - struct DS_DOMAIN_CONTROLLER_INFO **info_out) -{ - prs_struct qbuf, rbuf; - NET_Q_DSR_GETDCNAMEEX2 q; - NET_R_DSR_GETDCNAME r; - char *tmp_str; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialize input parameters */ - - tmp_str = talloc_asprintf(mem_ctx, "\\\\%s", server_name); - if (tmp_str == NULL) { - return WERR_NOMEM; - } - - init_net_q_dsr_getdcnameex2(&q, server_name, domain_name, client_account, - mask, domain_guid, site_name, flags); - - /* Marshall data and send request */ - - CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_DSR_GETDCNAMEEX2, - q, r, - qbuf, rbuf, - net_io_q_dsr_getdcnameex2, - net_io_r_dsr_getdcname, - WERR_GENERAL_FAILURE); - - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - r.result = pull_domain_controller_info_from_getdcname_reply(mem_ctx, info_out, &r); - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - return WERR_OK; -} - - /* Dsr_GetSiteName */ WERROR rpccli_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, @@ -976,11 +875,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, int validation_level = 3; const char *workstation_name_slash; const char *server_name_slash; - static uint8 zeros[16]; + uint8 zeros[16]; DOM_CRED clnt_creds; DOM_CRED ret_creds; int i; - + + ZERO_STRUCT(zeros); ZERO_STRUCT(q); ZERO_STRUCT(r); ZERO_STRUCT(ret_creds); @@ -1082,9 +982,10 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, int validation_level = 3; const char *workstation_name_slash; const char *server_name_slash; - static uint8 zeros[16]; + uint8 zeros[16]; int i; - + + ZERO_STRUCT(zeros); ZERO_STRUCT(q); ZERO_STRUCT(r); diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index f61ea95d04..40d0ac5da9 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -2263,7 +2263,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe *perr = rpc_pipe_bind(result, PIPE_AUTH_TYPE_NONE, PIPE_AUTH_LEVEL_NONE); if (!NT_STATUS_IS_OK(*perr)) { int lvl = 0; - if (pipe_idx == PI_LSARPC_DS) { + if (pipe_idx == PI_DSSETUP) { /* non AD domains just don't have this pipe, avoid * level 0 statement in that case - gd */ lvl = 3; @@ -2364,8 +2364,8 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta goto err; } - DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to machine %s and" - "bound NTLMSSP as user %s\\%s.\n", + DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to " + "machine %s and bound NTLMSSP as user %s\\%s.\n", result->pipe_name, cli->desthost, domain, username )); @@ -2466,7 +2466,6 @@ static bool get_schannel_session_key_common(struct rpc_pipe_client *netlogon_pip if (((*pneg_flags) & NETLOGON_NEG_SCHANNEL) == 0) { DEBUG(3, ("get_schannel_session_key: Server %s did not offer schannel\n", cli->desthost)); - cli_rpc_pipe_close(netlogon_pipe); *perr = NT_STATUS_INVALID_NETWORK_RESPONSE; return false; } @@ -2597,7 +2596,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state const char *password, NTSTATUS *perr) { - uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; + uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; struct rpc_pipe_client *netlogon_pipe = NULL; struct rpc_pipe_client *result = NULL; @@ -2631,7 +2630,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel(struct cli_state *cli, const char *domain, NTSTATUS *perr) { - uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; + uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; struct rpc_pipe_client *netlogon_pipe = NULL; struct rpc_pipe_client *result = NULL; diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c index bf8313816c..fa1e5a645b 100644 --- a/source3/rpc_client/cli_samr.c +++ b/source3/rpc_client/cli_samr.c @@ -95,201 +95,6 @@ NTSTATUS rpccli_samr_connect4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return result; } -/* Close SAMR handle */ - -NTSTATUS rpccli_samr_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *connect_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_CLOSE_HND q; - SAMR_R_CLOSE_HND r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_close\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_close_hnd(&q, connect_pol); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CLOSE_HND, - q, r, - qbuf, rbuf, - samr_io_q_close_hnd, - samr_io_r_close_hnd, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { -#ifdef __INSURE__ - SAFE_FREE(connect_pol->marker); -#endif - *connect_pol = r.pol; - } - - return result; -} - -/* Open handle on a domain */ - -NTSTATUS rpccli_samr_open_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *connect_pol, uint32 access_mask, - const DOM_SID *domain_sid, - POLICY_HND *domain_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_OPEN_DOMAIN q; - SAMR_R_OPEN_DOMAIN r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_open_domain with sid %s\n", - sid_string_dbg(domain_sid) )); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_open_domain(&q, connect_pol, access_mask, domain_sid); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_DOMAIN, - q, r, - qbuf, rbuf, - samr_io_q_open_domain, - samr_io_r_open_domain, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { - *domain_pol = r.domain_pol; -#ifdef __INSURE__ - domain_pol->marker = malloc(1); -#endif - } - - return result; -} - -NTSTATUS rpccli_samr_open_user(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, uint32 access_mask, - uint32 user_rid, POLICY_HND *user_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_OPEN_USER q; - SAMR_R_OPEN_USER r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_open_user with rid 0x%x\n", user_rid )); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_open_user(&q, domain_pol, access_mask, user_rid); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_USER, - q, r, - qbuf, rbuf, - samr_io_q_open_user, - samr_io_r_open_user, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { - *user_pol = r.user_pol; -#ifdef __INSURE__ - user_pol->marker = malloc(1); -#endif - } - - return result; -} - -/* Open handle on a group */ - -NTSTATUS rpccli_samr_open_group(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, uint32 access_mask, - uint32 group_rid, POLICY_HND *group_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_OPEN_GROUP q; - SAMR_R_OPEN_GROUP r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_open_group with rid 0x%x\n", group_rid )); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_open_group(&q, domain_pol, access_mask, group_rid); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_GROUP, - q, r, - qbuf, rbuf, - samr_io_q_open_group, - samr_io_r_open_group, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { - *group_pol = r.pol; -#ifdef __INSURE__ - group_pol->marker = malloc(1); -#endif - } - - return result; -} - -/* Create domain group */ - -NTSTATUS rpccli_samr_create_dom_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, - const char *group_name, - uint32 access_mask, POLICY_HND *group_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_CREATE_DOM_GROUP q; - SAMR_R_CREATE_DOM_GROUP r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_create_dom_group\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_create_dom_group(&q, domain_pol, group_name, access_mask); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_DOM_GROUP, - q, r, - qbuf, rbuf, - samr_io_q_create_dom_group, - samr_io_r_create_dom_group, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) - *group_pol = r.pol; - - return result; -} - /* Add a domain group member */ NTSTATUS rpccli_samr_add_groupmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -908,82 +713,6 @@ NTSTATUS rpccli_samr_query_aliasmem(struct rpc_pipe_client *cli, return result; } -/* Open handle on an alias */ - -NTSTATUS rpccli_samr_open_alias(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, uint32 access_mask, - uint32 alias_rid, POLICY_HND *alias_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_OPEN_ALIAS q; - SAMR_R_OPEN_ALIAS r; - NTSTATUS result; - - DEBUG(10,("cli_samr_open_alias with rid 0x%x\n", alias_rid)); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_open_alias(&q, domain_pol, access_mask, alias_rid); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_ALIAS, - q, r, - qbuf, rbuf, - samr_io_q_open_alias, - samr_io_r_open_alias, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { - *alias_pol = r.pol; -#ifdef __INSURE__ - alias_pol->marker = malloc(1); -#endif - } - - return result; -} - -/* Create an alias */ - -NTSTATUS rpccli_samr_create_dom_alias(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, const char *name, - POLICY_HND *alias_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_CREATE_DOM_ALIAS q; - SAMR_R_CREATE_DOM_ALIAS r; - NTSTATUS result; - - DEBUG(10,("cli_samr_create_dom_alias named %s\n", name)); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_create_dom_alias(&q, domain_pol, name); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_DOM_ALIAS, - q, r, - qbuf, rbuf, - samr_io_q_create_dom_alias, - samr_io_r_create_dom_alias, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (NT_STATUS_IS_OK(result = r.status)) { - *alias_pol = r.alias_pol; - } - - return result; -} - /* Add an alias member */ NTSTATUS rpccli_samr_add_aliasmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -1639,51 +1368,6 @@ NTSTATUS rpccli_samr_lookup_names(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c return result; } -/* Create a domain user */ - -NTSTATUS rpccli_samr_create_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *domain_pol, const char *acct_name, - uint32 acb_info, uint32 access_mask, - POLICY_HND *user_pol, uint32 *rid) -{ - prs_struct qbuf, rbuf; - SAMR_Q_CREATE_USER q; - SAMR_R_CREATE_USER r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_create_dom_user %s\n", acct_name)); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_create_user(&q, domain_pol, acct_name, acb_info, access_mask); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_USER, - q, r, - qbuf, rbuf, - samr_io_q_create_user, - samr_io_r_create_user, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - if (!NT_STATUS_IS_OK(result = r.status)) { - goto done; - } - - if (user_pol) - *user_pol = r.user_pol; - - if (rid) - *rid = r.user_rid; - - done: - - return result; -} - /* Set userinfo */ NTSTATUS rpccli_samr_set_userinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -1778,105 +1462,6 @@ NTSTATUS rpccli_samr_set_userinfo2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ return result; } -/* Delete domain group */ - -NTSTATUS rpccli_samr_delete_dom_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *group_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_DELETE_DOM_GROUP q; - SAMR_R_DELETE_DOM_GROUP r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_delete_dom_group\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_delete_dom_group(&q, group_pol); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_GROUP, - q, r, - qbuf, rbuf, - samr_io_q_delete_dom_group, - samr_io_r_delete_dom_group, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - return result; -} - -/* Delete domain alias */ - -NTSTATUS rpccli_samr_delete_dom_alias(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *alias_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_DELETE_DOM_ALIAS q; - SAMR_R_DELETE_DOM_ALIAS r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_delete_dom_alias\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_delete_dom_alias(&q, alias_pol); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_ALIAS, - q, r, - qbuf, rbuf, - samr_io_q_delete_dom_alias, - samr_io_r_delete_dom_alias, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - return result; -} - -/* Delete domain user */ - -NTSTATUS rpccli_samr_delete_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *user_pol) -{ - prs_struct qbuf, rbuf; - SAMR_Q_DELETE_DOM_USER q; - SAMR_R_DELETE_DOM_USER r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_delete_dom_user\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_delete_dom_user(&q, user_pol); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_USER, - q, r, - qbuf, rbuf, - samr_io_q_delete_dom_user, - samr_io_r_delete_dom_user, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - return result; -} - /* Remove foreign SID */ NTSTATUS rpccli_samr_remove_sid_foreign_domain(struct rpc_pipe_client *cli, @@ -1981,91 +1566,6 @@ NTSTATUS rpccli_samr_set_sec_obj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct return result; } - -/* Get domain password info */ - -NTSTATUS rpccli_samr_get_dom_pwinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint16 *min_pwd_length, uint32 *password_properties) -{ - prs_struct qbuf, rbuf; - SAMR_Q_GET_DOM_PWINFO q; - SAMR_R_GET_DOM_PWINFO r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_get_dom_pwinfo\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_get_dom_pwinfo(&q, cli->cli->desthost); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DOM_PWINFO, - q, r, - qbuf, rbuf, - samr_io_q_get_dom_pwinfo, - samr_io_r_get_dom_pwinfo, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - if (min_pwd_length) - *min_pwd_length = r.min_pwd_length; - if (password_properties) - *password_properties = r.password_properties; - } - - return result; -} - -/* Get domain password info */ - -NTSTATUS rpccli_samr_get_usrdom_pwinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, uint16 *min_pwd_length, - uint32 *password_properties, uint32 *unknown1) -{ - prs_struct qbuf, rbuf; - SAMR_Q_GET_USRDOM_PWINFO q; - SAMR_R_GET_USRDOM_PWINFO r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - DEBUG(10,("cli_samr_get_usrdom_pwinfo\n")); - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_samr_q_get_usrdom_pwinfo(&q, pol); - - CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_USRDOM_PWINFO, - q, r, - qbuf, rbuf, - samr_io_q_get_usrdom_pwinfo, - samr_io_r_get_usrdom_pwinfo, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - if (min_pwd_length) - *min_pwd_length = r.min_pwd_length; - if (password_properties) - *password_properties = r.password_properties; - if (unknown1) - *unknown1 = r.unknown_1; - } - - return result; -} - - /* Lookup Domain Name */ NTSTATUS rpccli_samr_lookup_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, |