2005-11-29 12:00:19 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Paul Vriens
|
|
|
|
*
|
|
|
|
* netapi32 directory service functions
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-11-29 12:00:19 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2006-09-20 21:24:37 +02:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2005-11-29 12:00:19 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
2006-09-20 21:24:37 +02:00
|
|
|
#include "ntsecapi.h"
|
2005-11-29 12:00:19 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsrole.h"
|
2006-09-27 16:23:29 +02:00
|
|
|
#include "dsgetdc.h"
|
2005-11-29 12:00:19 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ds);
|
|
|
|
|
2006-09-27 16:23:29 +02:00
|
|
|
DWORD WINAPI DsGetDcNameW(LPCWSTR ComputerName, LPCWSTR AvoidDCName,
|
|
|
|
GUID* DomainGuid, LPCWSTR SiteName, ULONG Flags,
|
|
|
|
PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo)
|
|
|
|
{
|
2006-10-12 20:56:59 +02:00
|
|
|
FIXME("(%s, %s, %s, %s, %08x, %p): stub\n", debugstr_w(ComputerName),
|
2006-09-27 16:23:29 +02:00
|
|
|
debugstr_w(AvoidDCName), debugstr_guid(DomainGuid),
|
|
|
|
debugstr_w(SiteName), Flags, DomainControllerInfo);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-10-05 16:26:53 +02:00
|
|
|
DWORD WINAPI DsGetDcNameA(LPCSTR ComputerName, LPCSTR AvoidDCName,
|
|
|
|
GUID* DomainGuid, LPCSTR SiteName, ULONG Flags,
|
|
|
|
PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo)
|
|
|
|
{
|
2006-10-12 20:56:59 +02:00
|
|
|
FIXME("(%s, %s, %s, %s, %08x, %p): stub\n", debugstr_a(ComputerName),
|
2006-10-05 16:26:53 +02:00
|
|
|
debugstr_a(AvoidDCName), debugstr_guid(DomainGuid),
|
|
|
|
debugstr_a(SiteName), Flags, DomainControllerInfo);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-09-27 16:23:29 +02:00
|
|
|
DWORD WINAPI DsGetSiteNameW(LPCWSTR ComputerName, LPWSTR *SiteName)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p): stub\n", debugstr_w(ComputerName), SiteName);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-06-16 21:48:59 +02:00
|
|
|
DWORD WINAPI DsGetSiteNameA(LPCSTR ComputerName, LPSTR *SiteName)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p): stub\n", debugstr_a(ComputerName), SiteName);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-11-29 12:00:19 +01:00
|
|
|
/************************************************************
|
|
|
|
* DsRoleFreeMemory (NETAPI32.@)
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Buffer [I] Pointer to the to-be-freed buffer.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing
|
|
|
|
*/
|
2005-12-02 13:27:42 +01:00
|
|
|
VOID WINAPI DsRoleFreeMemory(PVOID Buffer)
|
2005-11-29 12:00:19 +01:00
|
|
|
{
|
2006-09-20 21:24:37 +02:00
|
|
|
TRACE("(%p)\n", Buffer);
|
|
|
|
HeapFree(GetProcessHeap(), 0, Buffer);
|
2005-11-29 12:00:19 +01:00
|
|
|
}
|
2005-12-02 13:27:42 +01:00
|
|
|
|
2005-11-29 12:00:19 +01:00
|
|
|
/************************************************************
|
|
|
|
* DsRoleGetPrimaryDomainInformation (NETAPI32.@)
|
|
|
|
*
|
|
|
|
* PARAMS
|
2008-04-08 23:22:43 +02:00
|
|
|
* lpServer [I] Pointer to UNICODE string with ComputerName
|
2005-11-29 12:00:19 +01:00
|
|
|
* InfoLevel [I] Type of data to retrieve
|
|
|
|
* Buffer [O] Pointer to to the requested data
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* When lpServer is NULL, use the local computer
|
|
|
|
*/
|
|
|
|
DWORD WINAPI DsRoleGetPrimaryDomainInformation(
|
|
|
|
LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
|
|
|
|
PBYTE* Buffer)
|
|
|
|
{
|
2006-09-20 21:24:37 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
2005-11-29 12:00:19 +01:00
|
|
|
FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer);
|
|
|
|
|
|
|
|
/* Check some input parameters */
|
|
|
|
|
|
|
|
if (!Buffer) return ERROR_INVALID_PARAMETER;
|
|
|
|
if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2008-06-19 15:13:51 +02:00
|
|
|
*Buffer = NULL;
|
2006-09-20 21:24:37 +02:00
|
|
|
switch (InfoLevel)
|
|
|
|
{
|
|
|
|
case DsRolePrimaryDomainInfoBasic:
|
|
|
|
{
|
|
|
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
LSA_HANDLE PolicyHandle;
|
|
|
|
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
|
|
|
|
NTSTATUS NtStatus;
|
|
|
|
int logon_domain_sz;
|
|
|
|
DWORD size;
|
|
|
|
PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic;
|
|
|
|
|
|
|
|
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
|
|
|
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
|
|
|
|
POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
|
|
|
|
if (NtStatus != STATUS_SUCCESS)
|
|
|
|
{
|
2007-03-19 02:34:18 +01:00
|
|
|
TRACE("LsaOpenPolicyFailed with NT status %x\n",
|
2006-09-20 21:24:37 +02:00
|
|
|
LsaNtStatusToWinError(NtStatus));
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
LsaQueryInformationPolicy(PolicyHandle,
|
|
|
|
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
|
|
|
|
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
|
|
|
|
LsaClose(PolicyHandle);
|
|
|
|
|
|
|
|
size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) +
|
|
|
|
logon_domain_sz * sizeof(WCHAR);
|
|
|
|
basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
if (basic)
|
|
|
|
{
|
|
|
|
basic->MachineRole = DsRole_RoleStandaloneWorkstation;
|
|
|
|
basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic +
|
|
|
|
sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
|
|
|
|
lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer);
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
|
|
|
*Buffer = (PBYTE)basic;
|
|
|
|
LsaFreeMemory(DomainInfo);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
return ret;
|
2005-11-29 12:00:19 +01:00
|
|
|
}
|