ReactOS 0.4.15-dev-8231-g29a56f3
lsa.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "ntsecapi.h"
#include "sddl.h"
#include "winnls.h"
#include "objbase.h"
#include "initguid.h"
#include "wine/test.h"
#include "winternl.h"
#include "ntlsa.h"
Include dependency graph for lsa.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static void test_lsa (void)
 
static void get_sid_info (PSID psid, LPSTR *user, LPSTR *dom)
 
static void test_LsaLookupNames2 (void)
 
static void test_LsaLookupSids (void)
 
static void test_LsaLookupPrivilegeName (void)
 
 START_TEST (lsa)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file lsa.c.

Function Documentation

◆ DEFINE_GUID()

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ get_sid_info()

static void get_sid_info ( PSID  psid,
LPSTR user,
LPSTR dom 
)
static

Definition at line 209 of file lsa.c.

210{
211 static char account[257], domain[257];
212 DWORD user_size, dom_size;
213 SID_NAME_USE use;
214 BOOL ret;
215
216 *user = account;
217 *dom = domain;
218
219 user_size = dom_size = 257;
220 account[0] = domain[0] = 0;
221 ret = LookupAccountSidA(NULL, psid, account, &user_size, domain, &dom_size, &use);
222 ok(ret, "LookupAccountSidA failed %u\n", GetLastError());
223}
#define ok(value,...)
Definition: atltest.h:57
void account(int argc, const char *argv[])
Definition: cmds.c:1690
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define NULL
Definition: types.h:112
BOOL WINAPI LookupAccountSidA(LPCSTR lpSystemName, PSID lpSid, LPSTR lpName, LPDWORD cchName, LPSTR lpReferencedDomainName, LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse)
Definition: misc.c:405
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
enum _SID_NAME_USE SID_NAME_USE
Definition: cookie.c:42
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_LsaLookupNames2().

◆ START_TEST()

START_TEST ( lsa  )

Definition at line 444 of file lsa.c.

445{
446 test_lsa();
450}
static void test_LsaLookupSids(void)
Definition: lsa.c:337
static void test_LsaLookupPrivilegeName(void)
Definition: lsa.c:411
static void test_lsa(void)
Definition: lsa.c:45
static void test_LsaLookupNames2(void)
Definition: lsa.c:225

◆ test_lsa()

static void test_lsa ( void  )
static

Definition at line 45 of file lsa.c.

