2 * COPYRIGHT: See COPYING in the top level directory
4 * FILE: dll/win32/netapi32/netlogon.c
5 * PURPOSE: Netlogon service interface code
6 * PROGRAMMERS: Eric Kohl (eric.kohl@reactos.org)
9 /* INCLUDES ******************************************************************/
16 #include "netlogon_c.h"
18 WINE_DEFAULT_DEBUG_CHANNEL(netapi32
);
20 /* FUNCTIONS *****************************************************************/
25 LOGONSRV_HANDLE pszSystemName
)
27 handle_t hBinding
= NULL
;
28 LPWSTR pszStringBinding
;
31 TRACE("LOGONSRV_HANDLE_bind() called\n");
33 status
= RpcStringBindingComposeW(NULL
,
41 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
45 /* Set the binding handle that will be used to bind to the server. */
46 status
= RpcBindingFromStringBindingW(pszStringBinding
,
50 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
53 status
= RpcStringFreeW(&pszStringBinding
);
56 // TRACE("RpcStringFree returned 0x%x\n", status);
65 LOGONSRV_HANDLE_unbind(
66 LOGONSRV_HANDLE pszSystemName
,
71 TRACE("LOGONSRV_HANDLE_unbind() called\n");
73 status
= RpcBindingFree(&hBinding
);
76 TRACE("RpcBindingFree returned 0x%x\n", status
);
81 /* PUBLIC FUNCTIONS **********************************************************/
85 DsAddressToSiteNamesA(
86 _In_opt_ LPCSTR ComputerName
,
87 _In_ DWORD EntryCount
,
88 _In_ PSOCKET_ADDRESS SocketAddresses
,
89 _Out_ LPSTR
**SiteNames
)
91 FIXME("DsAddressToSiteNamesA(%s, %lu, %p, %p)\n",
92 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
93 return ERROR_CALL_NOT_IMPLEMENTED
;
99 DsAddressToSiteNamesW(
100 _In_opt_ LPCWSTR ComputerName
,
101 _In_ DWORD EntryCount
,
102 _In_ PSOCKET_ADDRESS SocketAddresses
,
103 _Out_ LPWSTR
**SiteNames
)
105 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
106 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
108 NET_API_STATUS status
;
110 TRACE("DsAddressToSiteNamesW(%s, %lu, %p, %p)\n",
111 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
114 return ERROR_INVALID_PARAMETER
;
120 status
= DsrAddressToSiteNamesW((PWSTR
)ComputerName
,
122 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
124 if (status
== NERR_Success
)
126 if (SiteNameArray
->EntryCount
== 0)
128 status
= ERROR_INVALID_PARAMETER
;
132 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
133 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
134 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
136 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
137 if (status
== NERR_Success
)
139 ZeroMemory(SiteNamesBuffer
, BufferSize
);
141 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
142 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
144 SiteNamesBuffer
[i
] = Ptr
;
146 SiteNameArray
->SiteNames
[i
].Buffer
,
147 SiteNameArray
->SiteNames
[i
].Length
);
149 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
152 *SiteNames
= SiteNamesBuffer
;
156 MIDL_user_free(SiteNameArray
);
159 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
161 status
= I_RpcMapWin32Status(RpcExceptionCode());
171 DsAddressToSiteNamesExA(
172 _In_opt_ LPCSTR ComputerName
,
173 _In_ DWORD EntryCount
,
174 _In_ PSOCKET_ADDRESS SocketAddresses
,
175 _Out_ LPSTR
**SiteNames
,
176 _Out_ LPSTR
**SubnetNames
)
178 FIXME("DsAddressToSiteNamesExA(%s, %lu, %p, %p, %p)\n",
179 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
,
180 SiteNames
, SubnetNames
);
181 return ERROR_CALL_NOT_IMPLEMENTED
;
187 DsAddressToSiteNamesExW(
188 _In_opt_ LPCWSTR ComputerName
,
189 _In_ DWORD EntryCount
,
190 _In_ PSOCKET_ADDRESS SocketAddresses
,
191 _Out_ LPWSTR
**SiteNames
,
192 _Out_ LPWSTR
**SubnetNames
)
194 PNL_SITE_NAME_EX_ARRAY SiteNameArray
= NULL
;
195 PWSTR
*SiteNamesBuffer
= NULL
, *SubnetNamesBuffer
= NULL
, Ptr
;
196 ULONG SiteNameBufferSize
, SubnetNameBufferSize
, i
;
197 NET_API_STATUS status
;
199 TRACE("DsAddressToSiteNamesExW(%s, %lu, %p, %p, %p)\n",
200 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
,
201 SiteNames
, SubnetNames
);
204 return ERROR_INVALID_PARAMETER
;
211 status
= DsrAddressToSiteNamesExW((PWSTR
)ComputerName
,
213 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
215 if (status
== NERR_Success
)
217 if (SiteNameArray
->EntryCount
== 0)
219 status
= ERROR_INVALID_PARAMETER
;
223 SiteNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
224 SubnetNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
225 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
227 SiteNameBufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
228 SubnetNameBufferSize
+= SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
);
231 status
= NetApiBufferAllocate(SiteNameBufferSize
, (PVOID
*)&SiteNamesBuffer
);
232 if (status
== NERR_Success
)
234 ZeroMemory(SiteNamesBuffer
, SiteNameBufferSize
);
236 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
237 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
239 SiteNamesBuffer
[i
] = Ptr
;
241 SiteNameArray
->SiteNames
[i
].Buffer
,
242 SiteNameArray
->SiteNames
[i
].Length
);
244 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
247 *SiteNames
= SiteNamesBuffer
;
250 status
= NetApiBufferAllocate(SubnetNameBufferSize
, (PVOID
*)&SubnetNamesBuffer
);
251 if (status
== NERR_Success
)
253 ZeroMemory(SubnetNamesBuffer
, SubnetNameBufferSize
);
255 Ptr
= (PWSTR
)((ULONG_PTR
)SubnetNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
256 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
258 SubnetNamesBuffer
[i
] = Ptr
;
260 SiteNameArray
->SubnetNames
[i
].Buffer
,
261 SiteNameArray
->SubnetNames
[i
].Length
);
263 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
));
266 *SubnetNames
= SubnetNamesBuffer
;
270 MIDL_user_free(SiteNameArray
);
273 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
275 status
= I_RpcMapWin32Status(RpcExceptionCode());
285 DsDeregisterDnsHostRecordsA(
286 _In_opt_ LPSTR ServerName
,
287 _In_opt_ LPSTR DnsDomainName
,
288 _In_opt_ GUID
*DomainGuid
,
289 _In_opt_ GUID
*DsaGuid
,
290 _In_ LPSTR DnsHostName
)
292 FIXME("DsDeregisterDnsHostRecordsA(%s, %s, %p, %p, %s)\n",
293 debugstr_a(ServerName
), debugstr_a(DnsDomainName
),
294 DomainGuid
, DsaGuid
, debugstr_a(DnsHostName
));
295 return ERROR_CALL_NOT_IMPLEMENTED
;
301 DsDeregisterDnsHostRecordsW(
302 _In_opt_ LPWSTR ServerName
,
303 _In_opt_ LPWSTR DnsDomainName
,
304 _In_opt_ GUID
*DomainGuid
,
305 _In_opt_ GUID
*DsaGuid
,
306 _In_ LPWSTR DnsHostName
)
308 NET_API_STATUS status
;
310 TRACE("DsDeregisterDnsHostRecordsW(%s, %s, %p, %p, %s)\n",
311 debugstr_w(ServerName
), debugstr_w(DnsDomainName
),
312 DomainGuid
, DsaGuid
, debugstr_w(DnsHostName
));
316 status
= DsrDeregisterDnsHostRecords(ServerName
,
322 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
324 status
= I_RpcMapWin32Status(RpcExceptionCode());
334 DsEnumerateDomainTrustsA(
335 _In_opt_ LPSTR ServerName
,
337 _Out_ PDS_DOMAIN_TRUSTSA
*Domains
,
338 _Out_ PULONG DomainCount
)
340 FIXME("DsEnumerateDomainTrustsA(%s, %x, %p, %p)\n",
341 debugstr_a(ServerName
), Flags
, Domains
, DomainCount
);
342 return ERROR_CALL_NOT_IMPLEMENTED
;
348 DsEnumerateDomainTrustsW(
349 _In_opt_ LPWSTR ServerName
,
351 _Out_ PDS_DOMAIN_TRUSTSW
*Domains
,
352 _Out_ PULONG DomainCount
)
354 FIXME("DsEnumerateDomainTrustsW(%s, %x, %p, %p)\n",
355 debugstr_w(ServerName
), Flags
, Domains
, DomainCount
);
356 return ERROR_CALL_NOT_IMPLEMENTED
;
363 _In_ LPCSTR ComputerName
,
364 _In_ LPCSTR DomainName
,
365 _In_ GUID
*DomainGuid
,
366 _In_ LPCSTR SiteName
,
368 _Out_ PDOMAIN_CONTROLLER_INFOA
*DomainControllerInfo
)
370 FIXME("DsGetDcNameA(%s, %s, %s, %s, %08x, %p): stub\n",
371 debugstr_a(ComputerName
), debugstr_a(DomainName
), debugstr_guid(DomainGuid
),
372 debugstr_a(SiteName
), Flags
, DomainControllerInfo
);
373 return ERROR_CALL_NOT_IMPLEMENTED
;
380 _In_ LPCWSTR ComputerName
,
381 _In_ LPCWSTR DomainName
,
382 _In_ GUID
*DomainGuid
,
383 _In_ LPCWSTR SiteName
,
385 _Out_ PDOMAIN_CONTROLLER_INFOW
*DomainControllerInfo
)
387 FIXME("DsGetDcNameW(%s, %s, %s, %s, %08x, %p)\n",
388 debugstr_w(ComputerName
), debugstr_w(DomainName
), debugstr_guid(DomainGuid
),
389 debugstr_w(SiteName
), Flags
, DomainControllerInfo
);
390 return ERROR_CALL_NOT_IMPLEMENTED
;
396 DsGetDcSiteCoverageA(
397 _In_opt_ LPCSTR ServerName
,
398 _Out_ PULONG EntryCount
,
399 _Out_ LPSTR
**SiteNames
)
401 FIXME("DsGetDcSiteCoverageA(%s, %p, %p)\n",
402 debugstr_a(ServerName
), EntryCount
, SiteNames
);
403 return ERROR_CALL_NOT_IMPLEMENTED
;
409 DsGetDcSiteCoverageW(
410 _In_opt_ LPCWSTR ServerName
,
411 _Out_ PULONG EntryCount
,
412 _Out_ LPWSTR
**SiteNames
)
414 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
415 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
417 NET_API_STATUS status
;
419 TRACE("DsGetDcSiteCoverageW(%s, %p, %p)\n",
420 debugstr_w(ServerName
), EntryCount
, SiteNames
);
427 status
= DsrGetDcSiteCoverageW((PWSTR
)ServerName
,
429 if (status
== NERR_Success
)
431 if (SiteNameArray
->EntryCount
== 0)
433 status
= ERROR_INVALID_PARAMETER
;
437 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
438 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
439 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
441 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
442 if (status
== NERR_Success
)
444 ZeroMemory(SiteNamesBuffer
, BufferSize
);
446 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
447 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
449 SiteNamesBuffer
[i
] = Ptr
;
451 SiteNameArray
->SiteNames
[i
].Buffer
,
452 SiteNameArray
->SiteNames
[i
].Length
);
454 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
457 *EntryCount
= SiteNameArray
->EntryCount
;
458 *SiteNames
= SiteNamesBuffer
;
462 MIDL_user_free(SiteNameArray
);
465 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
467 status
= I_RpcMapWin32Status(RpcExceptionCode());
477 DsGetForestTrustInformationW(
478 _In_opt_ LPCWSTR ServerName
,
479 _In_opt_ LPCWSTR TrustedDomainName
,
481 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
483 NET_API_STATUS status
;
485 TRACE("DsGetForestTrustInformationW(%s, %s, 0x%08lx, %p)\n",
486 debugstr_w(ServerName
), debugstr_w(TrustedDomainName
),
487 Flags
, ForestTrustInfo
);
491 status
= DsrGetForestTrustInformation((PWSTR
)ServerName
,
492 (PWSTR
)TrustedDomainName
,
496 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
498 status
= I_RpcMapWin32Status(RpcExceptionCode());
509 _In_ LPCSTR ComputerName
,
510 _Out_ LPSTR
*SiteName
)
512 FIXME("DsGetSiteNameA(%s, %p)\n",
513 debugstr_a(ComputerName
), SiteName
);
514 return ERROR_CALL_NOT_IMPLEMENTED
;
521 _In_ LPCWSTR ComputerName
,
522 _Out_ LPWSTR
*SiteName
)
524 NET_API_STATUS status
;
526 TRACE("DsGetSiteNameW(%s, %p)\n",
527 debugstr_w(ComputerName
), SiteName
);
531 status
= DsrGetSiteName((PWSTR
)ComputerName
,
534 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
536 status
= I_RpcMapWin32Status(RpcExceptionCode());
546 DsMergeForestTrustInformationW(
547 _In_ LPCWSTR DomainName
,
548 _In_ PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo
,
549 _In_opt_ PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo
,
550 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
552 FIXME("DsMergeForestTrustInformationW(%s, %p, %p, %p)\n",
553 debugstr_w(DomainName
), NewForestTrustInfo
,
554 OldForestTrustInfo
, ForestTrustInfo
);
555 return ERROR_CALL_NOT_IMPLEMENTED
;
561 DsValidateSubnetNameA(
562 _In_ LPCSTR SubnetName
)
564 FIXME("DsValidateSubnetNameA(%s)\n",
565 debugstr_a(SubnetName
));
566 return ERROR_CALL_NOT_IMPLEMENTED
;
572 DsValidateSubnetNameW(
573 _In_ LPCWSTR SubnetName
)
575 FIXME("DsValidateSubnetNameW(%s)\n",
576 debugstr_w(SubnetName
));
577 return ERROR_CALL_NOT_IMPLEMENTED
;
583 NetEnumerateTrustedDomains(
584 _In_ LPWSTR ServerName
,
585 _Out_ LPWSTR
*DomainNames
)
587 DOMAIN_NAME_BUFFER DomainNameBuffer
= {0, NULL
};
590 TRACE("NetEnumerateTrustedDomains(%s, %p)\n",
591 debugstr_w(ServerName
), DomainNames
);
595 Status
= NetrEnumerateTrustedDomains(ServerName
,
597 if (NT_SUCCESS(Status
))
599 *DomainNames
= (LPWSTR
)DomainNameBuffer
.DomainNames
;
602 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
604 Status
= I_RpcMapWin32Status(RpcExceptionCode());
614 _In_opt_ LPCWSTR ServerName
,
615 _In_opt_ LPCWSTR DomainName
,
616 _Out_ LPBYTE
*BufPtr
)
618 NET_API_STATUS status
;
620 TRACE("NetGetAnyDCName(%s, %s, %p)\n",
621 debugstr_w(ServerName
), debugstr_w(DomainName
), BufPtr
);
627 status
= NetrGetAnyDCName((PWSTR
)ServerName
,
631 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
633 status
= I_RpcMapWin32Status(RpcExceptionCode());
644 _In_ LPCWSTR servername
,
645 _In_ LPCWSTR domainname
,
646 _Out_ LPBYTE
*bufptr
)
648 FIXME("NetGetDCName(%s, %s, %p)\n",
649 debugstr_w(servername
), debugstr_w(domainname
), bufptr
);
651 return NERR_DCNotFound
;
657 NetLogonSetServiceBits(
658 _In_ LPWSTR ServerName
,
659 _In_ DWORD ServiceBitsOfInterest
,
660 _In_ DWORD ServiceBits
)
664 TRACE("NetLogonSetServiceBits(%s 0x%lx 0x%lx)\n",
665 debugstr_w(ServerName
), ServiceBitsOfInterest
, ServiceBits
);
669 Status
= NetrLogonSetServiceBits(ServerName
,
670 ServiceBitsOfInterest
,
673 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
675 Status
= RpcExceptionCode();