00001
00002
00003 #include "libmsrpc.h"
00004 #include "test_util.h"
00005
00006 int main(int argc, char **argv) {
00007 CacServerHandle *hnd = NULL;
00008 TALLOC_CTX *mem_ctx = NULL;
00009
00010 mem_ctx = talloc_init("cac_dominfo");
00011
00012 hnd = cac_NewServerHandle(True);
00013
00014 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
00015
00016 cac_parse_cmd_line(argc, argv, hnd);
00017
00018 if(!cac_Connect(hnd, NULL)) {
00019 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
00020 exit(-1);
00021 }
00022
00023 struct SamOpenDomain sod;
00024 ZERO_STRUCT(sod);
00025
00026 sod.in.access = MAXIMUM_ALLOWED_ACCESS;
00027
00028 if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
00029 fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
00030 goto done;
00031 }
00032
00033 struct SamGetDomainInfo gdi;
00034 ZERO_STRUCT(gdi);
00035
00036 gdi.in.dom_hnd = sod.out.dom_hnd;
00037
00038 if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) {
00039 fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status));
00040 goto done;
00041 }
00042
00043 printf("Got domain info:\n");
00044 print_cac_domain_info(gdi.out.info);
00045
00046 done:
00047 cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
00048
00049 cac_FreeHandle(hnd);
00050
00051 talloc_destroy(mem_ctx);
00052
00053 return 0;
00054 }
00055