diff options
author | Gerald Carter <jerry@samba.org> | 2005-09-03 16:55:45 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:03:30 -0500 |
commit | 3c6b0f965588aab0edbc4d115fb9e72c884ded3b (patch) | |
tree | ce3740784555e729297955c924e4701feaf69d38 /examples/libmsrpc/test/reg/regopen.c | |
parent | a44e97c99f61916db3f7cc02cd2581c8d64be73a (diff) | |
download | samba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.tar.gz samba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.tar.bz2 samba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.zip |
r10003: in the rush for 10k, I forgot to run add the rest of Chris' libmsrpc files
(This used to be commit 32bebc452dffa8348b94c5b866350b1fe761986f)
Diffstat (limited to 'examples/libmsrpc/test/reg/regopen.c')
-rw-r--r-- | examples/libmsrpc/test/reg/regopen.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/examples/libmsrpc/test/reg/regopen.c b/examples/libmsrpc/test/reg/regopen.c new file mode 100644 index 0000000000..fedc52e40d --- /dev/null +++ b/examples/libmsrpc/test/reg/regopen.c @@ -0,0 +1,66 @@ +/*opens and closes a registry handle*/ + +#include "libmsrpc.h" + +int main() { + CacServerHandle *hnd = NULL; + TALLOC_CTX *mem_ctx = NULL; + + POLICY_HND **keys = NULL; + + char roots[4][50] = { {CAC_HKCR}, {CAC_HKLM}, {CAC_HKU}, {CAC_HKPD} }; + + int i; + + + mem_ctx = talloc_init("regopen"); + + hnd = cac_NewServerHandle(True); + + keys = TALLOC_ARRAY(mem_ctx, POLICY_HND *, 4); + + printf("Enter server to connect to: "); + fscanf(stdin, "%s", hnd->server); + + if(!cac_Connect(hnd, NULL)) { + fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); + cac_FreeHandle(hnd); + exit(-1); + } + + struct RegConnect rc; + ZERO_STRUCT(rc); + + rc.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; + + for(i = 0; i < 4; i++) { + printf("opening: %s\n", roots[i]); + + rc.in.root = roots[i]; + + if(!cac_RegConnect(hnd, mem_ctx, &rc)) { + fprintf(stderr, " Could not connect to registry. %s\n", nt_errstr(hnd->status)); + continue; + } + + keys[i] = rc.out.key; + } + + for(i = 3; i >= 0; i--) { + if(keys[i] == NULL) + continue; + + printf("closing: %s\n", roots[i]); + + if(!cac_RegClose(hnd, mem_ctx, keys[i])) { + fprintf(stderr, " Could not close handle. %s\n", nt_errstr(hnd->status)); + } + } + + cac_FreeHandle(hnd); + + talloc_destroy(mem_ctx); + + return 0; + +} |