1 /*opens and closes a registry handle*/
6 CacServerHandle
*hnd
= NULL
;
7 TALLOC_CTX
*mem_ctx
= NULL
;
9 POLICY_HND
**keys
= NULL
;
11 char roots
[4][50] = { {CAC_HKCR
}, {CAC_HKLM
}, {CAC_HKU
}, {CAC_HKPD
} };
16 mem_ctx
= talloc_init("regopen");
18 hnd
= cac_NewServerHandle(True
);
20 keys
= TALLOC_ARRAY(mem_ctx
, POLICY_HND
*, 4);
22 printf("Enter server to connect to: ");
23 fscanf(stdin
, "%s", hnd
->server
);
25 if(!cac_Connect(hnd
, NULL
)) {
26 fprintf(stderr
, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd
->status
), strerror(errno
));
34 rc
.in
.access
= SEC_RIGHT_MAXIMUM_ALLOWED
;
36 for(i
= 0; i
< 4; i
++) {
37 printf("opening: %s\n", roots
[i
]);
39 rc
.in
.root
= roots
[i
];
41 if(!cac_RegConnect(hnd
, mem_ctx
, &rc
)) {
42 fprintf(stderr
, " Could not connect to registry. %s\n", nt_errstr(hnd
->status
));
49 for(i
= 3; i
>= 0; i
--) {
53 printf("closing: %s\n", roots
[i
]);
55 if(!cac_RegClose(hnd
, mem_ctx
, keys
[i
])) {
56 fprintf(stderr
, " Could not close handle. %s\n", nt_errstr(hnd
->status
));
62 talloc_destroy(mem_ctx
);