[NETAPI32_WINETEST] Sync with Wine Staging 1.7.43.
[reactos.git] / rostests / winetests / netapi32 / ds.c
1 /*
2 * Copyright 2005 Paul Vriens
3 *
4 * Conformance test of the ds functions.
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
23 #include <wine/test.h>
24 #include <windef.h>
25 #include <winbase.h>
26 #include <winerror.h>
27 #include <dsrole.h>
28
29 static DWORD (WINAPI *pDsRoleGetPrimaryDomainInformation)(LPCWSTR, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL, PBYTE*);
30 static void (WINAPI *pDsRoleFreeMemory)(PVOID);
31
32 static void test_params(void)
33 {
34 DWORD ret;
35 PDSROLE_PRIMARY_DOMAIN_INFO_BASIC dpdi;
36
37 SetLastError(0xdeadbeef);
38 ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, NULL);
39 ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
40
41 SetLastError(0xdeadbeef);
42 ret = pDsRoleGetPrimaryDomainInformation(NULL, 0, NULL);
43 ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
44 SetLastError(0xdeadbeef);
45 ret = pDsRoleGetPrimaryDomainInformation(NULL, 4, NULL);
46 ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
47
48 SetLastError(0xdeadbeef);
49 ret = pDsRoleGetPrimaryDomainInformation(NULL, 4, (PBYTE *)&dpdi);
50 ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
51 }
52
53 static void test_get(void)
54 {
55 DWORD ret;
56 PDSROLE_PRIMARY_DOMAIN_INFO_BASIC dpdi;
57 PDSROLE_UPGRADE_STATUS_INFO dusi;
58 PDSROLE_OPERATION_STATE_INFO dosi;
59
60 SetLastError(0xdeadbeef);
61 ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (PBYTE *)&dpdi);
62 ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret);
63 pDsRoleFreeMemory(dpdi);
64
65 SetLastError(0xdeadbeef);
66 ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRoleUpgradeStatus, (PBYTE *)&dusi);
67 todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); }
68 pDsRoleFreeMemory(dusi);
69
70 SetLastError(0xdeadbeef);
71 ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRoleOperationState, (PBYTE *)&dosi);
72 todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); }
73 pDsRoleFreeMemory(dosi);
74 }
75
76
77 START_TEST(ds)
78 {
79 HMODULE hnetapi32 = LoadLibraryA("netapi32.dll");
80
81 pDsRoleGetPrimaryDomainInformation=(void*)GetProcAddress(hnetapi32,"DsRoleGetPrimaryDomainInformation");
82 if (pDsRoleGetPrimaryDomainInformation)
83 {
84 pDsRoleFreeMemory=(void*)GetProcAddress(hnetapi32,"DsRoleFreeMemory");
85
86 test_params();
87 test_get();
88 }
89 else
90 win_skip("DsRoleGetPrimaryDomainInformation is not available\n");
91
92 FreeLibrary(hnetapi32);
93 }