BOOL torture_domain_list(struct torture_context *torture) { BOOL ret = True; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; const char *bindstr; struct dcerpc_binding *binding; struct libnet_context *ctx; struct libnet_DomainList r; int i; 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_samr"); /* * querying the domain list using default buffer size */ ZERO_STRUCT(r); r.in.hostname = binding->host; status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = False; goto done; } d_printf("Received list or domains (everything in one piece):\n"); for (i = 0; i < r.out.count; i++) { d_printf("Name[%d]: %s\n", i, r.out.domains[i].name); } /* * querying the domain list using specified (much smaller) buffer size */ ctx->samr.buf_size = 32; ZERO_STRUCT(r); r.in.hostname = binding->host; status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = False; goto done; } d_printf("Received list or domains (collected in more than one round):\n"); for (i = 0; i < r.out.count; i++) { d_printf("Name[%d]: %s\n", i, r.out.domains[i].name); } done: d_printf("\nStatus: %s\n", nt_errstr(status)); talloc_free(mem_ctx); talloc_free(ctx); return ret; }
bool torture_domain_list(struct torture_context *torture) { bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; struct dcerpc_binding *binding; struct libnet_context *ctx; struct libnet_DomainList r; int i; 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_samr"); /* * querying the domain list using default buffer size */ ZERO_STRUCT(r); r.in.hostname = dcerpc_binding_get_string_option(binding, "host"); status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = false; goto done; } torture_comment(torture, "Received list or domains (everything in one piece):\n"); for (i = 0; i < r.out.count; i++) { torture_comment(torture, "Name[%d]: %s\n", i, r.out.domains[i].name); } /* * querying the domain list using specified (much smaller) buffer size */ ctx->samr.buf_size = 32; ZERO_STRUCT(r); r.in.hostname = dcerpc_binding_get_string_option(binding, "host"); status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { ret = false; goto done; } torture_comment(torture, "Received list or domains (collected in more than one round):\n"); for (i = 0; i < r.out.count; i++) { torture_comment(torture, "Name[%d]: %s\n", i, r.out.domains[i].name); } done: torture_comment(torture, "\nStatus: %s\n", nt_errstr(status)); talloc_free(mem_ctx); talloc_free(ctx); return ret; }