BOOL torture_domain_close_lsa(struct torture_context *torture) { BOOL ret = True; NTSTATUS status; TALLOC_CTX *mem_ctx=NULL; struct libnet_context *ctx; struct lsa_String domain_name; struct dcerpc_binding *binding; const char *bindstr; uint32_t access_mask; struct policy_handle h; struct dcerpc_pipe *p; struct libnet_DomainClose r; bindstr = torture_setting_string(torture, "binding", NULL); status = dcerpc_parse_binding(torture, bindstr, &binding); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to parse binding string\n"); return False; } ctx = libnet_context_init(NULL); if (ctx == NULL) { d_printf("failed to create libnet context\n"); ret = False; goto done; } ctx->cred = cmdline_credentials; mem_ctx = talloc_init("torture_domain_close_lsa"); status = dcerpc_pipe_connect(mem_ctx, &p, bindstr, &dcerpc_table_lsarpc, cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to connect to server %s: %s\n", bindstr, nt_errstr(status)); ret = False; goto done; } domain_name.string = lp_workgroup(); if (!test_opendomain_lsa(p, torture, &h, &domain_name, &access_mask)) { d_printf("failed to open domain on lsa service\n"); ret = False; goto done; } ctx->lsa.pipe = p; ctx->lsa.name = domain_name.string; ctx->lsa.access_mask = access_mask; ctx->lsa.handle = h; /* we have to use pipe's event context, otherwise the call will hang indefinitely */ ctx->event_ctx = p->conn->event_ctx; ZERO_STRUCT(r); r.in.type = DOMAIN_LSA; r.in.domain_name = domain_name.string; status = libnet_DomainClose(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = False; goto done; } done: talloc_free(mem_ctx); talloc_free(ctx); return ret; }
bool torture_domain_close_lsa(struct torture_context *torture) { bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx=NULL; struct libnet_context *ctx; struct lsa_String domain_name; struct dcerpc_binding *binding; uint32_t access_mask; struct policy_handle h; struct dcerpc_pipe *p; struct libnet_DomainClose r; status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { return false; } ctx = libnet_context_init(torture->ev, torture->lp_ctx); if (ctx == NULL) { torture_comment(torture, "failed to create libnet context\n"); ret = false; goto done; } ctx->cred = cmdline_credentials; mem_ctx = talloc_init("torture_domain_close_lsa"); status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc, cmdline_credentials, torture->ev, torture->lp_ctx); if (!NT_STATUS_IS_OK(status)) { torture_comment(torture, "failed to connect to server: %s\n", nt_errstr(status)); ret = false; goto done; } domain_name.string = lpcfg_workgroup(torture->lp_ctx); if (!test_opendomain_lsa(torture, p->binding_handle, torture, &h, &domain_name, &access_mask)) { torture_comment(torture, "failed to open domain on lsa service\n"); ret = false; goto done; } ctx->lsa.pipe = p; ctx->lsa.name = domain_name.string; ctx->lsa.access_mask = access_mask; ctx->lsa.handle = h; ZERO_STRUCT(r); r.in.type = DOMAIN_LSA; r.in.domain_name = domain_name.string; status = libnet_DomainClose(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = false; goto done; } done: talloc_free(mem_ctx); talloc_free(ctx); return ret; }