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
24 #define SECURITY_WIN32
28 #include "wine/test.h"
30 static HMODULE secdll;
32 static BOOLEAN (WINAPI * pGetComputerObjectNameA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG lpnSize);
33 static BOOLEAN (WINAPI * pGetComputerObjectNameW)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG lpnSize);
35 static EXTENDED_NAME_FORMAT formats[] = {
36 NameUnknown, NameFullyQualifiedDN, NameSamCompatible, NameDisplay,
37 NameUniqueId, NameCanonical, NameUserPrincipal, NameCanonicalEx,
38 NameServicePrincipal, NameDnsDomain
41 static void testGetComputerObjectNameA(void)
48 for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
50 ZeroMemory(name, sizeof(name));
51 rc = pGetComputerObjectNameA(formats[i], name, &size);
52 ok(rc || ((formats[i] == NameUnknown) &&
53 (GetLastError() == ERROR_INVALID_PARAMETER)) ||
54 (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
55 (GetLastError() == ERROR_NO_SUCH_DOMAIN),
56 "GetComputerObjectNameA(%d) failed: %ld\n",
57 formats[i], GetLastError());
59 trace("GetComputerObjectNameA() returned %s\n", name);
63 static void testGetComputerObjectNameW(void)
70 for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
71 size = sizeof(nameW)/sizeof(nameW[0]);
72 ZeroMemory(nameW, sizeof(nameW));
73 rc = pGetComputerObjectNameW(formats[i], nameW, &size);
74 ok(rc || ((formats[i] == NameUnknown) &&
75 (GetLastError() == ERROR_INVALID_PARAMETER)) ||
76 (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
77 (GetLastError() == ERROR_NO_SUCH_DOMAIN),
78 "GetComputerObjectNameW(%d) failed: %ld\n",
79 formats[i], GetLastError());
82 WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL );
83 trace("GetComputerObjectNameW() returned %s\n", name);
90 secdll = LoadLibraryA("secur32.dll");
93 secdll = LoadLibraryA("security.dll");
97 pGetComputerObjectNameA = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameA");
98 pGetComputerObjectNameW = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameW");
100 if (pGetComputerObjectNameA)
101 testGetComputerObjectNameA();
103 if (pGetComputerObjectNameW)
104 testGetComputerObjectNameW();