2 * Unit tests for lsa functions
4 * Copyright (c) 2006 Robert Reif
5 * Copyright (c) 2020 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library 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 GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define WIN32_NO_STATUS
35 #include "wine/test.h"
39 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
41 static BOOL (WINAPI
*pGetSystemPreferredUILanguages
)(DWORD
, ULONG
*, WCHAR
*, ULONG
*);
42 static NTSTATUS (WINAPI
*pLsaGetUserName
)(PUNICODE_STRING
*user
, PUNICODE_STRING
*domain
);
44 static void test_lsa(void)
48 LSA_OBJECT_ATTRIBUTES object_attributes
;
50 ZeroMemory(&object_attributes
, sizeof(object_attributes
));
51 object_attributes
.Length
= sizeof(object_attributes
);
53 status
= LsaOpenPolicy( NULL
, &object_attributes
, POLICY_ALL_ACCESS
, &handle
);
54 ok(status
== STATUS_SUCCESS
|| status
== STATUS_ACCESS_DENIED
,
55 "LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08lx\n", status
);
57 /* try a more restricted access mask if necessary */
58 if (status
== STATUS_ACCESS_DENIED
) {
59 trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES\n");
60 status
= LsaOpenPolicy( NULL
, &object_attributes
, POLICY_VIEW_LOCAL_INFORMATION
|POLICY_LOOKUP_NAMES
, &handle
);
61 ok(status
== STATUS_SUCCESS
, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION|POLICY_LOOKUP_NAMES) returned 0x%08lx\n", status
);
64 if (status
== STATUS_SUCCESS
) {
65 PPOLICY_AUDIT_EVENTS_INFO audit_events_info
;
66 PPOLICY_PRIMARY_DOMAIN_INFO primary_domain_info
;
67 PPOLICY_ACCOUNT_DOMAIN_INFO account_domain_info
;
68 PPOLICY_DNS_DOMAIN_INFO dns_domain_info
;
72 status
= LsaQueryInformationPolicy(handle
, PolicyAuditEventsInformation
, (void **)&audit_events_info
);
73 if (status
== STATUS_ACCESS_DENIED
)
74 skip("Not enough rights to retrieve PolicyAuditEventsInformation\n");
76 ok(status
== STATUS_SUCCESS
, "LsaQueryInformationPolicy(PolicyAuditEventsInformation) failed, returned 0x%08lx\n", status
);
77 if (status
== STATUS_SUCCESS
)
78 LsaFreeMemory(audit_events_info
);
80 status
= LsaQueryInformationPolicy(handle
, PolicyPrimaryDomainInformation
, (void **)&primary_domain_info
);
81 ok(status
== STATUS_SUCCESS
, "LsaQueryInformationPolicy(PolicyPrimaryDomainInformation) failed, returned 0x%08lx\n", status
);
82 if (status
== STATUS_SUCCESS
) {
83 if (primary_domain_info
->Sid
) {
85 if (ConvertSidToStringSidA(primary_domain_info
->Sid
, &strsid
))
87 if (primary_domain_info
->Name
.Buffer
) {
90 len
= WideCharToMultiByte( CP_ACP
, 0, primary_domain_info
->Name
.Buffer
, -1, NULL
, 0, NULL
, NULL
);
91 name
= LocalAlloc( 0, len
);
92 WideCharToMultiByte( CP_ACP
, 0, primary_domain_info
->Name
.Buffer
, -1, name
, len
, NULL
, NULL
);
93 trace(" name: %s sid: %s\n", name
, strsid
);
96 trace(" name: NULL sid: %s\n", strsid
);
100 trace("invalid sid\n");
103 trace("Running on a standalone system.\n");
104 LsaFreeMemory(primary_domain_info
);
107 status
= LsaQueryInformationPolicy(handle
, PolicyAccountDomainInformation
, (void **)&account_domain_info
);
108 ok(status
== STATUS_SUCCESS
, "LsaQueryInformationPolicy(PolicyAccountDomainInformation) failed, returned 0x%08lx\n", status
);
109 if (status
== STATUS_SUCCESS
)
110 LsaFreeMemory(account_domain_info
);
112 /* This isn't supported in NT4 */
113 status
= LsaQueryInformationPolicy(handle
, PolicyDnsDomainInformation
, (void **)&dns_domain_info
);
114 ok(status
== STATUS_SUCCESS
|| status
== STATUS_INVALID_PARAMETER
,
115 "LsaQueryInformationPolicy(PolicyDnsDomainInformation) failed, returned 0x%08lx\n", status
);
116 if (status
== STATUS_SUCCESS
) {
117 if (dns_domain_info
->Sid
|| !IsEqualGUID(&dns_domain_info
->DomainGuid
, &GUID_NULL
)) {
123 ConvertSidToStringSidA(dns_domain_info
->Sid
, &strsid
);
124 if (dns_domain_info
->Name
.Buffer
) {
125 len
= WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->Name
.Buffer
, -1, NULL
, 0, NULL
, NULL
);
126 name
= LocalAlloc( 0, len
);
127 WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->Name
.Buffer
, -1, name
, len
, NULL
, NULL
);
129 if (dns_domain_info
->DnsDomainName
.Buffer
) {
130 len
= WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->DnsDomainName
.Buffer
, -1, NULL
, 0, NULL
, NULL
);
131 domain
= LocalAlloc( 0, len
);
132 WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->DnsDomainName
.Buffer
, -1, domain
, len
, NULL
, NULL
);
134 if (dns_domain_info
->DnsForestName
.Buffer
) {
135 len
= WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->DnsForestName
.Buffer
, -1, NULL
, 0, NULL
, NULL
);
136 forest
= LocalAlloc( 0, len
);
137 WideCharToMultiByte( CP_ACP
, 0, dns_domain_info
->DnsForestName
.Buffer
, -1, forest
, len
, NULL
, NULL
);
139 trace(" name: %s domain: %s forest: %s guid: %s sid: %s\n",
140 debugstr_a(name
), debugstr_a(domain
), debugstr_a(forest
),
141 debugstr_guid(&dns_domain_info
->DomainGuid
), debugstr_a(strsid
));
148 trace("Running on a standalone system.\n");
149 LsaFreeMemory(dns_domain_info
);
152 /* We need a valid SID to pass to LsaEnumerateAccountRights */
153 ret
= OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY
, &token
);
154 ok(ret
, "Unable to obtain process token, error %lu\n", GetLastError( ));
158 TOKEN_USER
*token_user
= (TOKEN_USER
*) buffer
;
159 ret
= GetTokenInformation( token
, TokenUser
, (LPVOID
) token_user
, sizeof(buffer
), &len
);
160 ok(ret
|| GetLastError( ) == ERROR_INSUFFICIENT_BUFFER
, "Unable to obtain token information, error %lu\n", GetLastError( ));
161 if (! ret
&& GetLastError( ) == ERROR_INSUFFICIENT_BUFFER
) {
162 trace("Resizing buffer to %lu.\n", len
);
163 token_user
= LocalAlloc( 0, len
);
164 if (token_user
!= NULL
)
165 ret
= GetTokenInformation( token
, TokenUser
, (LPVOID
) token_user
, len
, &len
);
169 PLSA_UNICODE_STRING rights
;
171 rights
= (PLSA_UNICODE_STRING
) 0xdeadbeaf;
172 rights_count
= 0xcafecafe;
173 status
= LsaEnumerateAccountRights(handle
, token_user
->User
.Sid
, &rights
, &rights_count
);
174 ok(status
== STATUS_SUCCESS
|| status
== STATUS_OBJECT_NAME_NOT_FOUND
, "Unexpected status 0x%lx\n", status
);
175 if (status
== STATUS_SUCCESS
)
176 LsaFreeMemory( rights
);
178 ok(rights
== NULL
&& rights_count
== 0, "Expected rights and rights_count to be set to 0 on failure\n");
180 if (token_user
!= NULL
&& token_user
!= (TOKEN_USER
*) buffer
)
181 LocalFree( token_user
);
182 CloseHandle( token
);
185 status
= LsaClose(handle
);
186 ok(status
== STATUS_SUCCESS
, "LsaClose() failed, returned 0x%08lx\n", status
);
190 static void get_sid_info(PSID psid
, LPSTR
*user
, LPSTR
*dom
)
192 static char account
[257], domain
[257];
193 DWORD user_size
, dom_size
;
200 user_size
= dom_size
= 257;
201 account
[0] = domain
[0] = 0;
202 ret
= LookupAccountSidA(NULL
, psid
, account
, &user_size
, domain
, &dom_size
, &use
);
203 ok(ret
, "LookupAccountSidA failed %lu\n", GetLastError());
206 static void test_LsaLookupNames2(void)
208 static const WCHAR n1
[] = {'L','O','C','A','L',' ','S','E','R','V','I','C','E'};
209 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'};
213 LSA_OBJECT_ATTRIBUTES attrs
;
214 PLSA_REFERENCED_DOMAIN_LIST domains
;
215 PLSA_TRANSLATED_SID2 sids
;
216 LSA_UNICODE_STRING name
[3];
217 LPSTR account
, sid_dom
;
219 if ((PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) != LANG_ENGLISH
) ||
220 (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH
))
222 skip("Non-English locale (skipping LsaLookupNames2 tests)\n");
226 memset(&attrs
, 0, sizeof(attrs
));
227 attrs
.Length
= sizeof(attrs
);
229 status
= LsaOpenPolicy(NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
);
230 ok(status
== STATUS_SUCCESS
|| status
== STATUS_ACCESS_DENIED
,
231 "LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08lx\n", status
);
233 /* try a more restricted access mask if necessary */
234 if (status
== STATUS_ACCESS_DENIED
)
236 trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION\n");
237 status
= LsaOpenPolicy(NULL
, &attrs
, POLICY_LOOKUP_NAMES
, &handle
);
238 ok(status
== STATUS_SUCCESS
, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION) returned 0x%08lx\n", status
);
240 if (status
!= STATUS_SUCCESS
)
242 skip("Cannot acquire policy handle\n");
246 name
[0].Buffer
= malloc(sizeof(n1
));
247 name
[0].Length
= name
[0].MaximumLength
= sizeof(n1
);
248 memcpy(name
[0].Buffer
, n1
, sizeof(n1
));
250 name
[1].Buffer
= malloc(sizeof(n1
));
251 name
[1].Length
= name
[1].MaximumLength
= sizeof(n1
) - sizeof(WCHAR
);
252 memcpy(name
[1].Buffer
, n1
, sizeof(n1
) - sizeof(WCHAR
));
254 name
[2].Buffer
= malloc(sizeof(n2
));
255 name
[2].Length
= name
[2].MaximumLength
= sizeof(n2
);
256 memcpy(name
[2].Buffer
, n2
, sizeof(n2
));
258 /* account name only */
261 status
= LsaLookupNames2(handle
, 0, 1, &name
[0], &domains
, &sids
);
262 ok(status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %lx)\n", status
);
263 ok(sids
[0].Use
== SidTypeWellKnownGroup
, "expected SidTypeWellKnownGroup, got %u\n", sids
[0].Use
);
264 ok(sids
[0].Flags
== 0, "expected 0, got 0x%08lx\n", sids
[0].Flags
);
265 ok(domains
->Entries
== 1, "expected 1, got %lu\n", domains
->Entries
);
266 get_sid_info(sids
[0].Sid
, &account
, &sid_dom
);
267 ok(!strcmp(account
, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account
);
268 ok(!strcmp(sid_dom
, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom
);
270 LsaFreeMemory(domains
);
272 /* unknown account name */
275 status
= LsaLookupNames2(handle
, 0, 1, &name
[1], &domains
, &sids
);
276 ok(status
== STATUS_NONE_MAPPED
, "expected STATUS_NONE_MAPPED, got %lx)\n", status
);
277 ok(sids
[0].Use
== SidTypeUnknown
, "expected SidTypeUnknown, got %u\n", sids
[0].Use
);
278 ok(sids
[0].Flags
== 0, "expected 0, got 0x%08lx\n", sids
[0].Flags
);
279 ok(domains
->Entries
== 0, "expected 0, got %lu\n", domains
->Entries
);
281 LsaFreeMemory(domains
);
283 /* account + domain */
286 status
= LsaLookupNames2(handle
, 0, 1, &name
[2], &domains
, &sids
);
287 ok(status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %lx)\n", status
);
288 ok(sids
[0].Use
== SidTypeWellKnownGroup
, "expected SidTypeWellKnownGroup, got %u\n", sids
[0].Use
);
289 ok(sids
[0].Flags
== 0, "expected 0, got 0x%08lx\n", sids
[0].Flags
);
290 ok(domains
->Entries
== 1, "expected 1, got %lu\n", domains
->Entries
);
291 get_sid_info(sids
[0].Sid
, &account
, &sid_dom
);
292 ok(!strcmp(account
, "LOCAL SERVICE"), "expected \"LOCAL SERVICE\", got \"%s\"\n", account
);
293 ok(!strcmp(sid_dom
, "NT AUTHORITY"), "expected \"NT AUTHORITY\", got \"%s\"\n", sid_dom
);
295 LsaFreeMemory(domains
);
300 status
= LsaLookupNames2(handle
, 0, 3, name
, &domains
, &sids
);
301 ok(status
== STATUS_SOME_NOT_MAPPED
, "expected STATUS_SOME_NOT_MAPPED, got %lx)\n", status
);
302 ok(sids
[0].Use
== SidTypeWellKnownGroup
, "expected SidTypeWellKnownGroup, got %u\n", sids
[0].Use
);
303 ok(sids
[1].Use
== SidTypeUnknown
, "expected SidTypeUnknown, got %u\n", sids
[1].Use
);
304 ok(sids
[2].Use
== SidTypeWellKnownGroup
, "expected SidTypeWellKnownGroup, got %u\n", sids
[2].Use
);
305 ok(sids
[0].DomainIndex
== 0, "expected 0, got %lu\n", sids
[0].DomainIndex
);
306 ok(domains
->Entries
== 1, "expected 1, got %lu\n", domains
->Entries
);
308 LsaFreeMemory(domains
);
310 free(name
[0].Buffer
);
311 free(name
[1].Buffer
);
312 free(name
[2].Buffer
);
314 status
= LsaClose(handle
);
315 ok(status
== STATUS_SUCCESS
, "LsaClose() failed, returned 0x%08lx\n", status
);
318 static void check_unicode_string_(int line
, const LSA_UNICODE_STRING
*string
, const WCHAR
*expect
)
320 ok_(__FILE__
, line
)(string
->Length
== wcslen(string
->Buffer
) * sizeof(WCHAR
),
321 "expected %Iu, got %u\n", wcslen(string
->Buffer
) * sizeof(WCHAR
), string
->Length
);
322 ok_(__FILE__
, line
)(string
->MaximumLength
== string
->Length
+ sizeof(WCHAR
),
323 "expected %Iu, got %u\n", string
->Length
+ sizeof(WCHAR
), string
->MaximumLength
);
324 ok_(__FILE__
, line
)(!wcsicmp(string
->Buffer
, expect
), "expected %s, got %s\n",
325 debugstr_w(expect
), debugstr_w(string
->Buffer
));
327 #define check_unicode_string(a, b) check_unicode_string_(__LINE__, a, b)
329 static void test_LsaLookupSids(void)
332 char user_buffer
[64];
333 LSA_OBJECT_ATTRIBUTES attrs
= {sizeof(attrs
)};
334 TOKEN_USER
*user
= (TOKEN_USER
*)user_buffer
;
335 WCHAR computer_name
[64], user_name
[64];
336 LSA_REFERENCED_DOMAIN_LIST
*list
;
337 LSA_TRANSLATED_NAME
*names
;
345 status
= LsaOpenPolicy(NULL
, &attrs
, POLICY_LOOKUP_NAMES
, &policy
);
346 ok(status
== STATUS_SUCCESS
, "got 0x%08lx\n", status
);
348 ret
= OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED
, &token
);
349 ok(ret
, "OpenProcessToken() failed, error %lu\n", GetLastError());
351 ret
= GetTokenInformation(token
, TokenUser
, user
, sizeof(user_buffer
), &size
);
352 ok(ret
, "GetTokenInformation() failed, error %lu\n", GetLastError());
354 size
= ARRAY_SIZE(computer_name
);
355 ret
= GetComputerNameW(computer_name
, &size
);
356 ok(ret
, "GetComputerName() failed, error %lu\n", GetLastError());
358 size
= ARRAY_SIZE(user_name
);
359 ret
= GetUserNameW(user_name
, &size
);
360 ok(ret
, "GetUserName() failed, error %lu\n", GetLastError());
362 status
= LsaLookupSids(policy
, 1, &user
->User
.Sid
, &list
, &names
);
363 ok(status
== STATUS_SUCCESS
, "got 0x%08lx\n", status
);
365 ok(list
->Entries
== 1, "got %ld\n", list
->Entries
);
366 check_unicode_string(&list
->Domains
[0].Name
, computer_name
);
368 ok(names
[0].Use
== SidTypeUser
, "got type %u\n", names
[0].Use
);
369 ok(!names
[0].DomainIndex
, "got index %lu\n", names
[0].DomainIndex
);
370 check_unicode_string(&names
[0].Name
, user_name
);
372 LsaFreeMemory(names
);
376 ret
= ConvertStringSidToSidA("S-1-1-0", &sid
);
377 ok(ret
, "ConvertStringSidToSidA() failed, error %lu\n", GetLastError());
379 status
= LsaLookupSids(policy
, 1, &sid
, &list
, &names
);
380 ok(status
== STATUS_SUCCESS
, "got 0x%08lx\n", status
);
382 ok(list
->Entries
== 1, "got %ld\n", list
->Entries
);
383 check_unicode_string(&list
->Domains
[0].Name
, L
"");
385 ok(names
[0].Use
== SidTypeWellKnownGroup
, "got type %u\n", names
[0].Use
);
386 ok(!names
[0].DomainIndex
, "got index %lu\n", names
[0].DomainIndex
);
388 /* The group name gets translated... but not in all locales */
389 size
= ARRAY_SIZE(langW
);
390 if (!pGetSystemPreferredUILanguages
||
391 !pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID
, &num
, langW
, &size
))
393 if (wcscmp(langW
, L
"0409") == 0 || wcscmp(langW
, L
"0411") == 0)
394 /* English and Japanese */
395 check_unicode_string(&names
[0].Name
, L
"Everyone");
396 else if (wcscmp(langW
, L
"0407") == 0) /* German */
397 todo_wine
ok(!wcsicmp(names
[0].Name
.Buffer
, L
"Jeder"), "missing translation %s\n",
398 debugstr_w(names
[0].Name
.Buffer
));
399 else if (wcscmp(langW
, L
"040C") == 0) /* French */
400 todo_wine
ok(!wcsicmp(names
[0].Name
.Buffer
, L
"Tout le monde"), "missing translation %s\n",
401 debugstr_w(names
[0].Name
.Buffer
));
403 trace("<Everyone-group>.Name=%s\n", debugstr_w(names
[0].Name
.Buffer
));
405 LsaFreeMemory(names
);
409 ret
= ConvertStringSidToSidA("S-1-1234-5678-1234-5678", &sid
);
410 ok(ret
, "ConvertStringSidToSidA() failed, error %lu\n", GetLastError());
412 status
= LsaLookupSids(policy
, 1, &sid
, &list
, &names
);
413 ok(status
== STATUS_NONE_MAPPED
, "got 0x%08lx\n", status
);
415 ok(!list
->Entries
, "got %ld\n", list
->Entries
);
417 ok(names
[0].Use
== SidTypeUnknown
, "got type %u\n", names
[0].Use
);
418 ok(names
[0].DomainIndex
== -1, "got index %lu\n", names
[0].DomainIndex
);
419 check_unicode_string(&names
[0].Name
, L
"S-1-1234-5678-1234-5678");
421 LsaFreeMemory(names
);
425 status
= LsaClose(policy
);
426 ok(status
== STATUS_SUCCESS
, "got 0x%08lx\n", status
);
429 static void test_LsaLookupPrivilegeName(void)
431 LSA_OBJECT_ATTRIBUTES attrs
;
432 LSA_UNICODE_STRING
*name
;
437 memset(&attrs
, 0, sizeof(attrs
));
438 attrs
.Length
= sizeof(attrs
);
440 status
= LsaOpenPolicy(NULL
, &attrs
, POLICY_LOOKUP_NAMES
, &policy
);
441 ok(status
== STATUS_SUCCESS
, "Failed to open policy, %#lx.\n", status
);
443 name
= (void *)0xdeadbeef;
444 status
= LsaLookupPrivilegeName(policy
, NULL
, &name
);
445 ok(status
!= STATUS_SUCCESS
, "Unexpected status %#lx.\n", status
);
446 ok(name
== (void *)0xdeadbeef, "Unexpected name pointer.\n");
448 name
= (void *)0xdeadbeef;
450 luid
.LowPart
= SE_CREATE_TOKEN_PRIVILEGE
;
451 status
= LsaLookupPrivilegeName(policy
, &luid
, &name
);
452 ok(status
== STATUS_NO_SUCH_PRIVILEGE
, "Unexpected status %#lx.\n", status
);
453 ok(name
== NULL
, "Unexpected name pointer.\n");
456 luid
.LowPart
= SE_CREATE_TOKEN_PRIVILEGE
;
457 status
= LsaLookupPrivilegeName(policy
, &luid
, &name
);
458 ok(status
== 0, "got %#lx.\n", status
);
462 static void test_LsaGetUserName(void)
466 UNICODE_STRING
*lsa_user
, *lsa_domain
;
467 WCHAR user
[256], computer
[256];
470 if (!pLsaGetUserName
)
472 skip("LsaGetUserName is not available on this platform\n");
476 size
= ARRAY_SIZE(user
);
477 ret
= GetUserNameW(user
, &size
);
478 ok(ret
, "GetUserName error %lu\n", GetLastError());
480 size
= ARRAY_SIZE(computer
);
481 ret
= GetComputerNameW(computer
, &size
);
482 ok(ret
, "GetComputerName error %lu\n", GetLastError());
484 if (0) /* crashes under Windows */
485 status
= pLsaGetUserName(NULL
, NULL
);
487 if (0) /* crashes under Windows */
488 status
= pLsaGetUserName(NULL
, &lsa_domain
);
490 status
= pLsaGetUserName(&lsa_user
, NULL
);
491 ok(!status
, "got %#lx\n", status
);
492 check_unicode_string(lsa_user
, user
);
493 LsaFreeMemory(lsa_user
);
495 status
= pLsaGetUserName(&lsa_user
, &lsa_domain
);
496 ok(!status
, "got %#lx\n", status
);
497 ok(!lstrcmpW(user
, lsa_user
->Buffer
), "%s != %s\n", wine_dbgstr_w(user
), wine_dbgstr_wn(lsa_user
->Buffer
, lsa_user
->Length
/sizeof(WCHAR
)));
498 check_unicode_string(lsa_user
, user
);
499 check_unicode_string(lsa_domain
, computer
);
500 LsaFreeMemory(lsa_user
);
501 LsaFreeMemory(lsa_domain
);
506 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
507 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
509 pGetSystemPreferredUILanguages
= (void*)GetProcAddress(hkernel32
, "GetSystemPreferredUILanguages");
510 pLsaGetUserName
= (void *)GetProcAddress(hadvapi32
, "LsaGetUserName");
513 test_LsaLookupNames2();
514 test_LsaLookupSids();
515 test_LsaLookupPrivilegeName();
516 test_LsaGetUserName();