1/*gets domain info and prints it out*/
2
3#include "libmsrpc.h"
4#include "test_util.h"
5
6int main(int argc, char **argv) {
7   CacServerHandle *hnd = NULL;
8   TALLOC_CTX *mem_ctx = NULL;
9
10   mem_ctx = talloc_init("cac_dominfo");
11
12   hnd = cac_NewServerHandle(True);
13
14   cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
15
16   cac_parse_cmd_line(argc, argv, hnd);
17
18   if(!cac_Connect(hnd, NULL)) {
19      fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
20      exit(-1);
21   }
22
23   struct SamOpenDomain sod;
24   ZERO_STRUCT(sod);
25
26   sod.in.access = MAXIMUM_ALLOWED_ACCESS;
27
28   if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
29      fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
30      goto done;
31   }
32
33   struct SamGetDomainInfo gdi;
34   ZERO_STRUCT(gdi);
35
36   gdi.in.dom_hnd = sod.out.dom_hnd;
37
38   if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) {
39      fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status));
40      goto done;
41   }
42
43   printf("Got domain info:\n");
44   print_cac_domain_info(gdi.out.info);
45
46done:
47   cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
48
49   cac_FreeHandle(hnd);
50
51   talloc_destroy(mem_ctx);
52
53   return 0;
54}
55
56