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 *****************************************************************/
23 LOGONSRV_HANDLE_bind(LOGONSRV_HANDLE pszSystemName
)
25 handle_t hBinding
= NULL
;
26 LPWSTR pszStringBinding
;
29 TRACE("LOGONSRV_HANDLE_bind() called\n");
31 status
= RpcStringBindingComposeW(NULL
,
39 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
43 /* Set the binding handle that will be used to bind to the server. */
44 status
= RpcBindingFromStringBindingW(pszStringBinding
,
48 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
51 status
= RpcStringFreeW(&pszStringBinding
);
54 // TRACE("RpcStringFree returned 0x%x\n", status);
62 LOGONSRV_HANDLE_unbind(LOGONSRV_HANDLE pszSystemName
,
67 TRACE("LOGONSRV_HANDLE_unbind() called\n");
69 status
= RpcBindingFree(&hBinding
);
72 TRACE("RpcBindingFree returned 0x%x\n", status
);
79 DsAddressToSiteNamesA(
80 _In_opt_ LPCSTR ComputerName
,
81 _In_ DWORD EntryCount
,
82 _In_ PSOCKET_ADDRESS SocketAddresses
,
83 _Out_ LPSTR
**SiteNames
)
85 FIXME("DsAddressToSiteNamesA(%s, %lu, %p, %p)\n",
86 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
87 return ERROR_CALL_NOT_IMPLEMENTED
;
93 DsAddressToSiteNamesW(
94 _In_opt_ LPCWSTR ComputerName
,
95 _In_ DWORD EntryCount
,
96 _In_ PSOCKET_ADDRESS SocketAddresses
,
97 _Out_ LPWSTR
**SiteNames
)
99 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
100 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
102 NET_API_STATUS status
;
104 TRACE("DsAddressToSiteNamesW(%s, %lu, %p, %p)\n",
105 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
, SiteNames
);
108 return ERROR_INVALID_PARAMETER
;
114 status
= DsrAddressToSiteNamesW((PWSTR
)ComputerName
,
116 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
118 if (status
== NERR_Success
)
120 if (SiteNameArray
->EntryCount
== 0)
122 status
= ERROR_INVALID_PARAMETER
;
126 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
127 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
128 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
130 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
131 if (status
== NERR_Success
)
133 ZeroMemory(SiteNamesBuffer
, BufferSize
);
135 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
136 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
138 SiteNamesBuffer
[i
] = Ptr
;
140 SiteNameArray
->SiteNames
[i
].Buffer
,
141 SiteNameArray
->SiteNames
[i
].Length
);
143 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
146 *SiteNames
= SiteNamesBuffer
;
150 MIDL_user_free(SiteNameArray
);
153 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
155 status
= I_RpcMapWin32Status(RpcExceptionCode());
165 DsAddressToSiteNamesExA(
166 _In_opt_ LPCSTR ComputerName
,
167 _In_ DWORD EntryCount
,
168 _In_ PSOCKET_ADDRESS SocketAddresses
,
169 _Out_ LPSTR
**SiteNames
,
170 _Out_ LPSTR
**SubnetNames
)
172 FIXME("DsAddressToSiteNamesExA(%s, %lu, %p, %p, %p)\n",
173 debugstr_a(ComputerName
), EntryCount
, SocketAddresses
,
174 SiteNames
, SubnetNames
);
175 return ERROR_CALL_NOT_IMPLEMENTED
;
181 DsAddressToSiteNamesExW(
182 _In_opt_ LPCWSTR ComputerName
,
183 _In_ DWORD EntryCount
,
184 _In_ PSOCKET_ADDRESS SocketAddresses
,
185 _Out_ LPWSTR
**SiteNames
,
186 _Out_ LPWSTR
**SubnetNames
)
188 PNL_SITE_NAME_EX_ARRAY SiteNameArray
= NULL
;
189 PWSTR
*SiteNamesBuffer
= NULL
, *SubnetNamesBuffer
= NULL
, Ptr
;
190 ULONG SiteNameBufferSize
, SubnetNameBufferSize
, i
;
191 NET_API_STATUS status
;
193 TRACE("DsAddressToSiteNamesExW(%s, %lu, %p, %p, %p)\n",
194 debugstr_w(ComputerName
), EntryCount
, SocketAddresses
,
195 SiteNames
, SubnetNames
);
198 return ERROR_INVALID_PARAMETER
;
205 status
= DsrAddressToSiteNamesExW((PWSTR
)ComputerName
,
207 (PNL_SOCKET_ADDRESS
)SocketAddresses
,
209 if (status
== NERR_Success
)
211 if (SiteNameArray
->EntryCount
== 0)
213 status
= ERROR_INVALID_PARAMETER
;
217 SiteNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
218 SubnetNameBufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
219 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
221 SiteNameBufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
222 SubnetNameBufferSize
+= SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
);
225 status
= NetApiBufferAllocate(SiteNameBufferSize
, (PVOID
*)&SiteNamesBuffer
);
226 if (status
== NERR_Success
)
228 ZeroMemory(SiteNamesBuffer
, SiteNameBufferSize
);
230 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
231 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
233 SiteNamesBuffer
[i
] = Ptr
;
235 SiteNameArray
->SiteNames
[i
].Buffer
,
236 SiteNameArray
->SiteNames
[i
].Length
);
238 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
241 *SiteNames
= SiteNamesBuffer
;
244 status
= NetApiBufferAllocate(SubnetNameBufferSize
, (PVOID
*)&SubnetNamesBuffer
);
245 if (status
== NERR_Success
)
247 ZeroMemory(SubnetNamesBuffer
, SubnetNameBufferSize
);
249 Ptr
= (PWSTR
)((ULONG_PTR
)SubnetNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
250 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
252 SubnetNamesBuffer
[i
] = Ptr
;
254 SiteNameArray
->SubnetNames
[i
].Buffer
,
255 SiteNameArray
->SubnetNames
[i
].Length
);
257 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SubnetNames
[i
].Length
+ sizeof(WCHAR
));
260 *SubnetNames
= SubnetNamesBuffer
;
264 MIDL_user_free(SiteNameArray
);
267 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
269 status
= I_RpcMapWin32Status(RpcExceptionCode());
279 DsDeregisterDnsHostRecordsA(
280 _In_opt_ LPSTR ServerName
,
281 _In_opt_ LPSTR DnsDomainName
,
282 _In_opt_ GUID
*DomainGuid
,
283 _In_opt_ GUID
*DsaGuid
,
284 _In_ LPSTR DnsHostName
)
286 FIXME("DsDeregisterDnsHostRecordsA(%s, %s, %p, %p, %s)\n",
287 debugstr_a(ServerName
), debugstr_a(DnsDomainName
),
288 DomainGuid
, DsaGuid
, debugstr_a(DnsHostName
));
289 return ERROR_CALL_NOT_IMPLEMENTED
;
295 DsDeregisterDnsHostRecordsW(
296 _In_opt_ LPWSTR ServerName
,
297 _In_opt_ LPWSTR DnsDomainName
,
298 _In_opt_ GUID
*DomainGuid
,
299 _In_opt_ GUID
*DsaGuid
,
300 _In_ LPWSTR DnsHostName
)
302 NET_API_STATUS status
;
304 TRACE("DsDeregisterDnsHostRecordsW(%s, %s, %p, %p, %s)\n",
305 debugstr_w(ServerName
), debugstr_w(DnsDomainName
),
306 DomainGuid
, DsaGuid
, debugstr_w(DnsHostName
));
310 status
= DsrDeregisterDnsHostRecords(ServerName
,
316 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
318 status
= I_RpcMapWin32Status(RpcExceptionCode());
328 DsEnumerateDomainTrustsA(
329 _In_opt_ LPSTR ServerName
,
331 _Out_ PDS_DOMAIN_TRUSTSA
*Domains
,
332 _Out_ PULONG DomainCount
)
334 FIXME("DsEnumerateDomainTrustsA(%s, %x, %p, %p)\n",
335 debugstr_a(ServerName
), Flags
, Domains
, DomainCount
);
336 return ERROR_CALL_NOT_IMPLEMENTED
;
342 DsEnumerateDomainTrustsW(
343 _In_opt_ LPWSTR ServerName
,
345 _Out_ PDS_DOMAIN_TRUSTSW
*Domains
,
346 _Out_ PULONG DomainCount
)
348 FIXME("DsEnumerateDomainTrustsW(%s, %x, %p, %p)\n",
349 debugstr_w(ServerName
), Flags
, Domains
, DomainCount
);
350 return ERROR_CALL_NOT_IMPLEMENTED
;
357 _In_ LPCSTR ComputerName
,
358 _In_ LPCSTR DomainName
,
359 _In_ GUID
*DomainGuid
,
360 _In_ LPCSTR SiteName
,
362 _Out_ PDOMAIN_CONTROLLER_INFOA
*DomainControllerInfo
)
364 FIXME("DsGetDcNameA(%s, %s, %s, %s, %08x, %p): stub\n",
365 debugstr_a(ComputerName
), debugstr_a(DomainName
), debugstr_guid(DomainGuid
),
366 debugstr_a(SiteName
), Flags
, DomainControllerInfo
);
367 return ERROR_CALL_NOT_IMPLEMENTED
;
374 _In_ LPCWSTR ComputerName
,
375 _In_ LPCWSTR DomainName
,
376 _In_ GUID
*DomainGuid
,
377 _In_ LPCWSTR SiteName
,
379 _Out_ PDOMAIN_CONTROLLER_INFOW
*DomainControllerInfo
)
381 FIXME("DsGetDcNameW(%s, %s, %s, %s, %08x, %p)\n",
382 debugstr_w(ComputerName
), debugstr_w(DomainName
), debugstr_guid(DomainGuid
),
383 debugstr_w(SiteName
), Flags
, DomainControllerInfo
);
384 return ERROR_CALL_NOT_IMPLEMENTED
;
390 DsGetDcSiteCoverageA(
391 _In_opt_ LPCSTR ServerName
,
392 _Out_ PULONG EntryCount
,
393 _Out_ LPSTR
**SiteNames
)
395 FIXME("DsGetDcSiteCoverageA(%s, %p, %p)\n",
396 debugstr_a(ServerName
), EntryCount
, SiteNames
);
397 return ERROR_CALL_NOT_IMPLEMENTED
;
403 DsGetDcSiteCoverageW(
404 _In_opt_ LPCWSTR ServerName
,
405 _Out_ PULONG EntryCount
,
406 _Out_ LPWSTR
**SiteNames
)
408 PNL_SITE_NAME_ARRAY SiteNameArray
= NULL
;
409 PWSTR
*SiteNamesBuffer
= NULL
, Ptr
;
411 NET_API_STATUS status
;
413 TRACE("DsGetDcSiteCoverageW(%s, %p, %p)\n",
414 debugstr_w(ServerName
), EntryCount
, SiteNames
);
421 status
= DsrGetDcSiteCoverageW((PWSTR
)ServerName
,
423 if (status
== NERR_Success
)
425 if (SiteNameArray
->EntryCount
== 0)
427 status
= ERROR_INVALID_PARAMETER
;
431 BufferSize
= SiteNameArray
->EntryCount
* sizeof(PWSTR
);
432 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
433 BufferSize
+= SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
);
435 status
= NetApiBufferAllocate(BufferSize
, (PVOID
*)&SiteNamesBuffer
);
436 if (status
== NERR_Success
)
438 ZeroMemory(SiteNamesBuffer
, BufferSize
);
440 Ptr
= (PWSTR
)((ULONG_PTR
)SiteNamesBuffer
+ SiteNameArray
->EntryCount
* sizeof(PWSTR
));
441 for (i
= 0; i
< SiteNameArray
->EntryCount
; i
++)
443 SiteNamesBuffer
[i
] = Ptr
;
445 SiteNameArray
->SiteNames
[i
].Buffer
,
446 SiteNameArray
->SiteNames
[i
].Length
);
448 Ptr
= (PWSTR
)((ULONG_PTR
)Ptr
+ SiteNameArray
->SiteNames
[i
].Length
+ sizeof(WCHAR
));
451 *EntryCount
= SiteNameArray
->EntryCount
;
452 *SiteNames
= SiteNamesBuffer
;
456 MIDL_user_free(SiteNameArray
);
459 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
461 status
= I_RpcMapWin32Status(RpcExceptionCode());
471 DsGetForestTrustInformationW(
472 _In_opt_ LPCWSTR ServerName
,
473 _In_opt_ LPCWSTR TrustedDomainName
,
475 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
477 NET_API_STATUS status
;
479 TRACE("DsGetForestTrustInformationW(%s, %s, 0x%08lx, %p)\n",
480 debugstr_w(ServerName
), debugstr_w(TrustedDomainName
),
481 Flags
, ForestTrustInfo
);
485 status
= DsrGetForestTrustInformation((PWSTR
)ServerName
,
486 (PWSTR
)TrustedDomainName
,
490 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
492 status
= I_RpcMapWin32Status(RpcExceptionCode());
503 _In_ LPCSTR ComputerName
,
504 _Out_ LPSTR
*SiteName
)
506 FIXME("DsGetSiteNameA(%s, %p)\n",
507 debugstr_a(ComputerName
), SiteName
);
508 return ERROR_CALL_NOT_IMPLEMENTED
;
515 _In_ LPCWSTR ComputerName
,
516 _Out_ LPWSTR
*SiteName
)
518 NET_API_STATUS status
;
520 TRACE("DsGetSiteNameW(%s, %p)\n",
521 debugstr_w(ComputerName
), SiteName
);
525 status
= DsrGetSiteName((PWSTR
)ComputerName
,
528 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
530 status
= I_RpcMapWin32Status(RpcExceptionCode());
540 DsMergeForestTrustInformationW(
541 _In_ LPCWSTR DomainName
,
542 _In_ PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo
,
543 _In_opt_ PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo
,
544 _Out_ PLSA_FOREST_TRUST_INFORMATION
*ForestTrustInfo
)
546 FIXME("DsMergeForestTrustInformationW(%s, %p, %p, %p)\n",
547 debugstr_w(DomainName
), NewForestTrustInfo
,
548 OldForestTrustInfo
, ForestTrustInfo
);
549 return ERROR_CALL_NOT_IMPLEMENTED
;
555 DsValidateSubnetNameA(
556 _In_ LPCSTR SubnetName
)
558 FIXME("DsValidateSubnetNameA(%s)\n",
559 debugstr_a(SubnetName
));
560 return ERROR_CALL_NOT_IMPLEMENTED
;
566 DsValidateSubnetNameW(
567 _In_ LPCWSTR SubnetName
)
569 FIXME("DsValidateSubnetNameW(%s)\n",
570 debugstr_w(SubnetName
));
571 return ERROR_CALL_NOT_IMPLEMENTED
;
577 NetEnumerateTrustedDomains(
578 _In_ LPWSTR ServerName
,
579 _Out_ LPWSTR
*DomainNames
)
581 DOMAIN_NAME_BUFFER DomainNameBuffer
= {0, NULL
};
584 TRACE("NetEnumerateTrustedDomains(%s, %p)\n",
585 debugstr_w(ServerName
), DomainNames
);
589 Status
= NetrEnumerateTrustedDomains(ServerName
,
591 if (NT_SUCCESS(Status
))
593 *DomainNames
= (LPWSTR
)DomainNameBuffer
.DomainNames
;
596 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
598 Status
= I_RpcMapWin32Status(RpcExceptionCode());
608 _In_opt_ LPCWSTR ServerName
,
609 _In_opt_ LPCWSTR DomainName
,
610 _Out_ LPBYTE
*BufPtr
)
612 NET_API_STATUS status
;
614 TRACE("NetGetAnyDCName(%s, %s, %p)\n",
615 debugstr_w(ServerName
), debugstr_w(DomainName
), BufPtr
);
621 status
= NetrGetAnyDCName((PWSTR
)ServerName
,
625 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
627 status
= I_RpcMapWin32Status(RpcExceptionCode());
638 _In_ LPCWSTR servername
,
639 _In_ LPCWSTR domainname
,
640 _Out_ LPBYTE
*bufptr
)
642 FIXME("NetGetDCName(%s, %s, %p)\n",
643 debugstr_w(servername
), debugstr_w(domainname
), bufptr
);
645 return NERR_DCNotFound
;