ReactOS 0.4.16-dev-240-gdb5fa3b
SecurityDescriptor.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CSecurityDescriptor
 

Functions

BOOL GetTextualSid (PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen)
 
const TCHARGetSidTypeName (SID_NAME_USE Use)
 

Function Documentation

◆ GetSidTypeName()

const TCHAR * GetSidTypeName ( SID_NAME_USE  Use)

Definition at line 106 of file SecurityDescriptor.cpp.

107{
108 switch(Use)
109 {
110 case SidTypeUser:
111 return _T("User SID");
112 case SidTypeGroup:
113 return _T("Group SID");
114 case SidTypeDomain:
115 return _T("Domain SID");
116 case SidTypeAlias:
117 return _T("Alias SID");
119 return _T("SID for a well-known group");
121 return _T("SID for a deleted account");
122 case SidTypeInvalid:
123 return _T("Invalid SID");
124 case SidTypeUnknown:
125 return _T("Unknown SID type");
126 default:
127 return _T("Error. Cannot recognize SID type.");
128 }
129}
@ SidTypeUnknown
Definition: lsa.idl:125
@ SidTypeAlias
Definition: lsa.idl:121
@ SidTypeDomain
Definition: lsa.idl:120
@ SidTypeGroup
Definition: lsa.idl:119
@ SidTypeDeletedAccount
Definition: lsa.idl:123
@ SidTypeUser
Definition: lsa.idl:118
@ SidTypeWellKnownGroup
Definition: lsa.idl:122
@ SidTypeInvalid
Definition: lsa.idl:124
#define _T(x)
Definition: vfdio.h:22

Referenced by CShellCommandDACL::Execute(), CShellCommandOwner::Execute(), and CShellCommandSACL::Execute().

◆ GetTextualSid()

BOOL GetTextualSid ( PSID  pSid,
LPTSTR  TextualSid,
LPDWORD  lpdwBufferLen 
)

Definition at line 29 of file SecurityDescriptor.cpp.

34{
36 DWORD dwSubAuthorities;
37 DWORD dwSidRev=SID_REVISION;
39 DWORD dwSidSize;
40
41 // Validate the binary SID.
42
43 if(!IsValidSid(pSid)) return FALSE;
44
45 // Get the identifier authority value from the SID.
46
48
49 // Get the number of subauthorities in the SID.
50
51 dwSubAuthorities = *GetSidSubAuthorityCount(pSid);
52
53 // Compute the buffer length.
54 // S-SID_REVISION- + IdentifierAuthority- + subauthorities- + NULL
55
56 dwSidSize=(15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR);
57
58 // Check input buffer length.
59 // If too small, indicate the proper size and set last error.
60
61 if (*lpdwBufferLen < dwSidSize)
62 {
63 *lpdwBufferLen = dwSidSize;
65 return FALSE;
66 }
67
68 // Add 'S' prefix and revision number to the string.
69
70 dwSidSize=wsprintf(TextualSid, TEXT("S-%lu-"), dwSidRev );
71
72 // Add SID identifier authority to the string.
73
74 if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) )
75 {
76 dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),
77 TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
78 (USHORT)psia->Value[0],
79 (USHORT)psia->Value[1],
80 (USHORT)psia->Value[2],
81 (USHORT)psia->Value[3],
82 (USHORT)psia->Value[4],
83 (USHORT)psia->Value[5]);
84 }
85 else
86 {
87 dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),
88 TEXT("%lu"),
89 (ULONG)(psia->Value[5] ) +
90 (ULONG)(psia->Value[4] << 8) +
91 (ULONG)(psia->Value[3] << 16) +
92 (ULONG)(psia->Value[2] << 24) );
93 }
94
95 // Add SID subauthorities to the string.
96 //
97 for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++)
98 {
99 dwSidSize+=wsprintf(TextualSid + dwSidSize, TEXT("-%lu"),
101 }
102
103 return TRUE;
104}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PDWORD WINAPI GetSidSubAuthority(PSID pSid, DWORD nSubAuthority)
Definition: security.c:896
BOOL WINAPI IsValidSid(PSID pSid)
Definition: security.c:819
PUCHAR WINAPI GetSidSubAuthorityCount(PSID pSid)
Definition: security.c:908
PSID_IDENTIFIER_AUTHORITY WINAPI GetSidIdentifierAuthority(PSID pSid)
Definition: security.c:885
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TEXT(s)
Definition: k32.h:26
DWORD dwCounter
Definition: mutex.c:10
static PSID pSid
Definition: security.c:74
unsigned short USHORT
Definition: pedump.c:61
uint32_t ULONG
Definition: typedefs.h:59
#define lstrlen
Definition: winbase.h:3901
#define wsprintf
Definition: winuser.h:5877
* PSID_IDENTIFIER_AUTHORITY
Definition: setypes.h:464
#define SID_REVISION
Definition: setypes.h:481
char TCHAR
Definition: xmlstorage.h:189

Referenced by CShellCommandDACL::Execute(), CShellCommandOwner::Execute(), and CShellCommandSACL::Execute().