4 * Copyright 2006 Robert Reif
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.
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.
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
25 #define SECURITY_WIN32
29 #include "wine/test.h"
31 static HMODULE secdll;
33 static BOOLEAN (WINAPI * pGetComputerObjectNameA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG lpnSize);
34 static BOOLEAN (WINAPI * pGetComputerObjectNameW)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG lpnSize);
36 static EXTENDED_NAME_FORMAT formats[] = {
37 NameUnknown, NameFullyQualifiedDN, NameSamCompatible, NameDisplay,
38 NameUniqueId, NameCanonical, NameUserPrincipal, NameCanonicalEx,
39 NameServicePrincipal, NameDnsDomain
42 static void testGetComputerObjectNameA(void)
49 for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
51 ZeroMemory(name, sizeof(name));
52 rc = pGetComputerObjectNameA(formats[i], name, &size);
53 ok(rc || ((formats[i] == NameUnknown) &&
54 (GetLastError() == ERROR_INVALID_PARAMETER)) ||
55 (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
56 (GetLastError() == ERROR_NO_SUCH_DOMAIN),
57 "GetComputerObjectNameA(%d) failed: %d\n",
58 formats[i], GetLastError());
60 trace("GetComputerObjectNameA() returned %s\n", name);
64 static void testGetComputerObjectNameW(void)
71 for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
72 size = sizeof(nameW)/sizeof(nameW[0]);
73 ZeroMemory(nameW, sizeof(nameW));
74 rc = pGetComputerObjectNameW(formats[i], nameW, &size);
75 ok(rc || ((formats[i] == NameUnknown) &&
76 (GetLastError() == ERROR_INVALID_PARAMETER)) ||
77 (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
78 (GetLastError() == ERROR_NO_SUCH_DOMAIN),
79 "GetComputerObjectNameW(%d) failed: %d\n",
80 formats[i], GetLastError());
83 WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL );
84 trace("GetComputerObjectNameW() returned %s\n", name);
91 secdll = LoadLibraryA("secur32.dll");
94 secdll = LoadLibraryA("security.dll");
98 pGetComputerObjectNameA = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameA");
99 pGetComputerObjectNameW = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameW");
101 if (pGetComputerObjectNameA)
102 testGetComputerObjectNameA();
104 if (pGetComputerObjectNameW)
105 testGetComputerObjectNameW();