~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/advapi32/tests/lsa.c

Version: ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit tests for lsa functions
  3  *
  4  * Copyright (c) 2006 Robert Reif
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <stdarg.h>
 22 #include <stdio.h>
 23 
 24 #include "ntstatus.h"
 25 #define WIN32_NO_STATUS
 26 #include "windef.h"
 27 #include "winbase.h"
 28 #include "winreg.h"
 29 #include "ntsecapi.h"
 30 #include "sddl.h"
 31 #include "winnls.h"
 32 #include "objbase.h"
 33 #define INITGUID
 34 #include "guiddef.h"
 35 #include "wine/test.h"
 36 
 37 static HMODULE hadvapi32;
 38 static NTSTATUS (WINAPI *pLsaClose)(LSA_HANDLE);
 39 static NTSTATUS (WINAPI *pLsaFreeMemory)(PVOID);
 40 static NTSTATUS (WINAPI *pLsaOpenPolicy)(PLSA_UNICODE_STRING,PLSA_OBJECT_ATTRIBUTES,ACCESS_MASK,PLSA_HANDLE);
 41 static NTSTATUS (WINAPI *pLsaQueryInformationPolicy)(LSA_HANDLE,POLICY_INFORMATION_CLASS,PVOID*);
 42 static BOOL     (WINAPI *pConvertSidToStringSidA)(PSID pSid, LPSTR *str);
 43 
 44 static BOOL init(void)
 45 {
 46     hadvapi32 = GetModuleHandle("advapi32.dll");
 47 
 48     pLsaClose = (void*)GetProcAddress(hadvapi32, "LsaClose");
 49     pLsaFreeMemory = (void*)GetProcAddress(hadvapi32, "LsaFreeMemory");
 50     pLsaOpenPolicy = (void*)GetProcAddress(hadvapi32, "LsaOpenPolicy");
 51     pLsaQueryInformationPolicy = (void*)GetProcAddress(hadvapi32, "LsaQueryInformationPolicy");
 52     pConvertSidToStringSidA = (void*)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
 53 
 54     if (pLsaClose && pLsaFreeMemory && pLsaOpenPolicy && pLsaQueryInformationPolicy && pConvertSidToStringSidA)
 55         return TRUE;
 56 
 57     return FALSE;
 58 }
 59 
 60 static void test_lsa(void)
 61 {
 62     NTSTATUS status;
 63     LSA_HANDLE handle;
 64     LSA_OBJECT_ATTRIBUTES object_attributes;
 65 
 66     ZeroMemory(&object_attributes, sizeof(object_attributes));
 67     object_attributes.Length = sizeof(object_attributes);
 68 
 69     status = pLsaOpenPolicy( NULL, &object_attributes, POLICY_ALL_ACCESS, &handle);
 70     ok(status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED,
 71        "LsaOpenPolicy(POLICY_ALL_ACCESS) returned 0x%08x\n", status);
 72 
 73     /* try a more restricted access mask if necessary */
 74     if (status == STATUS_ACCESS_DENIED) {
 75         trace("LsaOpenPolicy(POLICY_ALL_ACCESS) failed, trying POLICY_VIEW_LOCAL_INFORMATION\n");
 76         status = pLsaOpenPolicy( NULL, &object_attributes, POLICY_VIEW_LOCAL_INFORMATION, &handle);
 77         ok(status == STATUS_SUCCESS, "LsaOpenPolicy(POLICY_VIEW_LOCAL_INFORMATION) returned 0x%08x\n", status);
 78     }
 79 
 80     if (status == STATUS_SUCCESS) {
 81         PPOLICY_AUDIT_EVENTS_INFO audit_events_info;
 82         PPOLICY_PRIMARY_DOMAIN_INFO primary_domain_info;
 83         PPOLICY_ACCOUNT_DOMAIN_INFO account_domain_info;
 84         PPOLICY_DNS_DOMAIN_INFO dns_domain_info;
 85 
 86         status = pLsaQueryInformationPolicy(handle, PolicyAuditEventsInformation, (PVOID*)&audit_events_info);
 87         if (status == STATUS_ACCESS_DENIED)
 88             skip("Not enough rights to retrieve PolicyAuditEventsInformation\n");
 89         else
 90             ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAuditEventsInformation) failed, returned 0x%08x\n", status);
 91         if (status == STATUS_SUCCESS) {
 92             pLsaFreeMemory((LPVOID)audit_events_info);
 93         }
 94 
 95         status = pLsaQueryInformationPolicy(handle, PolicyPrimaryDomainInformation, (PVOID*)&primary_domain_info);
 96         ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyPrimaryDomainInformation) failed, returned 0x%08x\n", status);
 97         if (status == STATUS_SUCCESS) {
 98             if (primary_domain_info->Sid) {
 99                 LPSTR strsid;
100                 if (pConvertSidToStringSidA(primary_domain_info->Sid, &strsid))
101                 {
102                     if (primary_domain_info->Name.Buffer) {
103                         LPSTR name = NULL;
104                         UINT len;
105                         len = WideCharToMultiByte( CP_ACP, 0, primary_domain_info->Name.Buffer, -1, NULL, 0, NULL, NULL );
106                         name = LocalAlloc( 0, len );
107                         WideCharToMultiByte( CP_ACP, 0, primary_domain_info->Name.Buffer, -1, name, len, NULL, NULL );
108                         trace("  name: %s sid: %s\n", name, strsid);
109                         LocalFree( name );
110                     } else
111                         trace("  name: NULL sid: %s\n", strsid);
112                     LocalFree( strsid );
113                 }
114                 else
115                     trace("invalid sid\n");
116             }
117             else
118                 trace("Running on a standalone system.\n");
119             pLsaFreeMemory((LPVOID)primary_domain_info);
120         }
121 
122         status = pLsaQueryInformationPolicy(handle, PolicyAccountDomainInformation, (PVOID*)&account_domain_info);
123         ok(status == STATUS_SUCCESS, "LsaQueryInformationPolicy(PolicyAccountDomainInformation) failed, returned 0x%08x\n", status);
124         if (status == STATUS_SUCCESS) {
125             pLsaFreeMemory((LPVOID)account_domain_info);
126         }
127 
128         /* This isn't supported in NT4 */
129         status = pLsaQueryInformationPolicy(handle, PolicyDnsDomainInformation, (PVOID*)&dns_domain_info);
130         ok(status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER,
131            "LsaQueryInformationPolicy(PolicyDnsDomainInformation) failed, returned 0x%08x\n", status);
132         if (status == STATUS_SUCCESS) {
133             if (dns_domain_info->Sid || !IsEqualGUID(&dns_domain_info->DomainGuid, &GUID_NULL)) {
134                 LPSTR strsid = NULL;
135                 LPSTR name = NULL;
136                 LPSTR domain = NULL;
137                 LPSTR forest = NULL;
138                 LPSTR guidstr = NULL;
139                 WCHAR guidstrW[64];
140                 UINT len;
141                 guidstrW[0] = '\0';
142                 pConvertSidToStringSidA(dns_domain_info->Sid, &strsid);
143                 StringFromGUID2(&dns_domain_info->DomainGuid, guidstrW, sizeof(guidstrW)/sizeof(WCHAR));
144                 len = WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, NULL, 0, NULL, NULL );
145                 guidstr = LocalAlloc( 0, len );
146                 WideCharToMultiByte( CP_ACP, 0, guidstrW, -1, guidstr, len, NULL, NULL );
147                 if (dns_domain_info->Name.Buffer) {
148                     len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->Name.Buffer, -1, NULL, 0, NULL, NULL );
149                     name = LocalAlloc( 0, len );
150                     WideCharToMultiByte( CP_ACP, 0, dns_domain_info->Name.Buffer, -1, name, len, NULL, NULL );
151                 }
152                 if (dns_domain_info->DnsDomainName.Buffer) {
153                     len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsDomainName.Buffer, -1, NULL, 0, NULL, NULL );
154                     domain = LocalAlloc( 0, len );
155                     WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsDomainName.Buffer, -1, domain, len, NULL, NULL );
156                 }
157                 if (dns_domain_info->DnsForestName.Buffer) {
158                     len = WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsForestName.Buffer, -1, NULL, 0, NULL, NULL );
159                     forest = LocalAlloc( 0, len );
160                     WideCharToMultiByte( CP_ACP, 0, dns_domain_info->DnsForestName.Buffer, -1, forest, len, NULL, NULL );
161                 }
162                 trace("  name: %s domain: %s forest: %s guid: %s sid: %s\n",
163                       name ? name : "NULL", domain ? domain : "NULL",
164                       forest ? forest : "NULL", guidstr, strsid ? strsid : "NULL");
165                 LocalFree( name );
166                 LocalFree( forest );
167                 LocalFree( domain );
168                 LocalFree( guidstr );
169                 LocalFree( strsid );
170             }
171             else
172                 trace("Running on a standalone system.\n");
173             pLsaFreeMemory((LPVOID)dns_domain_info);
174         }
175 
176         status = pLsaClose(handle);
177         ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
178     }
179 }
180 
181 START_TEST(lsa)
182 {
183     if (!init()) {
184         skip("Needed functions are not available\n");
185         return;
186     }
187 
188     test_lsa();
189 }
190 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.