WERROR rpccli_svcctl_get_dispname( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, fstring displayname ) { SVCCTL_Q_GET_DISPLAY_NAME in; SVCCTL_R_GET_DISPLAY_NAME out; prs_struct qbuf, rbuf; ZERO_STRUCT(in); ZERO_STRUCT(out); memcpy( &in.handle, hService, sizeof(POLICY_HND) ); in.display_name_len = 0; CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, in, out, qbuf, rbuf, svcctl_io_q_get_display_name, svcctl_io_r_get_display_name, WERR_GENERAL_FAILURE ); /* second time with correct buffer size...should be ok */ if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { in.display_name_len = out.display_name_len; CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, in, out, qbuf, rbuf, svcctl_io_q_get_display_name, svcctl_io_r_get_display_name, WERR_GENERAL_FAILURE ); } if ( !W_ERROR_IS_OK( out.status ) ) return out.status; rpcstr_pull( displayname, out.displayname.buffer, sizeof(displayname), -1, STR_TERMINATE ); return out.status; }
/** * get the value of a configuration parameter as a string */ static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, char **valstr) { WERROR werr; bool found; uint32_t share_index, param_index; werr = smbconf_txt_load_file(ctx); if (!W_ERROR_IS_OK(werr)) { return werr; } found = smbconf_find_in_array(service, pd(ctx)->cache->share_names, pd(ctx)->cache->num_shares, &share_index); if (!found) { return WERR_NO_SUCH_SERVICE; } found = smbconf_reverse_find_in_array(param, pd(ctx)->cache->param_names[share_index], pd(ctx)->cache->num_params[share_index], ¶m_index); if (!found) { return WERR_INVALID_PARAM; } *valstr = talloc_strdup(mem_ctx, pd(ctx)->cache->param_values[share_index][param_index]); if (*valstr == NULL) { return WERR_NOMEM; } return WERR_OK; }
/* Server query info */ static WERROR cmd_srvsvc_srv_query_info(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 101; SRV_INFO_CTR ctr; WERROR result; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); return WERR_OK; } if (argc == 2) info_level = atoi(argv[1]); result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, &ctr); if (!W_ERROR_IS_OK(result)) { goto done; } /* Display results */ switch (info_level) { case 101: display_srv_info_101(&ctr.srv.sv101); break; case 102: display_srv_info_102(&ctr.srv.sv102); break; default: printf("unsupported info level %d\n", info_level); break; } done: return result; }
WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, struct NetGetJoinableOUs *r) { struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct wkssvc_PasswordBuffer *encrypted_password = NULL; NTSTATUS status; WERROR werr; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_wkssvc.syntax_id, &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } if (r->in.password) { encode_wkssvc_join_password_buffer(ctx, r->in.password, &cli->user_session_key, &encrypted_password); } status = rpccli_wkssvc_NetrGetJoinableOus2(pipe_cli, ctx, r->in.server_name, r->in.domain, r->in.account, encrypted_password, r->out.ou_count, r->out.ous, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } done: return werr; }
/** * Reads schema_info structure from schemaInfo * attribute on SCHEMA partition */ static int dsdb_module_schema_info_read(struct ldb_module *ldb_module, uint32_t dsdb_flags, TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info, struct ldb_request *parent) { int ret; DATA_BLOB ndr_blob; TALLOC_CTX *temp_ctx; WERROR werr; temp_ctx = talloc_new(mem_ctx); if (temp_ctx == NULL) { return ldb_module_oom(ldb_module); } /* read serialized schemaInfo from LDB */ ret = dsdb_module_schema_info_blob_read(ldb_module, dsdb_flags, temp_ctx, &ndr_blob, parent); if (ret != LDB_SUCCESS) { talloc_free(temp_ctx); return ret; } /* convert NDR blob to dsdb_schema_info object */ werr = dsdb_schema_info_from_blob(&ndr_blob, mem_ctx, _schema_info); talloc_free(temp_ctx); if (W_ERROR_EQUAL(werr, WERR_DS_NO_ATTRIBUTE_OR_VALUE)) { return LDB_ERR_NO_SUCH_ATTRIBUTE; } if (!W_ERROR_IS_OK(werr)) { ldb_asprintf_errstring(ldb_module_get_ctx(ldb_module), __location__ ": failed to get schema_info"); return ldb_operr(ldb_module_get_ctx(ldb_module)); } return LDB_SUCCESS; }
static WERROR _dsdb_prefixmap_from_ldb_val(const struct ldb_val *pfm_ldb_val, TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **_pfm) { WERROR werr; enum ndr_err_code ndr_err; struct prefixMapBlob pfm_blob; TALLOC_CTX *temp_ctx = talloc_new(mem_ctx); W_ERROR_HAVE_NO_MEMORY(temp_ctx); ndr_err = ndr_pull_struct_blob(pfm_ldb_val, temp_ctx, &pfm_blob, (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); DEBUG(0,("_dsdb_prefixmap_from_ldb_val: Failed to parse prefixmap of length %u: %s\n", (unsigned int)pfm_ldb_val->length, ndr_map_error2string(ndr_err))); talloc_free(temp_ctx); return ntstatus_to_werror(nt_status); } if (pfm_blob.version != PREFIX_MAP_VERSION_DSDB) { DEBUG(0,("_dsdb_prefixmap_from_ldb_val: pfm_blob->version %u incorrect\n", (unsigned int)pfm_blob.version)); talloc_free(temp_ctx); return WERR_VERSION_PARSE_ERROR; } /* call the drsuapi version */ werr = dsdb_schema_pfm_from_drsuapi_pfm(&pfm_blob.ctr.dsdb, false, mem_ctx, _pfm, NULL); if (!W_ERROR_IS_OK(werr)) { DEBUG(0, (__location__ " dsdb_schema_pfm_from_drsuapi_pfm failed: %s\n", win_errstr(werr))); talloc_free(temp_ctx); return werr; } talloc_free(temp_ctx); return werr; }
static NTSTATUS rpc_service_resume_internal(struct net_context *c, const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, int argc, const char **argv ) { struct policy_handle hSCM; WERROR result = WERR_GENERAL_FAILURE; NTSTATUS status; fstring servicename; if (argc != 1 ) { d_printf("Usage: net rpc service status <service>\n"); return NT_STATUS_OK; } fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, &result); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", win_errstr(result)); return werror_to_ntstatus(result); } result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING ); rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); return werror_to_ntstatus(result); }
/* ask the server what interface IDs are available on this endpoint */ static BOOL test_inq_if_ids(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface) { NTSTATUS status; struct mgmt_inq_if_ids r; int i; status = dcerpc_mgmt_inq_if_ids(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("inq_if_ids failed - %s\n", nt_errstr(status)); return False; } if (!W_ERROR_IS_OK(r.out.result)) { printf("inq_if_ids gave error code %s\n", win_errstr(r.out.result)); return False; } if (!r.out.if_id_vector) { printf("inq_if_ids gave NULL if_id_vector\n"); return False; } for (i=0;i<r.out.if_id_vector->count;i++) { const char *uuid; struct dcerpc_syntax_id *id = r.out.if_id_vector->if_id[i].id; if (!id) continue; uuid = GUID_string(mem_ctx, &id->uuid), printf("\n\tuuid %s version 0x%08x '%s'\n", uuid, id->if_version, idl_pipe_name(&id->uuid, id->if_version)); test_num_calls(iface, mem_ctx, id); } return True; }
static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { const char *dcname = NULL; WERROR werr; NTSTATUS status; int old_timeout; struct dcerpc_binding_handle *b = cli->binding_handle; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); return WERR_OK; } /* Make sure to wait for our DC's reply */ old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */ rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */ status = dcerpc_netr_GetAnyDCName(b, mem_ctx, cli->desthost, argv[1], &dcname, &werr); rpccli_set_timeout(cli, old_timeout); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); } if (!W_ERROR_IS_OK(werr)) { return werr; } /* Display results */ printf("%s\n", dcname); return werr; }
static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key, const char **classname, uint32_t *num_subkeys, uint32_t *num_values, NTTIME *last_changed_time, uint32_t *max_subkeylen, uint32_t *max_valnamelen, uint32_t *max_valbufsize) { struct rpc_key *mykeydata = talloc_get_type(key, struct rpc_key); WERROR error; if (mykeydata->num_values == -1) { error = rpc_query_key(mem_ctx, key); if(!W_ERROR_IS_OK(error)) return error; } if (classname != NULL) *classname = mykeydata->classname; if (num_subkeys != NULL) *num_subkeys = mykeydata->num_subkeys; if (num_values != NULL) *num_values = mykeydata->num_values; if (last_changed_time != NULL) *last_changed_time = mykeydata->last_changed_time; if (max_subkeylen != NULL) *max_subkeylen = mykeydata->max_subkeylen; if (max_valnamelen != NULL) *max_valnamelen = mykeydata->max_valnamelen; if (max_valbufsize != NULL) *max_valbufsize = mykeydata->max_valbufsize; return WERR_OK; }
static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request *req) { struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private_data, struct libnet_UnbecomeDC_state); struct composite_context *c = s->creq; struct drsuapi_DsRemoveDSServer *r = &s->drsuapi.rm_ds_srv_r; c->status = dcerpc_ndr_request_recv(req); if (!composite_is_ok(c)) return; if (!W_ERROR_IS_OK(r->out.result)) { composite_error(c, werror_to_ntstatus(r->out.result)); return; } if (*r->out.level_out != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } composite_done(c); }
static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, struct registry_key **parent, const char **name) { char *parent_name; WERROR error; if (strchr(path, '\\') == NULL) { return WERR_FOOBAR; } parent_name = talloc_strndup(mem_ctx, path, strrchr(path, '\\')-path); error = reg_open_key_abs(mem_ctx, ctx, parent_name, parent); if (!W_ERROR_IS_OK(error)) { return error; } *name = talloc_strdup(mem_ctx, strrchr(path, '\\')+1); return WERR_OK; }
static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct dcerpc_binding_handle *b = cli->binding_handle; NTSTATUS status; WERROR werr; uint16_t version; status = dcerpc_PNP_GetVersion(b, mem_ctx, &version, &werr); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); } if (W_ERROR_IS_OK(werr)) { printf("version: %d\n", version); } return werr; }
/* load only the value names into memory to enable searching */ WERROR value_list_load_quick(struct value_list *vl, struct registry_key *key) { uint32_t nvalues; uint32_t idx; struct value_item *vitem, *new_items; WERROR rv; multilist_set_data(vl->list, NULL); vl->nvalues = 0; TALLOC_FREE(vl->values); nvalues = get_num_values(vl, key); if (nvalues == 0) { return WERR_OK; } new_items = talloc_zero_array(vl, struct value_item, nvalues); if (new_items == NULL) { return WERR_NOMEM; } for (idx = 0; idx < nvalues; ++idx) { vitem = &new_items[idx]; rv = reg_key_get_value_by_index(new_items, key, idx, &vitem->value_name, &vitem->type, &vitem->data); if (!W_ERROR_IS_OK(rv)) { talloc_free(new_items); return rv; } } TYPESAFE_QSORT(new_items, nvalues, vitem_cmp); vl->nvalues = nvalues; vl->values = new_items; return rv; }
NTSTATUS printing_tdb_migrate_secdesc(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *winreg_pipe, const char *key_name, unsigned char *data, size_t length) { struct dcerpc_binding_handle *b = winreg_pipe->binding_handle; enum ndr_err_code ndr_err; struct sec_desc_buf secdesc_ctr; DATA_BLOB blob; WERROR result; if (strequal(key_name, "printers")) { return NT_STATUS_OK; } blob = data_blob_const(data, length); ZERO_STRUCT(secdesc_ctr); ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &secdesc_ctr, (ndr_pull_flags_fn_t)ndr_pull_sec_desc_buf); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(2, ("security descriptor pull failed: %s\n", ndr_errstr(ndr_err))); return NT_STATUS_NO_MEMORY; } DEBUG(2, ("Migrating Security Descriptor: %s\n", key_name)); result = winreg_set_printer_secdesc(mem_ctx, b, key_name, secdesc_ctr.sd); if (!W_ERROR_IS_OK(result)) { return werror_to_ntstatus(result); } return NT_STATUS_OK; }
static uint32_t get_num_values(TALLOC_CTX *ctx, const struct registry_key *key) { const char *classname; uint32_t num_subkeys; uint32_t num_values; NTTIME last_change_time; uint32_t max_subkeynamelen; uint32_t max_valnamelen; uint32_t max_valbufsize; WERROR rv; rv = reg_key_get_info(ctx, key, &classname, &num_subkeys, &num_values, &last_change_time, &max_subkeynamelen, &max_valnamelen, &max_valbufsize); if (W_ERROR_IS_OK(rv)) { return num_values; } return 0; }
static bool smbconf_reg_key_has_values(struct registry_key *key) { WERROR werr; uint32_t num_subkeys; uint32_t max_subkeylen; uint32_t max_subkeysize; uint32_t num_values; uint32_t max_valnamelen; uint32_t max_valbufsize; uint32_t secdescsize; NTTIME last_changed_time; werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen, &max_subkeysize, &num_values, &max_valnamelen, &max_valbufsize, &secdescsize, &last_changed_time); if (!W_ERROR_IS_OK(werr)) { return false; } return (num_values != 0); }
static WERROR cmd_clusapi_get_cluster_version(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct dcerpc_binding_handle *b = cli->binding_handle; NTSTATUS status; WERROR error; uint16_t lpwMajorVersion; uint16_t lpwMinorVersion; uint16_t lpwBuildNumber; const char *lpszVendorId; const char *lpszCSDVersion; status = dcerpc_clusapi_GetClusterVersion(b, mem_ctx, &lpwMajorVersion, &lpwMinorVersion, &lpwBuildNumber, &lpszVendorId, &lpszCSDVersion, &error); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); } if (!W_ERROR_IS_OK(error)) { printf("error: %s\n", win_errstr(error)); return error; } printf("lpwMajorVersion: %d\n", lpwMajorVersion); printf("lpwMinorVersion: %d\n", lpwMinorVersion); printf("lpwBuildNumber: %d\n", lpwBuildNumber); printf("lpszVendorId: %s\n", lpszVendorId); printf("lpszCSDVersion: %s\n", lpszCSDVersion); return WERR_OK; }
WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, struct NetServerSetInfo *r) { NTSTATUS status; WERROR werr; union srvsvc_NetSrvInfo info; struct dcerpc_binding_handle *b; werr = libnetapi_get_binding_handle(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, &b); if (!W_ERROR_IS_OK(werr)) { goto done; } switch (r->in.level) { case 1005: info.info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer; break; default: werr = WERR_NOT_SUPPORTED; goto done; } status = dcerpc_srvsvc_NetSrvSetInfo(b, talloc_tos(), r->in.server_name, r->in.level, &info, r->out.parm_error, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } done: return werr; }
static WERROR cmd_netlogon_getdcsitecoverage(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GEN_FAILURE; const char *server_name = cli->desthost; struct DcSitesCtr *ctr = NULL; struct dcerpc_binding_handle *b = cli->binding_handle; if (argc < 1 || argc > 3) { fprintf(stderr, "Usage: %s <server_name>\n", argv[0]); return WERR_OK; } if (argc >= 2) { server_name = argv[1]; } status = dcerpc_netr_DsrGetDcSiteCoverageW(b, mem_ctx, server_name, &ctr, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } if (W_ERROR_IS_OK(werr) && ctr->num_sites) { int i; printf("sites covered by this DC: %d\n", ctr->num_sites); for (i=0; i<ctr->num_sites; i++) { printf("%s\n", ctr->sites[i].string); } } done: return werr; }
NTSTATUS dcerpc_winreg_set_multi_sz(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *h, struct policy_handle *key_handle, const char *value, const char **data, WERROR *pwerr) { struct winreg_String wvalue = { 0, }; DATA_BLOB blob; WERROR result = WERR_OK; NTSTATUS status; wvalue.name = value; if (!push_reg_multi_sz(mem_ctx, &blob, data)) { DEBUG(2, ("dcerpc_winreg_set_multi_sz: Could not marshall " "string multi sz for %s\n", wvalue.name)); *pwerr = WERR_NOMEM; return NT_STATUS_OK; } status = dcerpc_winreg_SetValue(h, mem_ctx, key_handle, wvalue, REG_MULTI_SZ, blob.data, blob.length, &result); if (!NT_STATUS_IS_OK(status)) { return status; } if (!W_ERROR_IS_OK(result)) { *pwerr = result; } return status; }
bool regkey_access_check(struct registry_key_handle *key, uint32 requested, uint32 *granted, const struct security_token *token ) { struct security_descriptor *sec_desc; NTSTATUS status; WERROR err; /* root free-pass, like we have on all other pipes like samr, lsa, etc. */ if (geteuid() == sec_initial_uid()) { *granted = REG_KEY_ALL; return true; } /* use the default security check if the backend has not defined its * own */ if (key->ops && key->ops->reg_access_check) { return key->ops->reg_access_check(key->name, requested, granted, token); } err = regkey_get_secdesc(talloc_tos(), key, &sec_desc); if (!W_ERROR_IS_OK(err)) { return false; } se_map_generic( &requested, ®_generic_map ); status =se_access_check(sec_desc, token, requested, granted); TALLOC_FREE(sec_desc); if (!NT_STATUS_IS_OK(status)) { return false; } return NT_STATUS_IS_OK(status); }
static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx, struct NetServerSetInfo *r) { WERROR werr; struct smbconf_ctx *conf_ctx; struct srvsvc_NetSrvInfo1005 *info1005; if (!r->in.buffer) { *r->out.parm_error = 1005; /* sure here ? */ return WERR_INVALID_PARAM; } info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer; if (!info1005->comment) { *r->out.parm_error = 1005; return WERR_INVALID_PARAM; } if (!lp_config_backend_is_registry()) { libnetapi_set_error_string(ctx, "Configuration manipulation requested but not " "supported by backend"); return WERR_NOT_SUPPORTED; } werr = smbconf_init_reg(ctx, &conf_ctx, NULL); if (!W_ERROR_IS_OK(werr)) { goto done; } werr = smbconf_set_global_parameter(conf_ctx, "server string", info1005->comment); done: smbconf_shutdown(conf_ctx); return werr; }
WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, struct NetServerSetInfo *r) { struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; union srvsvc_NetSrvInfo info; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } switch (r->in.level) { case 1005: info.info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer; break; default: werr = WERR_NOT_SUPPORTED; goto done; } status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, talloc_tos(), r->in.server_name, r->in.level, &info, r->out.parm_error, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } done: return werr; }
WERROR dcesrv_drsuapi_ListRoles(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, const struct drsuapi_DsNameRequest1 *req1, struct drsuapi_DsNameCtr1 **ctr1) { struct drsuapi_DsNameInfo1 *names; uint32_t i; uint32_t count = 5;/*number of fsmo role owners we are going to return*/ *ctr1 = talloc(mem_ctx, struct drsuapi_DsNameCtr1); W_ERROR_HAVE_NO_MEMORY(*ctr1); names = talloc_array(mem_ctx, struct drsuapi_DsNameInfo1, count); W_ERROR_HAVE_NO_MEMORY(names); for (i = 0; i < count; i++) { WERROR werr; struct ldb_dn *role_owner_dn, *fsmo_role_dn, *server_dn; werr = dsdb_get_fsmo_role_info(mem_ctx, sam_ctx, i, &fsmo_role_dn, &role_owner_dn); if(!W_ERROR_IS_OK(werr)) { return werr; } server_dn = ldb_dn_copy(mem_ctx, role_owner_dn); ldb_dn_remove_child_components(server_dn, 1); names[i].status = DRSUAPI_DS_NAME_STATUS_OK; names[i].dns_domain_name = samdb_dn_to_dnshostname(sam_ctx, mem_ctx, server_dn); if(!names[i].dns_domain_name) { DEBUG(4, ("list_roles: Failed to find dNSHostName for server %s\n", ldb_dn_get_linearized(server_dn))); } names[i].result_name = talloc_strdup(mem_ctx, ldb_dn_get_linearized(role_owner_dn)); } (*ctr1)->count = count; (*ctr1)->array = names; return WERR_OK; }
WERROR rpccli_svcctl_open_scm(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 access_desired ) { SVCCTL_Q_OPEN_SCMANAGER in; SVCCTL_R_OPEN_SCMANAGER out; prs_struct qbuf, rbuf; fstring server; ZERO_STRUCT(in); ZERO_STRUCT(out); /* leave the database name NULL to get the default service db */ in.database = NULL; /* set the server name */ if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) ) return WERR_NOMEM; fstr_sprintf( server, "\\\\%s", cli->cli->desthost ); init_unistr2( in.servername, server, UNI_STR_TERMINATE ); in.access = access_desired; CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, in, out, qbuf, rbuf, svcctl_io_q_open_scmanager, svcctl_io_r_open_scmanager, WERR_GENERAL_FAILURE ); if ( !W_ERROR_IS_OK( out.status ) ) return out.status; memcpy( hSCM, &out.handle, sizeof(POLICY_HND) ); return out.status; }
static WERROR cmd_clusapi_open_resource(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct dcerpc_binding_handle *b = cli->binding_handle; NTSTATUS status; const char *lpszResourceName = "Cluster Name"; WERROR Status; struct policy_handle hResource; WERROR rpc_status, ignore; if (argc >= 2) { lpszResourceName = argv[1]; } status = dcerpc_clusapi_OpenResource(b, mem_ctx, lpszResourceName, &Status, &rpc_status, &hResource); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); } if (!W_ERROR_IS_OK(Status)) { printf("Status: %s\n", win_errstr(Status)); return Status; } printf("rpc_status: %s\n", win_errstr(rpc_status)); dcerpc_clusapi_CloseResource(b, mem_ctx, &hResource, &ignore); return WERR_OK; }
static void unbecomeDC_drsuapi_remove_ds_server_recv(struct tevent_req *subreq) { struct libnet_UnbecomeDC_state *s = tevent_req_callback_data(subreq, struct libnet_UnbecomeDC_state); struct composite_context *c = s->creq; struct drsuapi_DsRemoveDSServer *r = &s->drsuapi.rm_ds_srv_r; c->status = dcerpc_drsuapi_DsRemoveDSServer_r_recv(subreq, s); TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; if (!W_ERROR_IS_OK(r->out.result)) { composite_error(c, werror_to_ntstatus(r->out.result)); return; } if (*r->out.level_out != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } composite_done(c); }
static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) { uint32_t value_type; DATA_BLOB value_data; WERROR error; if (argc != 2) { fprintf(stderr, "Usage: print <valuename>\n"); return WERR_INVALID_PARAM; } error = reg_key_get_value_by_name(ctx, ctx->current, argv[1], &value_type, &value_data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "No such value '%s'\n", argv[1]); return error; } printf("%s\n%s\n", str_regtype(value_type), reg_val_data_string(ctx, value_type, value_data)); return WERR_OK; }
static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) { struct registry_value val; WERROR error; if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); return WERR_INVALID_PARAM; } if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, &val.data)) { fprintf(stderr, "Unable to interpret data\n"); return WERR_INVALID_PARAM; } error = reg_val_set(ctx->current, argv[1], val.data_type, val.data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); return error; } return WERR_OK; }