1 /*gets domain info and prints it out*/
6 int main(int argc, char **argv) {
7 CacServerHandle *hnd = NULL;
8 TALLOC_CTX *mem_ctx = NULL;
10 mem_ctx = talloc_init("cac_dominfo");
12 hnd = cac_NewServerHandle(True);
14 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
16 cac_parse_cmd_line(argc, argv, hnd);
18 if(!cac_Connect(hnd, NULL)) {
19 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
23 struct SamOpenDomain sod;
26 sod.in.access = MAXIMUM_ALLOWED_ACCESS;
28 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
29 fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
33 struct SamGetDomainInfo gdi;
36 gdi.in.dom_hnd = sod.out.dom_hnd;
38 if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) {
39 fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status));
43 printf("Got domain info:\n");
44 print_cac_domain_info(gdi.out.info);
47 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
51 talloc_destroy(mem_ctx);