61{
66 const TCHAR *pchParameter;
68
71
74 {
76 }
78 {
80 goto CheckOwnerArgument;
81 }
82
84 {
85CheckOwnerArgument:
86 blnBadParameter =
FALSE;
89 {
91 blnDo = pchKey !=
NULL;
92 }
93 else if (!pchKey)
94 {
95 pchKey = pchParameter;
97 }
98 else
99 {
100 blnBadParameter =
TRUE;
101 }
102 if (blnBadParameter)
103 {
104 rConsole.
Write(
_T(
"Bad parameter: "));
105 rConsole.
Write(pchParameter);
107 }
108 }
109
111
113 {
116 }
117
118 if (blnHelp)
119 {
121 }
122
123 if (blnDo&&blnHelp) rConsole.
Write(
_T(
"\n"));
124
125 if (!blnDo)
126 return 0;
127
129 {
131 return 0;
132 }
133
136 try
137 {
138 DWORD dwSecurityDescriptorLength;
143 dwError =
Key.GetSecurityDescriptorLength(&dwSecurityDescriptorLength);
145
147 DWORD dwSecurityDescriptorLength1 = dwSecurityDescriptorLength;
151 BOOL blnOwnerDefaulted;
154 if (psidOwner ==
NULL)
155 {
156 rConsole.
Write(
_T(
"Key has no owner."));
157 }
158 else
159 {
161 {
162 rConsole.
Write(
_T(
"Key has invalid owner SID."));
163 }
164 else
165 {
166 rConsole.
Write(
_T(
"Key Owner: \n"));
167 DWORD dwSIDStringSize = 0;
173 {
179 rConsole.
Write(
_T(
"\nGetting string representation of SID\n"));
180 }
181 else
182 {
184 rConsole.
Write(pchSID);
186 }
187 delete [] pchSID;
188 DWORD dwNameBufferLength, dwDomainNameBufferLength;
189 dwNameBufferLength = 1024;
190 dwDomainNameBufferLength = 1024;
191 pchName =
new TCHAR [dwNameBufferLength];
192 pchDomainName =
new TCHAR [dwDomainNameBufferLength];
193 DWORD dwNameLength = dwNameBufferLength, dwDomainNameLength = dwDomainNameBufferLength;
195 if (!
LookupAccountSid(
NULL,psidOwner,pchName,&dwNameLength,pchDomainName,&dwDomainNameLength,&Use))
197 else
198 {
199 rConsole.
Write(
_T(
"\tOwner Domain: "));
200 rConsole.
Write(pchDomainName);
202 rConsole.
Write(
_T(
"\tOwner Name: "));
203 rConsole.
Write(pchName);
204 rConsole.
Write(
_T(
"\n\tSID type: "));
207 rConsole.
Write(
_T(
"\tOwner defaulted: "));
208 rConsole.
Write(blnOwnerDefaulted?
_T(
"Yes"):
_T(
"No"));
210 }
211 delete [] pchName;
213 delete [] pchDomainName;
214 pchDomainName =
NULL;
215
216 }
217 }
218 delete [] pSecurityDescriptor;
219 }
220 catch (
DWORD dwError)
221 {
226 if (pchName) delete [] pchName;
227 if (pchDomainName) delete [] pchDomainName;
228 if (pSecurityDescriptor) delete [] pSecurityDescriptor;
229 }
230
231 return 0;
232}
#define COMMAND_NA_ON_ROOT
const TCHAR * GetSidTypeName(SID_NAME_USE Use)
BOOL GetTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen)
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetLastErrorDescription()
virtual const TCHAR * GetHelpString()
#define ERROR_INSUFFICIENT_BUFFER
BOOL WINAPI IsValidSid(PSID pSid)
_CRTIMP char *__cdecl _itoa(_In_ int _Value, _Pre_notnull_ _Post_z_ char *_Dest, _In_ int _Radix)
enum _SID_NAME_USE SID_NAME_USE
DWORD SECURITY_INFORMATION
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted)
DWORD WINAPI GetLastError(void)
#define OWNER_SECURITY_INFORMATION
struct _SECURITY_DESCRIPTOR * PISECURITY_DESCRIPTOR