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
24 #define WIN32_NO_STATUS
30 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ds);
35 /************************************************************
36 * DsRoleFreeMemory (NETAPI32.@)
39 * Buffer [I] Pointer to the to-be-freed buffer.
44 VOID WINAPI DsRoleFreeMemory(PVOID Buffer)
46 TRACE("(%p)\n", Buffer);
47 HeapFree(GetProcessHeap(), 0, Buffer);
50 /************************************************************
51 * DsRoleGetPrimaryDomainInformation (NETAPI32.@)
54 * lpServer [I] Pointer to UNICODE string with Computername
55 * InfoLevel [I] Type of data to retrieve
56 * Buffer [O] Pointer to to the requested data
61 * When lpServer is NULL, use the local computer
63 DWORD WINAPI DsRoleGetPrimaryDomainInformation(
64 LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
69 FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer);
71 /* Check some input parameters */
73 if (!Buffer) return ERROR_INVALID_PARAMETER;
74 if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER;
78 case DsRolePrimaryDomainInfoBasic:
80 LSA_OBJECT_ATTRIBUTES ObjectAttributes;
81 LSA_HANDLE PolicyHandle;
82 PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
86 PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic;
88 ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
89 NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
90 POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
91 if (NtStatus != STATUS_SUCCESS)
93 ERR("LsaOpenPolicyFailed with NT status %lx\n",
94 LsaNtStatusToWinError(NtStatus));
95 return ERROR_OUTOFMEMORY;
97 LsaQueryInformationPolicy(PolicyHandle,
98 PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
99 logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
100 LsaClose(PolicyHandle);
102 size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) +
103 logon_domain_sz * sizeof(WCHAR);
104 basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
107 basic->MachineRole = DsRole_RoleStandaloneWorkstation;
108 basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic +
109 sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
110 lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer);
114 ret = ERROR_OUTOFMEMORY;
115 *Buffer = (PBYTE)basic;
116 LsaFreeMemory(DomainInfo);
120 ret = ERROR_CALL_NOT_IMPLEMENTED;