if we are adding a new sambaAccount, make sure that we add a
[Samba.git] / source / rpcclient / display_sec.c
blob5c23bf42ffa872693b52d453ebfd6369c33ff4cb
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-1999
5 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "rpcclient.h"
26 /****************************************************************************
27 convert a security permissions into a string
28 ****************************************************************************/
29 char *get_sec_mask_str(uint32 type)
31 static fstring typestr="";
33 typestr[0] = 0;
35 if (type & GENERIC_ALL_ACCESS)
36 fstrcat(typestr, "Generic all access ");
37 if (type & GENERIC_EXECUTE_ACCESS)
38 fstrcat(typestr, "Generic execute access ");
39 if (type & GENERIC_WRITE_ACCESS)
40 fstrcat(typestr, "Generic write access ");
41 if (type & GENERIC_READ_ACCESS)
42 fstrcat(typestr, "Generic read access ");
43 if (type & MAXIMUM_ALLOWED_ACCESS)
44 fstrcat(typestr, "MAXIMUM_ALLOWED_ACCESS ");
45 if (type & SYSTEM_SECURITY_ACCESS)
46 fstrcat(typestr, "SYSTEM_SECURITY_ACCESS ");
47 if (type & SYNCHRONIZE_ACCESS)
48 fstrcat(typestr, "SYNCHRONIZE_ACCESS ");
49 if (type & WRITE_OWNER_ACCESS)
50 fstrcat(typestr, "WRITE_OWNER_ACCESS ");
51 if (type & WRITE_DAC_ACCESS)
52 fstrcat(typestr, "WRITE_DAC_ACCESS ");
53 if (type & READ_CONTROL_ACCESS)
54 fstrcat(typestr, "READ_CONTROL_ACCESS ");
55 if (type & DELETE_ACCESS)
56 fstrcat(typestr, "DELETE_ACCESS ");
58 printf("\t\tSpecific bits: 0x%lx\n", type&SPECIFIC_RIGHTS_MASK);
60 return typestr;
63 /****************************************************************************
64 display sec_access structure
65 ****************************************************************************/
66 void display_sec_access(SEC_ACCESS *info)
68 printf("\t\tPermissions: 0x%x: %s\n", info->mask, get_sec_mask_str(info->mask));
71 /****************************************************************************
72 display sec_ace structure
73 ****************************************************************************/
74 void display_sec_ace(SEC_ACE *ace)
76 fstring sid_str;
78 printf("\tACE\n\t\ttype: ");
79 switch (ace->type) {
80 case SEC_ACE_TYPE_ACCESS_ALLOWED:
81 printf("ACCESS ALLOWED");
82 break;
83 case SEC_ACE_TYPE_ACCESS_DENIED:
84 printf("ACCESS DENIED");
85 break;
86 case SEC_ACE_TYPE_SYSTEM_AUDIT:
87 printf("SYSTEM AUDIT");
88 break;
89 case SEC_ACE_TYPE_SYSTEM_ALARM:
90 printf("SYSTEM ALARM");
91 break;
92 default:
93 printf("????");
94 break;
96 printf(" (%d) flags: %d\n", ace->type, ace->flags);
97 display_sec_access(&ace->info);
98 sid_to_string(sid_str, &ace->trustee);
99 printf("\t\tSID: %s\n\n", sid_str);
102 /****************************************************************************
103 display sec_acl structure
104 ****************************************************************************/
105 void display_sec_acl(SEC_ACL *sec_acl)
107 int i;
109 printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
110 sec_acl->num_aces, sec_acl->revision);
111 printf("\t---\n");
113 if (sec_acl->size != 0 && sec_acl->num_aces != 0)
114 for (i = 0; i < sec_acl->num_aces; i++)
115 display_sec_ace(&sec_acl->ace[i]);
119 /****************************************************************************
120 display sec_desc structure
121 ****************************************************************************/
122 void display_sec_desc(SEC_DESC *sec)
124 fstring sid_str;
126 if (sec->sacl) {
127 printf("SACL\n");
128 display_sec_acl(sec->sacl);
131 if (sec->dacl) {
132 printf("DACL\n");
133 display_sec_acl(sec->dacl);
136 if (sec->owner_sid) {
137 sid_to_string(sid_str, sec->owner_sid);
138 printf("\tOwner SID:\t%s\n", sid_str);
141 if (sec->grp_sid) {
142 sid_to_string(sid_str, sec->grp_sid);
143 printf("\tParent SID:\t%s\n", sid_str);