#include "libmsrpc.h"#include "includes.h"Go to the source code of this file.
Defines | |
| #define | MAX_STRING_LEN 50; |
Functions | |
| int | main () |
|
|
Definition at line 6 of file lsaenumprivs.c. |
|
|
Definition at line 8 of file lsaenumprivs.c. References cac_Connect(), cac_FreeHandle(), cac_LsaClosePolicy(), cac_LsaEnumPrivileges(), cac_LsaOpenPolicy(), cac_NewServerHandle(), CAC_OP_FAILED, errno, fprintf(), LsaEnumPrivileges::in, LsaOpenPolicy::in, nt_errstr(), LsaEnumPrivileges::out, LsaOpenPolicy::out, printf(), SEC_RIGHT_MAXIMUM_ALLOWED, _CACSERVERHANDLE::server, _CACSERVERHANDLE::status, strerror, talloc_destroy, talloc_init(), True, and ZERO_STRUCT. 00008 { 00009 CacServerHandle *hnd = NULL; 00010 TALLOC_CTX *mem_ctx = NULL; 00011 POLICY_HND *lsa_pol = NULL; 00012 00013 int i; 00014 00015 mem_ctx = talloc_init("lsatrust"); 00016 00017 hnd = cac_NewServerHandle(True); 00018 00019 printf("Server: "); 00020 fscanf(stdin, "%s", hnd->server); 00021 00022 printf("Connecting to server....\n"); 00023 00024 if(!cac_Connect(hnd, NULL)) { 00025 fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno)); 00026 cac_FreeHandle(hnd); 00027 exit(-1); 00028 } 00029 00030 printf("Connected to server\n"); 00031 00032 struct LsaOpenPolicy lop; 00033 ZERO_STRUCT(lop); 00034 00035 lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; 00036 lop.in.security_qos = True; 00037 00038 00039 if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { 00040 fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status)); 00041 cac_FreeHandle(hnd); 00042 exit(-1); 00043 } 00044 00045 lsa_pol = lop.out.pol; 00046 00047 printf("Enumerating Privileges\n"); 00048 00049 struct LsaEnumPrivileges ep; 00050 ZERO_STRUCT(ep); 00051 00052 ep.in.pol = lsa_pol; 00053 ep.in.pref_max_privs = 50; 00054 00055 while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) { 00056 printf(" Enumerated %d privileges\n", ep.out.num_privs); 00057 00058 for(i = 0; i < ep.out.num_privs; i++) { 00059 printf("\"%s\"\n", ep.out.priv_names[i]); 00060 } 00061 00062 printf("\n"); 00063 } 00064 00065 if(CAC_OP_FAILED(hnd->status)) { 00066 fprintf(stderr, "Error while enumerating privileges.\n Error: %s\n", nt_errstr(hnd->status)); 00067 goto done; 00068 } 00069 00070 done: 00071 if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { 00072 fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status)); 00073 } 00074 00075 cac_FreeHandle(hnd); 00076 talloc_destroy(mem_ctx); 00077 00078 return 0; 00079 }
|