46{
47 static WCHAR machineW[] = {'W','i','n','e','N','o','M','a','c','h','i','n','e',0};
51 LSA_OBJECT_ATTRIBUTES object_attributes;
52
53 ZeroMemory(&object_attributes, sizeof(object_attributes));
54 object_attributes.Length = sizeof(object_attributes);
55
56 machine.Buffer = machineW;
57 machine.Length = sizeof(machineW) - 2;
58 machine.MaximumLength = sizeof(machineW);
59
60 status = LsaOpenPolicy( &machine, &object_attributes, POLICY_LOOKUP_NAMES, &handle);
62 "LsaOpenPolicy(POLICY_LOOKUP_NAMES) for invalid machine returned 0x%08x\n", status);
63
64 status = LsaOpenPolicy( NULL, &object_attributes, POLICY_ALL_ACCESS, &handle);
66 "LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
67
68 /* try a more restricted access mask if necessary */
70 trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES\n");
72 ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES) returned 0x%08x\n", status);
73 }
74
75 if (status == STATUS_SUCCESS) {
76 PPOLICY_AUDIT_EVENTS_INFO audit_events_info;
77 PPOLICY_PRIMARY_DOMAIN_INFO primary_domain_info;
78 PPOLICY_ACCOUNT_DOMAIN_INFO account_domain_info;
79 PPOLICY_DNS_DOMAIN_INFO dns_domain_info;
81 BOOL ret;
82
85 skip("Not enough rights to retrieve PolicyAuditEventsInformation\n");
86 else
87 ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAuditEventsInformation) failed, returned 0x%08x\n", status);
89 LsaFreeMemory(audit_events_info);
90
92 ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyPrimaryDomainInformation) failed, returned 0x%08x\n", status);
93 if (status == STATUS_SUCCESS) {
94 if (primary_domain_info->Sid) {
95 LPSTR strsid;
96 if (ConvertSidToStringSidA(primary_domain_info->Sid, &strsid))
97 {
98 if (primary_domain_info->Name.Buffer) {
99 LPSTR name = NULL;
100 UINT len;
101 len = WideCharToMultiByte( CP_ACP, 0, primary_domain_info->Name.Buffer, -1, NULL, 0, NULL, NULL );
102 name = LocalAlloc( 0, len );
103 WideCharToMultiByte( CP_ACP, 0, primary_domain_info->Name.Buffer, -1, name, len, NULL, NULL );
104 trace(" name: %s sid: %s\n", name, strsid);
105 LocalFree( name );
106 } else
107 trace(" name: NULL sid: %s\n", strsid);
108 LocalFree( strsid );
109 }
110 else
111 trace("invalid sid\n");
112 }
113 else
114 trace("Running on a standalone system.\n");
115 LsaFreeMemory(primary_domain_info);
116 }
117
119 ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAccountDomainInformation) failed, returned 0x%08x\n", status);
120 if (status == STATUS_SUCCESS)
121 LsaFreeMemory(account_domain_info);
122
123 /* This isn't supported in NT4 */
126 "LsaQueryInformationPolicy(PolicyDnsDomainInformation) failed, returned 0x%08x\n", status);
127 if (status == STATUS_SUCCESS) {
128 if (dns_domain_info->Sid || !IsEqualGUID(&dns_domain_info->DomainGuid, &GUID_NULL)) {
129 LPSTR strsid = NULL;
130 LPSTR name = NULL;
131 LPSTR domain = NULL;
132 LPSTR forest = NULL;
133 LPSTR guidstr = NULL;
134 WCHAR guidstrW[64];
135 UINT len;
136 guidstrW[0] = '\0';
137 ConvertSidToStringSidA(dns_domain_info->Sid, &strsid);
138 StringFromGUID2(&dns_domain_info->DomainGuid, guidstrW, sizeof(guidstrW)/sizeof(WCHAR));
139 len = WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, NULL, 0, NULL, NULL );
140 guidstr = LocalAlloc( 0, len );
141 WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, guidstr, len, NULL, NULL );
142 if (dns_domain_info->Name.Buffer) {
143 len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->Name.Buffer, -1, NULL, 0, NULL, NULL );
144 name = LocalAlloc( 0, len );
145 WideCharToMultiByte( CP_ACP, 0, dns_domain_info->Name.Buffer, -1, name, len, NULL, NULL );
146 }
147 if (dns_domain_info->DnsDomainName.Buffer) {
148 len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsDomainName.Buffer, -1, NULL, 0, NULL, NULL );
149 domain = LocalAlloc( 0, len );
150 WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsDomainName.Buffer, -1, domain, len, NULL, NULL );
151 }
152 if (dns_domain_info->DnsForestName.Buffer) {
153 len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsForestName.Buffer, -1, NULL, 0, NULL, NULL );
154 forest = LocalAlloc( 0, len );
155 WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsForestName.Buffer, -1, forest, len, NULL, NULL );
156 }
157 trace(" name: %s domain: %s forest: %s guid: %s sid: %s\n",
158 name ? name : "NULL", domain ? domain : "NULL",
159 forest ? forest : "NULL", guidstr, strsid ? strsid : "NULL");
160 LocalFree( name );
161 LocalFree( forest );
162 LocalFree( domain );
163 LocalFree( guidstr );
164 LocalFree( strsid );
165 }
166 else
167 trace("Running on a standalone system.\n");
168 LsaFreeMemory(dns_domain_info);
169 }
170
171 /* We need a valid SID to pass to LsaEnumerateAccountRights */
173 ok(ret, "Unable to obtain process token, error %u\n", GetLastError( ));
174 if (ret) {
175 char buffer[64];
176 DWORD len;
177 TOKEN_USER *token_user = (TOKEN_USER *) buffer;
178 ret = GetTokenInformation( token, TokenUser, (LPVOID) token_user, sizeof(buffer), &len );
179 ok(ret || GetLastError( ) == ERROR_INSUFFICIENT_BUFFER, "Unable to obtain token information, error %u\n", GetLastError( ));
181 trace("Resizing buffer to %u.\n", len);
182 token_user = LocalAlloc( 0, len );
183 if (token_user != NULL)
184 ret = GetTokenInformation( token, TokenUser, (LPVOID) token_user, len, &len );
185 }
186
187 if (ret) {
188 PLSA_UNICODE_STRING rights;
189 ULONG rights_count;
190 rights = (PLSA_UNICODE_STRING) 0xdeadbeaf;
191 rights_count = 0xcafecafe;
192 status = LsaEnumerateAccountRights(handle, token_user->User.Sid, &rights, &rights_count);
193 ok(status == STATUS_SUCCESS || status == STATUS_OBJECT_NAME_NOT_FOUND, "Unexpected status 0x%x\n", status);
194 if (status == STATUS_SUCCESS)
195 LsaFreeMemory( rights );
196 else
197 ok(rights == NULL && rights_count == 0, "Expected rights and rights_count to be set to 0 on failure\n");
198 }
199 if (token_user != NULL && token_user != (TOKEN_USER *) buffer)
200 LocalFree( token_user );
202 }
203
205 ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
206 }
207}
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
Definition: lsa.c:1183
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
Definition: lsa.c:1473
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:701
NTSTATUS WINAPI LsaEnumerateAccountRights(IN LSA_HANDLE PolicyHandle, IN PSID AccountSid, OUT PLSA_UNICODE_STRING *UserRights, OUT PULONG CountOfRights)
Definition: lsa.c:406
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
Definition: lsa.c:194
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI ConvertSidToStringSidA(PSID Sid, LPSTR *StringSid)
Definition: security.c:3637
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define GetCurrentProcess()
Definition: compat.h:759
#define WideCharToMultiByte
Definition: compat.h:111
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define GUID_NULL
Definition: ks.h:106
static const WCHAR machineW[]
Definition: profile.c:105
static const char machine[]
Definition: profile.c:104
unsigned int UINT
Definition: ndis.h:50
@ PolicyAuditEventsInformation
Definition: ntsecapi.h:244
@ PolicyDnsDomainInformation
Definition: ntsecapi.h:254
@ PolicyPrimaryDomainInformation
Definition: ntsecapi.h:245
@ PolicyAccountDomainInformation
Definition: ntsecapi.h:247
struct _LSA_UNICODE_STRING * PLSA_UNICODE_STRING
#define POLICY_VIEW_LOCAL_INFORMATION
Definition: ntsecapi.h:61
#define POLICY_ALL_ACCESS
Definition: ntsecapi.h:77
#define POLICY_LOOKUP_NAMES
Definition: ntsecapi.h:72
#define RPC_NT_SERVER_UNAVAILABLE
Definition: ntstatus.h:1201
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define STATUS_SUCCESS
Definition: shellext.h:65
LSA_UNICODE_STRING Name
Definition: ntsecapi.h:574
LSA_UNICODE_STRING DnsDomainName
Definition: ntsecapi.h:575
LSA_UNICODE_STRING DnsForestName
Definition: ntsecapi.h:576
LSA_UNICODE_STRING Name
Definition: ntsecapi.h:570
Definition: name.c:39
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define ZeroMemory
Definition: winbase.h:1712
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenUser
Definition: setypes.h:966
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_LsaLookupNames2()

