1 /*enumerates privileges*/
6 #define MAX_STRING_LEN 50;
9 CacServerHandle *hnd = NULL;
10 TALLOC_CTX *mem_ctx = NULL;
11 POLICY_HND *lsa_pol = NULL;
15 mem_ctx = talloc_init("lsatrust");
17 hnd = cac_NewServerHandle(True);
20 fscanf(stdin, "%s", hnd->server);
22 printf("Connecting to server....\n");
24 if(!cac_Connect(hnd, NULL)) {
25 fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno));
30 printf("Connected to server\n");
32 struct LsaOpenPolicy lop;
35 lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
36 lop.in.security_qos = True;
39 if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
40 fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status));
45 lsa_pol = lop.out.pol;
47 printf("Enumerating Privileges\n");
49 struct LsaEnumPrivileges ep;
53 ep.in.pref_max_privs = 50;
55 while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) {
56 printf(" Enumerated %d privileges\n", ep.out.num_privs);
58 for(i = 0; i < ep.out.num_privs; i++) {
59 printf("\"%s\"\n", ep.out.priv_names[i]);
65 if(CAC_OP_FAILED(hnd->status)) {
66 fprintf(stderr, "Error while enumerating privileges.\n Error: %s\n", nt_errstr(hnd->status));
71 if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) {
72 fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status));
76 talloc_destroy(mem_ctx);