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
);
22 DsGetDcNameWithAccountA(
23 _In_opt_ LPCSTR ComputerName
,
24 _In_opt_ LPCSTR AccountName
,
25 _In_ ULONG AccountControlBits
,
26 _In_ LPCSTR DomainName
,
27 _In_ GUID
*DomainGuid
,
30 _Out_ PDOMAIN_CONTROLLER_INFOA
*DomainControllerInfo
);
34 DsGetDcNameWithAccountW(
35 _In_ LPCWSTR ComputerName
,
36 _In_opt_ LPCWSTR AccountName
,
37 _In_ ULONG AccountControlBits
,
38 _In_ LPCWSTR DomainName
,
39 _In_ GUID
*DomainGuid
,
40 _In_ LPCWSTR SiteName
,
42 _Out_ PDOMAIN_CONTROLLER_INFOW
*DomainControllerInfo
);
44 /* FUNCTIONS *****************************************************************/
49 LOGONSRV_HANDLE pszSystemName
)
51 handle_t hBinding
= NULL
;
52 LPWSTR pszStringBinding
;
55 TRACE("LOGONSRV_HANDLE_bind() called\n");
57 status
= RpcStringBindingComposeW(NULL
,
65 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
69 /* Set the binding handle that will be used to bind to the server. */
70 status
= RpcBindingFromStringBindingW(pszStringBinding
,
74 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
77 status
= RpcStringFreeW(&pszStringBinding
);
80 // TRACE("RpcStringFree returned 0x%x\n", status);
89 LOGONSRV_HANDLE_unbind(
90 LOGONSRV_HANDLE pszSystemName
,
95 TRACE("LOGONSRV_HANDLE_unbind() called\n");
97 status
= RpcBindingFree(&hBinding
);
100 TRACE("RpcBindingFree returned 0x%x\n", status
);
105 /* PUBLIC FUNCTIONS **********************************************************/
109 DsAddressToSiteNamesA(
110 _In_opt_ LPCSTR ComputerName
,
111 _In_ DWORD EntryCount
,
112 _In_ PSOCKET_ADDRESS SocketAddresses
,
113 _Out_ LPSTR
**SiteNames
)
115 FIXME("DsAddressToSiteNamesA(%s, %lu, %p, %p)\n",
116 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
117 return ERROR_CALL_NOT_IMPLEMENTED
;
123 DsAddressToSiteNamesW(
124 _In_opt_ LPCWSTR ComputerName
,
125 _In_ DWORD EntryCount
,
126 _In_ PSOCKET_ADDRESS SocketAddresses
,
127 _Out_ LPWSTR
**SiteNames
)
129 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
130 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
132 NET_API_STATUS status
;
134 TRACE("DsAddressToSiteNamesW(%s, %lu, %p, %p)\n",
135 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
138 return ERROR_INVALID_PARAMETER
;
144 status
= DsrAddressToSiteNamesW((PWSTR
)ComputerName
,
146 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
148 if (status
== NERR_Success
)
150 if (SiteNameArray
->EntryCount
== 0)
152 status
= ERROR_INVALID_PARAMETER
;
156 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
157 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
158 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
160 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
161 if (status
== NERR_Success
)
163 ZeroMemory(SiteNamesBuffer
, BufferSize
);
165 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
166 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
168 SiteNamesBuffer
[i
] = Ptr
;
170 SiteNameArray
->SiteNames
[i
].Buffer
,
171 SiteNameArray
->SiteNames
[i
].Length
);
173 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
176 *SiteNames
= SiteNamesBuffer
;
180 MIDL_user_free(SiteNameArray
);
183 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
185 status
= I_RpcMapWin32Status(RpcExceptionCode());
195 DsAddressToSiteNamesExA(
196 _In_opt_ LPCSTR ComputerName
,
197 _In_ DWORD EntryCount
,
198 _In_ PSOCKET_ADDRESS SocketAddresses
,
199 _Out_ LPSTR
**SiteNames
,
200 _Out_ LPSTR
**SubnetNames
)
202 FIXME("DsAddressToSiteNamesExA(%s, %lu, %p, %p, %p)\n",
203 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
,
204 SiteNames
, SubnetNames
);
205 return ERROR_CALL_NOT_IMPLEMENTED
;
211 DsAddressToSiteNamesExW(
212 _In_opt_ LPCWSTR ComputerName
,
213 _In_ DWORD EntryCount
,
214 _In_ PSOCKET_ADDRESS SocketAddresses
,
215 _Out_ LPWSTR
**SiteNames
,
216 _Out_ LPWSTR
**SubnetNames
)
218 PNL_SITE_NAME_EX_ARRAY SiteNameArray
= NULL
;
219 PWSTR
*SiteNamesBuffer
= NULL
, *SubnetNamesBuffer
= NULL
, Ptr
;
220 ULONG SiteNameBufferSize
, SubnetNameBufferSize
, i
;
221 NET_API_STATUS status
;
223 TRACE("DsAddressToSiteNamesExW(%s, %lu, %p, %p, %p)\n",
224 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
,
225 SiteNames
, SubnetNames
);
228 return ERROR_INVALID_PARAMETER
;
235 status
= DsrAddressToSiteNamesExW((PWSTR
)ComputerName
,
237 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
239 if (status
== NERR_Success
)
241 if (SiteNameArray
->EntryCount
== 0)
243 status
= ERROR_INVALID_PARAMETER
;
247 SiteNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
248 SubnetNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
249 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
251 SiteNameBufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
252 SubnetNameBufferSize
+= SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
);
255 status
= NetApiBufferAllocate(SiteNameBufferSize
, (PVOID
*)&SiteNamesBuffer
);
256 if (status
== NERR_Success
)
258 ZeroMemory(SiteNamesBuffer
, SiteNameBufferSize
);
260 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
261 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
263 SiteNamesBuffer
[i
] = Ptr
;
265 SiteNameArray
->SiteNames
[i
].Buffer
,
266 SiteNameArray
->SiteNames
[i
].Length
);
268 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
271 *SiteNames
= SiteNamesBuffer
;
274 status
= NetApiBufferAllocate(SubnetNameBufferSize
, (PVOID
*)&SubnetNamesBuffer
);
275 if (status
== NERR_Success
)
277 ZeroMemory(SubnetNamesBuffer
, SubnetNameBufferSize
);
279 Ptr
= (PWSTR
)((ULONG_PTR
)SubnetNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
280 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
282 SubnetNamesBuffer
[i
] = Ptr
;
284 SiteNameArray
->SubnetNames
[i
].Buffer
,
285 SiteNameArray
->SubnetNames
[i
].Length
);
287 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
));
290 *SubnetNames
= SubnetNamesBuffer
;
294 MIDL_user_free(SiteNameArray
);
297 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
299 status
= I_RpcMapWin32Status(RpcExceptionCode());
309 DsDeregisterDnsHostRecordsA(
310 _In_opt_ LPSTR ServerName
,
311 _In_opt_ LPSTR DnsDomainName
,
312 _In_opt_ GUID
*DomainGuid
,
313 _In_opt_ GUID
*DsaGuid
,
314 _In_ LPSTR DnsHostName
)
316 FIXME("DsDeregisterDnsHostRecordsA(%s, %s, %p, %p, %s)\n",
317 debugstr_a(ServerName
), debugstr_a(DnsDomainName
),
318 DomainGuid
, DsaGuid
, debugstr_a(DnsHostName
));
319 return ERROR_CALL_NOT_IMPLEMENTED
;
325 DsDeregisterDnsHostRecordsW(
326 _In_opt_ LPWSTR ServerName
,
327 _In_opt_ LPWSTR DnsDomainName
,
328 _In_opt_ GUID
*DomainGuid
,
329 _In_opt_ GUID
*DsaGuid
,
330 _In_ LPWSTR DnsHostName
)
332 NET_API_STATUS status
;
334 TRACE("DsDeregisterDnsHostRecordsW(%s, %s, %p, %p, %s)\n",
335 debugstr_w(ServerName
), debugstr_w(DnsDomainName
),
336 DomainGuid
, DsaGuid
, debugstr_w(DnsHostName
));
340 status
= DsrDeregisterDnsHostRecords(ServerName
,
346 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
348 status
= I_RpcMapWin32Status(RpcExceptionCode());
358 DsEnumerateDomainTrustsA(
359 _In_opt_ LPSTR ServerName
,
361 _Out_ PDS_DOMAIN_TRUSTSA
*Domains
,
362 _Out_ PULONG DomainCount
)
364 FIXME("DsEnumerateDomainTrustsA(%s, %x, %p, %p)\n",
365 debugstr_a(ServerName
), Flags
, Domains
, DomainCount
);
366 return ERROR_CALL_NOT_IMPLEMENTED
;
372 DsEnumerateDomainTrustsW(
373 _In_opt_ LPWSTR ServerName
,
375 _Out_ PDS_DOMAIN_TRUSTSW
*Domains
,
376 _Out_ PULONG DomainCount
)
378 FIXME("DsEnumerateDomainTrustsW(%s, %x, %p, %p)\n",
379 debugstr_w(ServerName
), Flags
, Domains
, DomainCount
);
380 return ERROR_CALL_NOT_IMPLEMENTED
;
387 _In_opt_ LPCSTR ComputerName
,
388 _In_ LPCSTR DomainName
,
389 _In_ GUID
*DomainGuid
,
390 _In_ LPCSTR SiteName
,
392 _Out_ PDOMAIN_CONTROLLER_INFOA
*DomainControllerInfo
)
394 TRACE("DsGetDcNameA(%s, %s, %s, %s, %08lx, %p): stub\n",
395 debugstr_a(ComputerName
), debugstr_a(DomainName
), debugstr_guid(DomainGuid
),
396 debugstr_a(SiteName
), Flags
, DomainControllerInfo
);
397 return DsGetDcNameWithAccountA(ComputerName
,
404 DomainControllerInfo
);
411 _In_opt_ LPCWSTR ComputerName
,
412 _In_ LPCWSTR DomainName
,
413 _In_ GUID
*DomainGuid
,
414 _In_ LPCWSTR SiteName
,
416 _Out_ PDOMAIN_CONTROLLER_INFOW
*DomainControllerInfo
)
418 TRACE("DsGetDcNameW(%s, %s, %s, %s, %08lx, %p)\n",
419 debugstr_w(ComputerName
), debugstr_w(DomainName
), debugstr_guid(DomainGuid
),
420 debugstr_w(SiteName
), Flags
, DomainControllerInfo
);
421 return DsGetDcNameWithAccountW(ComputerName
,
428 DomainControllerInfo
);
434 DsGetDcNameWithAccountA(
435 _In_opt_ LPCSTR ComputerName
,
436 _In_opt_ LPCSTR AccountName
,
437 _In_ ULONG AccountControlBits
,
438 _In_ LPCSTR DomainName
,
439 _In_ GUID
*DomainGuid
,
440 _In_ LPCSTR SiteName
,
442 _Out_ PDOMAIN_CONTROLLER_INFOA
*DomainControllerInfo
)
444 FIXME("DsGetDcNameWithAccountA(%s, %s, %08lx, %s, %s, %s, %08lx, %p): stub\n",
445 debugstr_a(ComputerName
), debugstr_a(AccountName
), AccountControlBits
,
446 debugstr_a(DomainName
), debugstr_guid(DomainGuid
),
447 debugstr_a(SiteName
), Flags
, DomainControllerInfo
);
448 return ERROR_CALL_NOT_IMPLEMENTED
;
454 DsGetDcNameWithAccountW(
455 _In_opt_ LPCWSTR ComputerName
,
456 _In_opt_ LPCWSTR AccountName
,
457 _In_ ULONG AccountControlBits
,
458 _In_ LPCWSTR DomainName
,
459 _In_ GUID
*DomainGuid
,
460 _In_ LPCWSTR SiteName
,
462 _Out_ PDOMAIN_CONTROLLER_INFOW
*DomainControllerInfo
)
464 NET_API_STATUS status
;
466 FIXME("DsGetDcNameWithAccountW(%s, %s, %08lx, %s, %s, %s, %08lx, %p): stub\n",
467 debugstr_w(ComputerName
), debugstr_w(AccountName
), AccountControlBits
,
468 debugstr_w(DomainName
), debugstr_guid(DomainGuid
),
469 debugstr_w(SiteName
), Flags
, DomainControllerInfo
);
473 status
= DsrGetDcNameEx2((PWSTR
)ComputerName
,
480 DomainControllerInfo
);
482 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
484 status
= I_RpcMapWin32Status(RpcExceptionCode());
494 DsGetDcSiteCoverageA(
495 _In_opt_ LPCSTR ServerName
,
496 _Out_ PULONG EntryCount
,
497 _Out_ LPSTR
**SiteNames
)
499 FIXME("DsGetDcSiteCoverageA(%s, %p, %p)\n",
500 debugstr_a(ServerName
), EntryCount
, SiteNames
);
501 return ERROR_CALL_NOT_IMPLEMENTED
;
507 DsGetDcSiteCoverageW(
508 _In_opt_ LPCWSTR ServerName
,
509 _Out_ PULONG EntryCount
,
510 _Out_ LPWSTR
**SiteNames
)
512 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
513 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
515 NET_API_STATUS status
;
517 TRACE("DsGetDcSiteCoverageW(%s, %p, %p)\n",
518 debugstr_w(ServerName
), EntryCount
, SiteNames
);
525 status
= DsrGetDcSiteCoverageW((PWSTR
)ServerName
,
527 if (status
== NERR_Success
)
529 if (SiteNameArray
->EntryCount
== 0)
531 status
= ERROR_INVALID_PARAMETER
;
535 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
536 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
537 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
539 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
540 if (status
== NERR_Success
)
542 ZeroMemory(SiteNamesBuffer
, BufferSize
);
544 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
545 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
547 SiteNamesBuffer
[i
] = Ptr
;
549 SiteNameArray
->SiteNames
[i
].Buffer
,
550 SiteNameArray
->SiteNames
[i
].Length
);
552 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
555 *EntryCount
= SiteNameArray
->EntryCount
;
556 *SiteNames
= SiteNamesBuffer
;
560 MIDL_user_free(SiteNameArray
);
563 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
565 status
= I_RpcMapWin32Status(RpcExceptionCode());
575 DsGetForestTrustInformationW(
576 _In_opt_ LPCWSTR ServerName
,
577 _In_opt_ LPCWSTR TrustedDomainName
,
579 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
581 NET_API_STATUS status
;
583 TRACE("DsGetForestTrustInformationW(%s, %s, 0x%08lx, %p)\n",
584 debugstr_w(ServerName
), debugstr_w(TrustedDomainName
),
585 Flags
, ForestTrustInfo
);
589 status
= DsrGetForestTrustInformation((PWSTR
)ServerName
,
590 (PWSTR
)TrustedDomainName
,
594 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
596 status
= I_RpcMapWin32Status(RpcExceptionCode());
607 _In_ LPCSTR ComputerName
,
608 _Out_ LPSTR
*SiteName
)
610 FIXME("DsGetSiteNameA(%s, %p)\n",
611 debugstr_a(ComputerName
), SiteName
);
612 return ERROR_CALL_NOT_IMPLEMENTED
;
619 _In_ LPCWSTR ComputerName
,
620 _Out_ LPWSTR
*SiteName
)
622 NET_API_STATUS status
;
624 TRACE("DsGetSiteNameW(%s, %p)\n",
625 debugstr_w(ComputerName
), SiteName
);
629 status
= DsrGetSiteName((PWSTR
)ComputerName
,
632 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
634 status
= I_RpcMapWin32Status(RpcExceptionCode());
644 DsMergeForestTrustInformationW(
645 _In_ LPCWSTR DomainName
,
646 _In_ PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo
,
647 _In_opt_ PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo
,
648 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
650 FIXME("DsMergeForestTrustInformationW(%s, %p, %p, %p)\n",
651 debugstr_w(DomainName
), NewForestTrustInfo
,
652 OldForestTrustInfo
, ForestTrustInfo
);
653 return ERROR_CALL_NOT_IMPLEMENTED
;
659 DsValidateSubnetNameA(
660 _In_ LPCSTR SubnetName
)
662 FIXME("DsValidateSubnetNameA(%s)\n",
663 debugstr_a(SubnetName
));
664 return ERROR_CALL_NOT_IMPLEMENTED
;
670 DsValidateSubnetNameW(
671 _In_ LPCWSTR SubnetName
)
673 FIXME("DsValidateSubnetNameW(%s)\n",
674 debugstr_w(SubnetName
));
675 return ERROR_CALL_NOT_IMPLEMENTED
;
681 NetEnumerateTrustedDomains(
682 _In_ LPWSTR ServerName
,
683 _Out_ LPWSTR
*DomainNames
)
685 DOMAIN_NAME_BUFFER DomainNameBuffer
= {0, NULL
};
688 TRACE("NetEnumerateTrustedDomains(%s, %p)\n",
689 debugstr_w(ServerName
), DomainNames
);
693 Status
= NetrEnumerateTrustedDomains(ServerName
,
695 if (NT_SUCCESS(Status
))
697 *DomainNames
= (LPWSTR
)DomainNameBuffer
.DomainNames
;
700 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
702 Status
= I_RpcMapWin32Status(RpcExceptionCode());
712 _In_opt_ LPCWSTR ServerName
,
713 _In_opt_ LPCWSTR DomainName
,
714 _Out_ LPBYTE
*BufPtr
)
716 NET_API_STATUS status
;
718 TRACE("NetGetAnyDCName(%s, %s, %p)\n",
719 debugstr_w(ServerName
), debugstr_w(DomainName
), BufPtr
);
725 status
= NetrGetAnyDCName((PWSTR
)ServerName
,
729 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
731 status
= I_RpcMapWin32Status(RpcExceptionCode());
742 _In_ LPCWSTR servername
,
743 _In_ LPCWSTR domainname
,
744 _Out_ LPBYTE
*bufptr
)
746 FIXME("NetGetDCName(%s, %s, %p)\n",
747 debugstr_w(servername
), debugstr_w(domainname
), bufptr
);
749 return NERR_DCNotFound
;
755 NetLogonGetTimeServiceParentDomain(
756 _In_ LPWSTR ServerName
,
757 _Out_ LPWSTR
*DomainName
,
758 _Out_ LPBOOL PdcSameSite
)
760 NET_API_STATUS Status
;
762 TRACE("NetLogonGetTimeServiceParentDomain(%s, %p, %p)\n",
763 debugstr_w(ServerName
), DomainName
, PdcSameSite
);
767 Status
= NetrLogonGetTimeServiceParentDomain(ServerName
,
771 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
773 Status
= I_RpcMapWin32Status(RpcExceptionCode());
783 NetLogonSetServiceBits(
784 _In_ LPWSTR ServerName
,
785 _In_ DWORD ServiceBitsOfInterest
,
786 _In_ DWORD ServiceBits
)
790 TRACE("NetLogonSetServiceBits(%s 0x%lx 0x%lx)\n",
791 debugstr_w(ServerName
), ServiceBitsOfInterest
, ServiceBits
);
795 Status
= NetrLogonSetServiceBits(ServerName
,
796 ServiceBitsOfInterest
,
799 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
801 Status
= RpcExceptionCode();