static void test_LsaLookupNames2 ( void  )
static

Definition at line 225 of file lsa.c.

226{
227 static const WCHAR n1[] = {'L','O','C','A','L',' ','S','E','R','V','I','C','E'};
228 static const WCHAR n2[] = {'N','T',' ','A','U','T','H','O','R','I','T','Y','\\','L','o','c','a','l','S','e','r','v','i','c','e'};
229
236 LPSTR account, sid_dom;
237
240 {
241 skip("Non-English locale (skipping LsaLookupNames2 tests)\n");
242 return;
243 }
244
245 memset(&attrs, 0, sizeof(attrs));
246 attrs.Length = sizeof(attrs);
247
250 "LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
251
252 /* try a more restricted access mask if necessary */
254 {
255 trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION\n");
257 ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION) returned 0x%08x\n", status);
258 }
259 if (status != STATUS_SUCCESS)
260 {
261 skip("Cannot acquire policy handle\n");
262 return;
263 }
264
265 name[0].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n1));
266 name[0].Length = name[0].MaximumLength = sizeof(n1);
267 memcpy(name[0].Buffer, n1, sizeof(n1));
268
269 name[1].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n1));
270 name[1].Length = name[1].MaximumLength = sizeof(n1) - sizeof(WCHAR);
271 memcpy(name[1].Buffer, n1, sizeof(n1) - sizeof(WCHAR));
272
273 name[2].Buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(n2));
274 name[2].Length = name[2].MaximumLength = sizeof(n2);
275 memcpy(name[2].Buffer, n2, sizeof(n2));
276
277 /* account name only */
278 sids = NULL;
279 domains = NULL;
280 status = LsaLookupNames2(handle, 0, 1, &name[0], &domains, &sids);
281 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %x)\n", status);
282 ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
283 ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
284 ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
285 get_sid_info(sids[0].Sid, &account, &sid_dom);
286 ok(!strcmp(account, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account);
287 ok(!strcmp(sid_dom, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom);
288 LsaFreeMemory(sids);
289 LsaFreeMemory(domains);
290
291 /* unknown account name */
292 sids = NULL;
293 domains = NULL;
294 status = LsaLookupNames2(handle, 0, 1, &name[1], &domains, &sids);
295 ok(status == STATUS_NONE_MAPPED, "expected STATUS_NONE_MAPPED, got %x)\n", status);
296 ok(sids[0].Use == SidTypeUnknown, "expected SidTypeUnknown, got %u\n", sids[0].Use);
297 ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
298 ok(domains->Entries == 0, "expected 0, got %u\n", domains->Entries);
299 LsaFreeMemory(sids);
300 LsaFreeMemory(domains);
301
302 /* account + domain */
303 sids = NULL;
304 domains = NULL;
305 status = LsaLookupNames2(handle, 0, 1, &name[2], &domains, &sids);
306 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %x)\n", status);
307 ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
308 ok(sids[0].Flags == 0, "expected 0, got 0x%08x\n", sids[0].Flags);
309 ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
310 get_sid_info(sids[0].Sid, &account, &sid_dom);
311 ok(!strcmp(account, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account);
312 ok(!strcmp(sid_dom, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom);
313 LsaFreeMemory(sids);
314 LsaFreeMemory(domains);
315
316 /* all three */
317 sids = NULL;
318 domains = NULL;
319 status = LsaLookupNames2(handle, 0, 3, name, &domains, &sids);
320 ok(status == STATUS_SOME_NOT_MAPPED, "expected STATUS_SOME_NOT_MAPPED, got %x)\n", status);
321 ok(sids[0].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[0].Use);
322 ok(sids[1].Use == SidTypeUnknown, "expected SidTypeUnknown, got %u\n", sids[1].Use);
323 ok(sids[2].Use == SidTypeWellKnownGroup, "expected SidTypeWellKnownGroup, got %u\n", sids[2].Use);
324 ok(sids[0].DomainIndex == 0, "expected 0, got %u\n", sids[0].DomainIndex);
325 ok(domains->Entries == 1, "expected 1, got %u\n", domains->Entries);
326 LsaFreeMemory(sids);
327 LsaFreeMemory(domains);
328
332
334 ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
335}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: bufpool.h:45
NTSTATUS WINAPI LsaLookupNames2(IN LSA_HANDLE PolicyHandle, IN ULONG Flags, IN ULONG Count, IN PLSA_UNICODE_STRING Names, OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, OUT PLSA_TRANSLATED_SID2 *Sids)
Definition: lsa.c:906
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2800
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
@ SidTypeUnknown
Definition: lsa.idl:125
@ SidTypeWellKnownGroup
Definition: lsa.idl:122
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void get_sid_info(PSID psid, LPSTR *user, LPSTR *dom)
Definition: lsa.c:209
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1133
#define STATUS_NONE_MAPPED
Definition: ntstatus.h:351
#define STATUS_SOME_NOT_MAPPED
Definition: ntstatus.h:86
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
#define LANG_ENGLISH
Definition: nls.h:52
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define memset(x, y, z)
Definition: compat.h:39
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by START_TEST().

◆ test_LsaLookupPrivilegeName()

static void test_LsaLookupPrivilegeName ( void  )
static

Definition at line 411 of file lsa.c.

412{
417 LUID luid;
418
419 memset(&attrs, 0, sizeof(attrs));
420 attrs.Length = sizeof(attrs);
421
423 ok(status == STATUS_SUCCESS, "Failed to open policy, %#x.\n", status);
424
425 name = (void *)0xdeadbeef;
427 ok(status != STATUS_SUCCESS, "Unexpected status %#x.\n", status);
428 ok(name == (void *)0xdeadbeef, "Unexpected name pointer.\n");
429
430 name = (void *)0xdeadbeef;
431 luid.HighPart = 1;
434 ok(status == STATUS_NO_SUCH_PRIVILEGE, "Unexpected status %#x.\n", status);
435 ok(name == NULL, "Unexpected name pointer.\n");
436
437 luid.HighPart = 0;
440 ok(status == 0, "got %#x.\n", status);
442}
NTSTATUS WINAPI LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle, IN PLUID Value, OUT PUNICODE_STRING *Name)
Definition: lsa.c:1000
WDF_INTERRUPT_POLICY policy
#define SE_CREATE_TOKEN_PRIVILEGE
Definition: security.c:656
#define STATUS_NO_SUCH_PRIVILEGE
Definition: ntstatus.h:332
LONG HighPart
DWORD LowPart

Referenced by START_TEST().

◆ test_LsaLookupSids()

static void test_LsaLookupSids ( void  )
static

Definition at line 337 of file lsa.c.

338{
346 DWORD size;
347 BOOL ret;
348 PSID sid;
349
350 memset(&attrs, 0, sizeof(attrs));
351 attrs.Length = sizeof(attrs);
352
354 ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
355
357 ok(ret, "got %d\n", ret);
358
360 ok(!ret, "got %d\n", ret);
361
364 ok(ret, "got %d\n", ret);
365
366 status = LsaLookupSids(policy, 1, &user->User.Sid, &list, &names);
367 ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
368
369 ok(list->Entries > 0, "got %d\n", list->Entries);
370 if (list->Entries)
371 {
372 ok((char*)list->Domains - (char*)list > 0, "%p, %p\n", list, list->Domains);
373 ok((char*)list->Domains[0].Sid - (char*)list->Domains > 0, "%p, %p\n", list->Domains, list->Domains[0].Sid);
374 ok(list->Domains[0].Name.MaximumLength > list->Domains[0].Name.Length, "got %d, %d\n", list->Domains[0].Name.MaximumLength,
375 list->Domains[0].Name.Length);
376 }
377
380
382
384
385 ret = ConvertStringSidToSidA("S-1-1-0", &sid);
386 ok(ret == TRUE, "ConvertStringSidToSidA returned false\n");
387
389 ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
390
391 ok(list->Entries > 0, "got %d\n", list->Entries);
392
393 if (list->Entries)
394 {
395 ok((char*)list->Domains - (char*)list > 0, "%p, %p\n", list, list->Domains);
396 ok((char*)list->Domains[0].Sid - (char*)list->Domains > 0, "%p, %p\n", list->Domains, list->Domains[0].Sid);
397 ok(list->Domains[0].Name.MaximumLength > list->Domains[0].Name.Length, "got %d, %d\n", list->Domains[0].Name.MaximumLength,
398 list->Domains[0].Name.Length);
399 ok(list->Domains[0].Name.Buffer != NULL, "domain[0] name buffer is null\n");
400 }
401
404
405 FreeSid(sid);
406
408 ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
409}
FT_UInt sid
Definition: cffcmap.c:139
Definition: list.h:37
#define TRUE
Definition: types.h:120
NTSTATUS WINAPI LsaLookupSids(IN LSA_HANDLE PolicyHandle, IN ULONG Count, IN PSID *Sids, OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, OUT PLSA_TRANSLATED_NAME *Names)
Definition: lsa.c:1069
BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID *Sid)
Definition: security.c:3560
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
GLsizeiptr size
Definition: glext.h:5919
GLuint GLuint * names
Definition: glext.h:11545
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define list
Definition: rosglue.h:35

Referenced by START_TEST().