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/lsa/lsaenumprivs.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/lsa/lsaenumprivs.c')
-rw-r--r-- | examples/libmsrpc/test/lsa/lsaenumprivs.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/examples/libmsrpc/test/lsa/lsaenumprivs.c b/examples/libmsrpc/test/lsa/lsaenumprivs.c new file mode 100644 index 0000000000..8b5c9deca6 --- /dev/null +++ b/examples/libmsrpc/test/lsa/lsaenumprivs.c @@ -0,0 +1,79 @@ +/*enumerates privileges*/ + +#include "libmsrpc.h" +#include "includes.h" + +#define MAX_STRING_LEN 50; + +int main() { + CacServerHandle *hnd = NULL; + TALLOC_CTX *mem_ctx = NULL; + POLICY_HND *lsa_pol = NULL; + + int i; + + mem_ctx = talloc_init("lsatrust"); + + hnd = cac_NewServerHandle(True); + + printf("Server: "); + fscanf(stdin, "%s", hnd->server); + + printf("Connecting to server....\n"); + + 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); + } + + printf("Connected to server\n"); + + struct LsaOpenPolicy lop; + ZERO_STRUCT(lop); + + lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; + lop.in.security_qos = True; + + + if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { + fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status)); + cac_FreeHandle(hnd); + exit(-1); + } + + lsa_pol = lop.out.pol; + + printf("Enumerating Privileges\n"); + + struct LsaEnumPrivileges ep; + ZERO_STRUCT(ep); + + ep.in.pol = lsa_pol; + ep.in.pref_max_privs = 50; + + while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) { + printf(" Enumerated %d privileges\n", ep.out.num_privs); + + for(i = 0; i < ep.out.num_privs; i++) { + printf("\"%s\"\n", ep.out.priv_names[i]); + } + + printf("\n"); + } + + if(CAC_OP_FAILED(hnd->status)) { + fprintf(stderr, "Error while enumerating privileges.\n Error: %s\n", nt_errstr(hnd->status)); + goto done; + } + +done: + if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { + fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status)); + } + + cac_FreeHandle(hnd); + talloc_destroy(mem_ctx); + + return 0; +} |