msi: Break out the publishing tests into their respective actions.
[wine.git] / dlls / netapi32 / ds.c
blob819dc23be3e1b4ac393bc982c529f9540eb9f0f0
1 /*
2 * Copyright 2005 Paul Vriens
4 * netapi32 directory service functions
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
21 #include <stdarg.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "ntsecapi.h"
29 #include "wine/debug.h"
30 #include "dsrole.h"
31 #include "dsgetdc.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ds);
35 DWORD WINAPI DsGetDcNameW(LPCWSTR ComputerName, LPCWSTR AvoidDCName,
36 GUID* DomainGuid, LPCWSTR SiteName, ULONG Flags,
37 PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo)
39 FIXME("(%s, %s, %s, %s, %08x, %p): stub\n", debugstr_w(ComputerName),
40 debugstr_w(AvoidDCName), debugstr_guid(DomainGuid),
41 debugstr_w(SiteName), Flags, DomainControllerInfo);
42 return ERROR_CALL_NOT_IMPLEMENTED;
45 DWORD WINAPI DsGetDcNameA(LPCSTR ComputerName, LPCSTR AvoidDCName,
46 GUID* DomainGuid, LPCSTR SiteName, ULONG Flags,
47 PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo)
49 FIXME("(%s, %s, %s, %s, %08x, %p): stub\n", debugstr_a(ComputerName),
50 debugstr_a(AvoidDCName), debugstr_guid(DomainGuid),
51 debugstr_a(SiteName), Flags, DomainControllerInfo);
52 return ERROR_CALL_NOT_IMPLEMENTED;
55 DWORD WINAPI DsGetSiteNameW(LPCWSTR ComputerName, LPWSTR *SiteName)
57 FIXME("(%s, %p): stub\n", debugstr_w(ComputerName), SiteName);
58 return ERROR_CALL_NOT_IMPLEMENTED;
61 /************************************************************
62 * DsRoleFreeMemory (NETAPI32.@)
64 * PARAMS
65 * Buffer [I] Pointer to the to-be-freed buffer.
67 * RETURNS
68 * Nothing
70 VOID WINAPI DsRoleFreeMemory(PVOID Buffer)
72 TRACE("(%p)\n", Buffer);
73 HeapFree(GetProcessHeap(), 0, Buffer);
76 /************************************************************
77 * DsRoleGetPrimaryDomainInformation (NETAPI32.@)
79 * PARAMS
80 * lpServer [I] Pointer to UNICODE string with Computername
81 * InfoLevel [I] Type of data to retrieve
82 * Buffer [O] Pointer to to the requested data
84 * RETURNS
86 * NOTES
87 * When lpServer is NULL, use the local computer
89 DWORD WINAPI DsRoleGetPrimaryDomainInformation(
90 LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
91 PBYTE* Buffer)
93 DWORD ret;
95 FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer);
97 /* Check some input parameters */
99 if (!Buffer) return ERROR_INVALID_PARAMETER;
100 if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER;
102 switch (InfoLevel)
104 case DsRolePrimaryDomainInfoBasic:
106 LSA_OBJECT_ATTRIBUTES ObjectAttributes;
107 LSA_HANDLE PolicyHandle;
108 PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
109 NTSTATUS NtStatus;
110 int logon_domain_sz;
111 DWORD size;
112 PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic;
114 ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
115 NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
116 POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
117 if (NtStatus != STATUS_SUCCESS)
119 TRACE("LsaOpenPolicyFailed with NT status %x\n",
120 LsaNtStatusToWinError(NtStatus));
121 return ERROR_OUTOFMEMORY;
123 LsaQueryInformationPolicy(PolicyHandle,
124 PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
125 logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
126 LsaClose(PolicyHandle);
128 size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) +
129 logon_domain_sz * sizeof(WCHAR);
130 basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
131 if (basic)
133 basic->MachineRole = DsRole_RoleStandaloneWorkstation;
134 basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic +
135 sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
136 lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer);
137 ret = ERROR_SUCCESS;
139 else
140 ret = ERROR_OUTOFMEMORY;
141 *Buffer = (PBYTE)basic;
142 LsaFreeMemory(DomainInfo);
144 break;
145 default:
146 ret = ERROR_CALL_NOT_IMPLEMENTED;
148 return ret;