293b482aee561ee9b6e602eb44a9b4d10a95b902
[reactos.git] / dll / win32 / netapi32 / netlogon.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: NetAPI DLL
4 * FILE: dll/win32/netapi32/netlogon.c
5 * PURPOSE: Netlogon service interface code
6 * PROGRAMMERS: Eric Kohl (eric.kohl@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "netapi32.h"
12 #include <winsock2.h>
13 #include <rpc.h>
14 #include <dsrole.h>
15 #include <dsgetdc.h>
16 #include "netlogon_c.h"
17
18 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
19
20 DWORD
21 WINAPI
22 DsGetDcNameWithAccountA(
23 _In_opt_ LPCSTR ComputerName,
24 _In_opt_ LPCSTR AccountName,
25 _In_ ULONG AccountControlBits,
26 _In_ LPCSTR DomainName,
27 _In_ GUID *DomainGuid,
28 _In_ LPCSTR SiteName,
29 _In_ ULONG Flags,
30 _Out_ PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo);
31
32 DWORD
33 WINAPI
34 DsGetDcNameWithAccountW(
35 _In_opt_ LPCWSTR ComputerName,
36 _In_opt_ LPCWSTR AccountName,
37 _In_ ULONG AccountControlBits,
38 _In_ LPCWSTR DomainName,
39 _In_ GUID *DomainGuid,
40 _In_ LPCWSTR SiteName,
41 _In_ ULONG Flags,
42 _Out_ PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo);
43
44 /* FUNCTIONS *****************************************************************/
45
46 handle_t
47 __RPC_USER
48 LOGONSRV_HANDLE_bind(
49 LOGONSRV_HANDLE pszSystemName)
50 {
51 handle_t hBinding = NULL;
52 LPWSTR pszStringBinding;
53 RPC_STATUS status;
54
55 TRACE("LOGONSRV_HANDLE_bind() called\n");
56
57 status = RpcStringBindingComposeW(NULL,
58 L"ncacn_np",
59 pszSystemName,
60 L"\\pipe\\netlogon",
61 NULL,
62 &pszStringBinding);
63 if (status)
64 {
65 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
66 return NULL;
67 }
68
69 /* Set the binding handle that will be used to bind to the server. */
70 status = RpcBindingFromStringBindingW(pszStringBinding,
71 &hBinding);
72 if (status)
73 {
74 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
75 }
76
77 status = RpcStringFreeW(&pszStringBinding);
78 if (status)
79 {
80 // TRACE("RpcStringFree returned 0x%x\n", status);
81 }
82
83 return hBinding;
84 }
85
86
87 void
88 __RPC_USER
89 LOGONSRV_HANDLE_unbind(
90 LOGONSRV_HANDLE pszSystemName,
91 handle_t hBinding)
92 {
93 RPC_STATUS status;
94
95 TRACE("LOGONSRV_HANDLE_unbind() called\n");
96
97 status = RpcBindingFree(&hBinding);
98 if (status)
99 {
100 TRACE("RpcBindingFree returned 0x%x\n", status);
101 }
102 }
103
104
105 /* PUBLIC FUNCTIONS **********************************************************/
106
107 DWORD
108 WINAPI
109 DsAddressToSiteNamesA(
110 _In_opt_ LPCSTR ComputerName,
111 _In_ DWORD EntryCount,
112 _In_ PSOCKET_ADDRESS SocketAddresses,
113 _Out_ LPSTR **SiteNames)
114 {
115 PWSTR pComputerNameW = NULL, *pSiteNamesW = NULL;
116 PSTR *pSiteNamesA = NULL, Ptr;
117 UNICODE_STRING UnicodeString;
118 ANSI_STRING AnsiString;
119 ULONG BufferSize, i;
120 NTSTATUS Status;
121 NET_API_STATUS status = NERR_Success;
122
123 TRACE("DsAddressToSiteNamesA(%s, %lu, %p, %p)\n",
124 debugstr_a(ComputerName), EntryCount, SocketAddresses, SiteNames);
125
126 if (EntryCount == 0)
127 return ERROR_INVALID_PARAMETER;
128
129 if (ComputerName != NULL)
130 {
131 pComputerNameW = NetpAllocWStrFromAnsiStr((PSTR)ComputerName);
132 if (pComputerNameW == NULL)
133 {
134 status = ERROR_NOT_ENOUGH_MEMORY;
135 goto done;
136 }
137 }
138
139 /* Call the Unicode function */
140 status = DsAddressToSiteNamesW(pComputerNameW,
141 EntryCount,
142 SocketAddresses,
143 &pSiteNamesW);
144 if (status != NERR_Success)
145 goto done;
146
147 /* Calculate the required site names buffer size */
148 BufferSize = EntryCount * sizeof(PSTR);
149 for (i = 0; i < EntryCount; i++)
150 {
151 if (pSiteNamesW[i] != NULL)
152 {
153 RtlInitUnicodeString(&UnicodeString,
154 pSiteNamesW[i]);
155 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
156 }
157 }
158
159 /* Allocate the site names ANSI buffer */
160 status = NetApiBufferAllocate(BufferSize, (PVOID*)&pSiteNamesA);
161 if (status != NERR_Success)
162 goto done;
163
164 /* Convert the site names */
165 Ptr = (PSTR)((ULONG_PTR)pSiteNamesA + EntryCount * sizeof(PSTR));
166 BufferSize -= EntryCount * sizeof(PSTR);
167
168 for (i = 0; i < EntryCount; i++)
169 {
170 if (pSiteNamesW[i] != NULL)
171 {
172 pSiteNamesA[i] = Ptr;
173 RtlInitUnicodeString(&UnicodeString,
174 pSiteNamesW[i]);
175 AnsiString.Length = 0;
176 AnsiString.MaximumLength = BufferSize;
177 AnsiString.Buffer = Ptr;
178
179 Status = RtlUnicodeStringToAnsiString(&AnsiString,
180 &UnicodeString,
181 FALSE);
182 if (!NT_SUCCESS(Status))
183 {
184 status = RtlNtStatusToDosError(Status);
185 goto done;
186 }
187
188 Ptr = Ptr + AnsiString.Length + sizeof(CHAR);
189 BufferSize -= AnsiString.Length + sizeof(CHAR);
190 }
191 }
192
193 *SiteNames = pSiteNamesA;
194 pSiteNamesA = NULL;
195
196 done:
197 if (pSiteNamesA != NULL)
198 NetApiBufferFree(pSiteNamesA);
199
200 if (pSiteNamesW != NULL)
201 NetApiBufferFree(pSiteNamesW);
202
203 if (pComputerNameW != NULL)
204 NetApiBufferFree(pComputerNameW);
205
206 return status;
207 }
208
209
210 DWORD
211 WINAPI
212 DsAddressToSiteNamesW(
213 _In_opt_ LPCWSTR ComputerName,
214 _In_ DWORD EntryCount,
215 _In_ PSOCKET_ADDRESS SocketAddresses,
216 _Out_ LPWSTR **SiteNames)
217 {
218 PNL_SITE_NAME_ARRAY SiteNameArray = NULL;
219 PWSTR *SiteNamesBuffer = NULL, Ptr;
220 ULONG BufferSize, i;
221 NET_API_STATUS status;
222
223 TRACE("DsAddressToSiteNamesW(%s, %lu, %p, %p)\n",
224 debugstr_w(ComputerName), EntryCount, SocketAddresses, SiteNames);
225
226 if (EntryCount == 0)
227 return ERROR_INVALID_PARAMETER;
228
229 *SiteNames = NULL;
230
231 RpcTryExcept
232 {
233 status = DsrAddressToSiteNamesW((PWSTR)ComputerName,
234 EntryCount,
235 (PNL_SOCKET_ADDRESS)SocketAddresses,
236 &SiteNameArray);
237 if (status == NERR_Success)
238 {
239 if (SiteNameArray->EntryCount == 0)
240 {
241 status = ERROR_INVALID_PARAMETER;
242 }
243 else
244 {
245 BufferSize = SiteNameArray->EntryCount * sizeof(PWSTR);
246 for (i = 0; i < SiteNameArray->EntryCount; i++)
247 BufferSize += SiteNameArray->SiteNames[i].Length + sizeof(WCHAR);
248
249 status = NetApiBufferAllocate(BufferSize, (PVOID*)&SiteNamesBuffer);
250 if (status == NERR_Success)
251 {
252 ZeroMemory(SiteNamesBuffer, BufferSize);
253
254 Ptr = (PWSTR)((ULONG_PTR)SiteNamesBuffer + SiteNameArray->EntryCount * sizeof(PWSTR));
255 for (i = 0; i < SiteNameArray->EntryCount; i++)
256 {
257 SiteNamesBuffer[i] = Ptr;
258 CopyMemory(Ptr,
259 SiteNameArray->SiteNames[i].Buffer,
260 SiteNameArray->SiteNames[i].Length);
261
262 Ptr = (PWSTR)((ULONG_PTR)Ptr + SiteNameArray->SiteNames[i].Length + sizeof(WCHAR));
263 }
264
265 *SiteNames = SiteNamesBuffer;
266 }
267 }
268
269 MIDL_user_free(SiteNameArray);
270 }
271 }
272 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
273 {
274 status = I_RpcMapWin32Status(RpcExceptionCode());
275 }
276 RpcEndExcept;
277
278 return status;
279 }
280
281
282 DWORD
283 WINAPI
284 DsAddressToSiteNamesExA(
285 _In_opt_ LPCSTR ComputerName,
286 _In_ DWORD EntryCount,
287 _In_ PSOCKET_ADDRESS SocketAddresses,
288 _Out_ LPSTR **SiteNames,
289 _Out_ LPSTR **SubnetNames)
290 {
291 PWSTR pComputerNameW = NULL, *pSiteNamesW = NULL;
292 PWSTR *pSubnetNamesW = NULL;
293 PSTR *pSiteNamesA = NULL, *pSubnetNamesA = NULL, Ptr;
294 UNICODE_STRING UnicodeString;
295 ANSI_STRING AnsiString;
296 ULONG BufferSize, i;
297 NTSTATUS Status;
298 NET_API_STATUS status = NERR_Success;
299
300 TRACE("DsAddressToSiteNamesExA(%s, %lu, %p, %p, %p)\n",
301 debugstr_a(ComputerName), EntryCount, SocketAddresses,
302 SiteNames, SubnetNames);
303
304 if (EntryCount == 0)
305 return ERROR_INVALID_PARAMETER;
306
307 if (ComputerName != NULL)
308 {
309 pComputerNameW = NetpAllocWStrFromAnsiStr((PSTR)ComputerName);
310 if (pComputerNameW == NULL)
311 {
312 status = ERROR_NOT_ENOUGH_MEMORY;
313 goto done;
314 }
315 }
316
317 /* Call the Unicode function */
318 status = DsAddressToSiteNamesExW(pComputerNameW,
319 EntryCount,
320 SocketAddresses,
321 &pSiteNamesW,
322 &pSubnetNamesW);
323 if (status != NERR_Success)
324 goto done;
325
326 /* Calculate the required site names buffer size */
327 BufferSize = EntryCount * sizeof(PSTR);
328 for (i = 0; i < EntryCount; i++)
329 {
330 if (pSiteNamesW[i] != NULL)
331 {
332 RtlInitUnicodeString(&UnicodeString,
333 pSiteNamesW[i]);
334 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
335 }
336 }
337
338 /* Allocate the site names ANSI buffer */
339 status = NetApiBufferAllocate(BufferSize, (PVOID*)&pSiteNamesA);
340 if (status != NERR_Success)
341 goto done;
342
343 /* Convert the site names */
344 Ptr = (PSTR)((ULONG_PTR)pSiteNamesA + EntryCount * sizeof(PSTR));
345 BufferSize -= EntryCount * sizeof(PSTR);
346
347 for (i = 0; i < EntryCount; i++)
348 {
349 if (pSiteNamesW[i] != NULL)
350 {
351 pSiteNamesA[i] = Ptr;
352 RtlInitUnicodeString(&UnicodeString,
353 pSiteNamesW[i]);
354 AnsiString.Length = 0;
355 AnsiString.MaximumLength = BufferSize;
356 AnsiString.Buffer = Ptr;
357
358 Status = RtlUnicodeStringToAnsiString(&AnsiString,
359 &UnicodeString,
360 FALSE);
361 if (!NT_SUCCESS(Status))
362 {
363 status = RtlNtStatusToDosError(Status);
364 goto done;
365 }
366
367 Ptr = Ptr + AnsiString.Length + sizeof(CHAR);
368 BufferSize -= AnsiString.Length + sizeof(CHAR);
369 }
370 }
371
372 /* Calculate the required subnet names buffer size */
373 BufferSize = EntryCount * sizeof(PSTR);
374 for (i = 0; i < EntryCount; i++)
375 {
376 if (pSubnetNamesW[i] != NULL)
377 {
378 RtlInitUnicodeString(&UnicodeString,
379 pSubnetNamesW[i]);
380 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
381 }
382 }
383
384 /* Allocate the subnet names ANSI buffer */
385 status = NetApiBufferAllocate(BufferSize, (PVOID*)&pSubnetNamesA);
386 if (status != NERR_Success)
387 goto done;
388
389 /* Convert the subnet names */
390 Ptr = (PSTR)((ULONG_PTR)pSubnetNamesA + EntryCount * sizeof(PSTR));
391 BufferSize -= EntryCount * sizeof(PSTR);
392
393 for (i = 0; i < EntryCount; i++)
394 {
395 if (pSubnetNamesW[i] != NULL)
396 {
397 pSubnetNamesA[i] = Ptr;
398 RtlInitUnicodeString(&UnicodeString,
399 pSubnetNamesW[i]);
400 AnsiString.Length = 0;
401 AnsiString.MaximumLength = BufferSize;
402 AnsiString.Buffer = Ptr;
403
404 Status = RtlUnicodeStringToAnsiString(&AnsiString,
405 &UnicodeString,
406 FALSE);
407 if (!NT_SUCCESS(Status))
408 {
409 status = RtlNtStatusToDosError(Status);
410 goto done;
411 }
412
413 Ptr = Ptr + AnsiString.Length + sizeof(CHAR);
414 BufferSize -= AnsiString.Length + sizeof(CHAR);
415 }
416 }
417
418 *SiteNames = pSiteNamesA;
419 *SubnetNames = pSubnetNamesA;
420 pSiteNamesA = NULL;
421 pSubnetNamesA = NULL;
422
423 done:
424 if (pSubnetNamesA != NULL)
425 NetApiBufferFree(pSubnetNamesA);
426
427 if (pSiteNamesA != NULL)
428 NetApiBufferFree(pSiteNamesA);
429
430 if (pSubnetNamesW != NULL)
431 NetApiBufferFree(pSubnetNamesW);
432
433 if (pSiteNamesW != NULL)
434 NetApiBufferFree(pSiteNamesW);
435
436 if (pComputerNameW != NULL)
437 NetApiBufferFree(pComputerNameW);
438
439 return status;
440 }
441
442
443 DWORD
444 WINAPI
445 DsAddressToSiteNamesExW(
446 _In_opt_ LPCWSTR ComputerName,
447 _In_ DWORD EntryCount,
448 _In_ PSOCKET_ADDRESS SocketAddresses,
449 _Out_ LPWSTR **SiteNames,
450 _Out_ LPWSTR **SubnetNames)
451 {
452 PNL_SITE_NAME_EX_ARRAY SiteNameArray = NULL;
453 PWSTR *SiteNamesBuffer = NULL, *SubnetNamesBuffer = NULL, Ptr;
454 ULONG SiteNameBufferSize, SubnetNameBufferSize, i;
455 NET_API_STATUS status;
456
457 TRACE("DsAddressToSiteNamesExW(%s, %lu, %p, %p, %p)\n",
458 debugstr_w(ComputerName), EntryCount, SocketAddresses,
459 SiteNames, SubnetNames);
460
461 if (EntryCount == 0)
462 return ERROR_INVALID_PARAMETER;
463
464 *SiteNames = NULL;
465 *SubnetNames = NULL;
466
467 RpcTryExcept
468 {
469 status = DsrAddressToSiteNamesExW((PWSTR)ComputerName,
470 EntryCount,
471 (PNL_SOCKET_ADDRESS)SocketAddresses,
472 &SiteNameArray);
473 if (status == NERR_Success)
474 {
475 if (SiteNameArray->EntryCount == 0)
476 {
477 status = ERROR_INVALID_PARAMETER;
478 }
479 else
480 {
481 SiteNameBufferSize = SiteNameArray->EntryCount * sizeof(PWSTR);
482 SubnetNameBufferSize = SiteNameArray->EntryCount * sizeof(PWSTR);
483 for (i = 0; i < SiteNameArray->EntryCount; i++)
484 {
485 SiteNameBufferSize += SiteNameArray->SiteNames[i].Length + sizeof(WCHAR);
486 SubnetNameBufferSize += SiteNameArray->SubnetNames[i].Length + sizeof(WCHAR);
487 }
488
489 status = NetApiBufferAllocate(SiteNameBufferSize, (PVOID*)&SiteNamesBuffer);
490 if (status == NERR_Success)
491 {
492 ZeroMemory(SiteNamesBuffer, SiteNameBufferSize);
493
494 Ptr = (PWSTR)((ULONG_PTR)SiteNamesBuffer + SiteNameArray->EntryCount * sizeof(PWSTR));
495 for (i = 0; i < SiteNameArray->EntryCount; i++)
496 {
497 SiteNamesBuffer[i] = Ptr;
498 CopyMemory(Ptr,
499 SiteNameArray->SiteNames[i].Buffer,
500 SiteNameArray->SiteNames[i].Length);
501
502 Ptr = (PWSTR)((ULONG_PTR)Ptr + SiteNameArray->SiteNames[i].Length + sizeof(WCHAR));
503 }
504
505 *SiteNames = SiteNamesBuffer;
506 }
507
508 status = NetApiBufferAllocate(SubnetNameBufferSize, (PVOID*)&SubnetNamesBuffer);
509 if (status == NERR_Success)
510 {
511 ZeroMemory(SubnetNamesBuffer, SubnetNameBufferSize);
512
513 Ptr = (PWSTR)((ULONG_PTR)SubnetNamesBuffer + SiteNameArray->EntryCount * sizeof(PWSTR));
514 for (i = 0; i < SiteNameArray->EntryCount; i++)
515 {
516 SubnetNamesBuffer[i] = Ptr;
517 CopyMemory(Ptr,
518 SiteNameArray->SubnetNames[i].Buffer,
519 SiteNameArray->SubnetNames[i].Length);
520
521 Ptr = (PWSTR)((ULONG_PTR)Ptr + SiteNameArray->SubnetNames[i].Length + sizeof(WCHAR));
522 }
523
524 *SubnetNames = SubnetNamesBuffer;
525 }
526 }
527
528 MIDL_user_free(SiteNameArray);
529 }
530 }
531 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
532 {
533 status = I_RpcMapWin32Status(RpcExceptionCode());
534 }
535 RpcEndExcept;
536
537 return status;
538 }
539
540
541 DWORD
542 WINAPI
543 DsDeregisterDnsHostRecordsA(
544 _In_opt_ LPSTR ServerName,
545 _In_opt_ LPSTR DnsDomainName,
546 _In_opt_ GUID *DomainGuid,
547 _In_opt_ GUID *DsaGuid,
548 _In_ LPSTR DnsHostName)
549 {
550 PWSTR pServerNameW = NULL, pDnsDomainNameW = NULL;
551 PWSTR pDnsHostNameW = NULL;
552 NET_API_STATUS status = NERR_Success;
553
554 TRACE("DsDeregisterDnsHostRecordsA(%s, %s, %p, %p, %s)\n",
555 debugstr_a(ServerName), debugstr_a(DnsDomainName),
556 DomainGuid, DsaGuid, debugstr_a(DnsHostName));
557
558 if (ServerName != NULL)
559 {
560 pServerNameW = NetpAllocWStrFromAnsiStr((PSTR)ServerName);
561 if (pServerNameW == NULL)
562 {
563 status = ERROR_NOT_ENOUGH_MEMORY;
564 goto done;
565 }
566 }
567
568 if (DnsDomainName != NULL)
569 {
570 pDnsDomainNameW = NetpAllocWStrFromAnsiStr((PSTR)DnsDomainName);
571 if (pDnsDomainNameW == NULL)
572 {
573 status = ERROR_NOT_ENOUGH_MEMORY;
574 goto done;
575 }
576 }
577
578 pDnsHostNameW = NetpAllocWStrFromAnsiStr((PSTR)DnsHostName);
579 if (pDnsHostNameW == NULL)
580 {
581 status = ERROR_NOT_ENOUGH_MEMORY;
582 goto done;
583 }
584
585 status = DsDeregisterDnsHostRecordsW(pServerNameW,
586 pDnsDomainNameW,
587 DomainGuid,
588 DsaGuid,
589 pDnsHostNameW);
590
591 done:
592 if (pDnsHostNameW != NULL)
593 NetApiBufferFree(pDnsHostNameW);
594
595 if (pDnsDomainNameW != NULL)
596 NetApiBufferFree(pDnsDomainNameW);
597
598 if (pServerNameW != NULL)
599 NetApiBufferFree(pServerNameW);
600
601 return status;
602 }
603
604
605 DWORD
606 WINAPI
607 DsDeregisterDnsHostRecordsW(
608 _In_opt_ LPWSTR ServerName,
609 _In_opt_ LPWSTR DnsDomainName,
610 _In_opt_ GUID *DomainGuid,
611 _In_opt_ GUID *DsaGuid,
612 _In_ LPWSTR DnsHostName)
613 {
614 NET_API_STATUS status;
615
616 TRACE("DsDeregisterDnsHostRecordsW(%s, %s, %p, %p, %s)\n",
617 debugstr_w(ServerName), debugstr_w(DnsDomainName),
618 DomainGuid, DsaGuid, debugstr_w(DnsHostName));
619
620 RpcTryExcept
621 {
622 status = DsrDeregisterDnsHostRecords(ServerName,
623 DnsDomainName,
624 DomainGuid,
625 DsaGuid,
626 DnsHostName);
627 }
628 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
629 {
630 status = I_RpcMapWin32Status(RpcExceptionCode());
631 }
632 RpcEndExcept;
633
634 return status;
635 }
636
637
638 DWORD
639 WINAPI
640 DsEnumerateDomainTrustsA(
641 _In_opt_ LPSTR ServerName,
642 _In_ ULONG Flags,
643 _Out_ PDS_DOMAIN_TRUSTSA *Domains,
644 _Out_ PULONG DomainCount)
645 {
646 FIXME("DsEnumerateDomainTrustsA(%s, %x, %p, %p)\n",
647 debugstr_a(ServerName), Flags, Domains, DomainCount);
648 return ERROR_CALL_NOT_IMPLEMENTED;
649 }
650
651
652 DWORD
653 WINAPI
654 DsEnumerateDomainTrustsW(
655 _In_opt_ LPWSTR ServerName,
656 _In_ ULONG Flags,
657 _Out_ PDS_DOMAIN_TRUSTSW *Domains,
658 _Out_ PULONG DomainCount)
659 {
660 FIXME("DsEnumerateDomainTrustsW(%s, %x, %p, %p)\n",
661 debugstr_w(ServerName), Flags, Domains, DomainCount);
662 return ERROR_CALL_NOT_IMPLEMENTED;
663 }
664
665
666 DWORD
667 WINAPI
668 DsGetDcNameA(
669 _In_opt_ LPCSTR ComputerName,
670 _In_ LPCSTR DomainName,
671 _In_ GUID *DomainGuid,
672 _In_ LPCSTR SiteName,
673 _In_ ULONG Flags,
674 _Out_ PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo)
675 {
676 TRACE("DsGetDcNameA(%s, %s, %s, %s, %08lx, %p): stub\n",
677 debugstr_a(ComputerName), debugstr_a(DomainName), debugstr_guid(DomainGuid),
678 debugstr_a(SiteName), Flags, DomainControllerInfo);
679 return DsGetDcNameWithAccountA(ComputerName,
680 NULL,
681 0,
682 DomainName,
683 DomainGuid,
684 SiteName,
685 Flags,
686 DomainControllerInfo);
687 }
688
689
690 DWORD
691 WINAPI
692 DsGetDcNameW(
693 _In_opt_ LPCWSTR ComputerName,
694 _In_ LPCWSTR DomainName,
695 _In_ GUID *DomainGuid,
696 _In_ LPCWSTR SiteName,
697 _In_ ULONG Flags,
698 _Out_ PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo)
699 {
700 TRACE("DsGetDcNameW(%s, %s, %s, %s, %08lx, %p)\n",
701 debugstr_w(ComputerName), debugstr_w(DomainName), debugstr_guid(DomainGuid),
702 debugstr_w(SiteName), Flags, DomainControllerInfo);
703 return DsGetDcNameWithAccountW(ComputerName,
704 NULL,
705 0,
706 DomainName,
707 DomainGuid,
708 SiteName,
709 Flags,
710 DomainControllerInfo);
711 }
712
713
714 DWORD
715 WINAPI
716 DsGetDcNameWithAccountA(
717 _In_opt_ LPCSTR ComputerName,
718 _In_opt_ LPCSTR AccountName,
719 _In_ ULONG AccountControlBits,
720 _In_ LPCSTR DomainName,
721 _In_ GUID *DomainGuid,
722 _In_ LPCSTR SiteName,
723 _In_ ULONG Flags,
724 _Out_ PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo)
725 {
726 PWSTR pComputerNameW = NULL, pAccountNameW = NULL;
727 PWSTR pDomainNameW = NULL, pSiteNameW = NULL;
728 PDOMAIN_CONTROLLER_INFOW pDomainControllerInfoW = NULL;
729 PDOMAIN_CONTROLLER_INFOA pDomainControllerInfoA = NULL;
730 UNICODE_STRING UnicodeString;
731 ANSI_STRING AnsiString;
732 PSTR Ptr;
733 ULONG BufferSize;
734 NTSTATUS Status;
735 NET_API_STATUS status = NERR_Success;
736
737 TRACE("DsGetDcNameWithAccountA(%s, %s, %08lx, %s, %s, %s, %08lx, %p): stub\n",
738 debugstr_a(ComputerName), debugstr_a(AccountName), AccountControlBits,
739 debugstr_a(DomainName), debugstr_guid(DomainGuid),
740 debugstr_a(SiteName), Flags, DomainControllerInfo);
741
742 if (ComputerName != NULL)
743 {
744 pComputerNameW = NetpAllocWStrFromAnsiStr((PSTR)ComputerName);
745 if (pComputerNameW == NULL)
746 {
747 status = ERROR_NOT_ENOUGH_MEMORY;
748 goto done;
749 }
750 }
751
752 if (AccountName != NULL)
753 {
754 pAccountNameW = NetpAllocWStrFromAnsiStr((PSTR)AccountName);
755 if (pAccountNameW == NULL)
756 {
757 status = ERROR_NOT_ENOUGH_MEMORY;
758 goto done;
759 }
760 }
761
762 pDomainNameW = NetpAllocWStrFromAnsiStr((PSTR)DomainName);
763 if (pDomainNameW == NULL)
764 {
765 status = ERROR_NOT_ENOUGH_MEMORY;
766 goto done;
767 }
768
769 pSiteNameW = NetpAllocWStrFromAnsiStr((PSTR)SiteName);
770 if (pSiteNameW == NULL)
771 {
772 status = ERROR_NOT_ENOUGH_MEMORY;
773 goto done;
774 }
775
776 status = DsGetDcNameWithAccountW(pComputerNameW,
777 pAccountNameW,
778 AccountControlBits,
779 pDomainNameW,
780 DomainGuid,
781 pSiteNameW,
782 Flags,
783 &pDomainControllerInfoW);
784 if (status != NERR_Success)
785 goto done;
786
787 BufferSize = sizeof(DOMAIN_CONTROLLER_INFOA);
788
789 RtlInitUnicodeString(&UnicodeString,
790 pDomainControllerInfoW->DomainControllerName);
791 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
792
793 RtlInitUnicodeString(&UnicodeString,
794 pDomainControllerInfoW->DomainControllerAddress);
795 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
796
797 RtlInitUnicodeString(&UnicodeString,
798 pDomainControllerInfoW->DomainName);
799 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
800
801 RtlInitUnicodeString(&UnicodeString,
802 pDomainControllerInfoW->DnsForestName);
803 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
804
805 if (pDomainControllerInfoW->DcSiteName != NULL)
806 {
807 RtlInitUnicodeString(&UnicodeString,
808 pDomainControllerInfoW->DcSiteName);
809 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
810 }
811
812 if (pDomainControllerInfoW->ClientSiteName != NULL)
813 {
814 RtlInitUnicodeString(&UnicodeString,
815 pDomainControllerInfoW->ClientSiteName);
816 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
817 }
818
819 /* Allocate the ANSI buffer */
820 status = NetApiBufferAllocate(BufferSize, (PVOID*)&pDomainControllerInfoA);
821 if (status != NERR_Success)
822 goto done;
823
824 pDomainControllerInfoA->DomainControllerAddressType =
825 pDomainControllerInfoW->DomainControllerAddressType;
826
827 pDomainControllerInfoA->Flags = pDomainControllerInfoW->Flags;
828
829 CopyMemory(&pDomainControllerInfoA->DomainGuid,
830 &pDomainControllerInfoW->DomainGuid,
831 sizeof(GUID));
832
833 Ptr = (PSTR)((ULONG_PTR)pDomainControllerInfoA + sizeof(DOMAIN_CONTROLLER_INFOA));
834 BufferSize -= sizeof(DOMAIN_CONTROLLER_INFOA);
835
836 pDomainControllerInfoA->DomainControllerName = Ptr;
837 RtlInitUnicodeString(&UnicodeString,
838 pDomainControllerInfoW->DomainControllerName);
839 AnsiString.Length = 0;
840 AnsiString.MaximumLength = BufferSize;
841 AnsiString.Buffer = Ptr;
842
843 Status = RtlUnicodeStringToAnsiString(&AnsiString,
844 &UnicodeString,
845 FALSE);
846 if (!NT_SUCCESS(Status))
847 {
848 status = RtlNtStatusToDosError(Status);
849 goto done;
850 }
851
852 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
853 BufferSize -= AnsiString.Length + sizeof(CHAR);
854
855 pDomainControllerInfoA->DomainControllerAddress = Ptr;
856 RtlInitUnicodeString(&UnicodeString,
857 pDomainControllerInfoW->DomainControllerAddress);
858 AnsiString.Length = 0;
859 AnsiString.MaximumLength = BufferSize;
860 AnsiString.Buffer = Ptr;
861
862 Status = RtlUnicodeStringToAnsiString(&AnsiString,
863 &UnicodeString,
864 FALSE);
865 if (!NT_SUCCESS(Status))
866 {
867 status = RtlNtStatusToDosError(Status);
868 goto done;
869 }
870
871 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
872 BufferSize -= AnsiString.Length + sizeof(CHAR);
873
874 pDomainControllerInfoA->DomainName = Ptr;
875 RtlInitUnicodeString(&UnicodeString,
876 pDomainControllerInfoW->DomainName);
877 AnsiString.Length = 0;
878 AnsiString.MaximumLength = BufferSize;
879 AnsiString.Buffer = Ptr;
880
881 Status = RtlUnicodeStringToAnsiString(&AnsiString,
882 &UnicodeString,
883 FALSE);
884 if (!NT_SUCCESS(Status))
885 {
886 status = RtlNtStatusToDosError(Status);
887 goto done;
888 }
889
890 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
891 BufferSize -= AnsiString.Length + sizeof(CHAR);
892
893 pDomainControllerInfoA->DnsForestName = Ptr;
894 RtlInitUnicodeString(&UnicodeString,
895 pDomainControllerInfoW->DnsForestName);
896 AnsiString.Length = 0;
897 AnsiString.MaximumLength = BufferSize;
898 AnsiString.Buffer = Ptr;
899
900 Status = RtlUnicodeStringToAnsiString(&AnsiString,
901 &UnicodeString,
902 FALSE);
903 if (!NT_SUCCESS(Status))
904 {
905 status = RtlNtStatusToDosError(Status);
906 goto done;
907 }
908
909 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
910 BufferSize -= AnsiString.Length + sizeof(CHAR);
911
912 if (pDomainControllerInfoW->DcSiteName != NULL)
913 {
914 pDomainControllerInfoA->DcSiteName = Ptr;
915 RtlInitUnicodeString(&UnicodeString,
916 pDomainControllerInfoW->DcSiteName);
917 AnsiString.Length = 0;
918 AnsiString.MaximumLength = BufferSize;
919 AnsiString.Buffer = Ptr;
920
921 Status = RtlUnicodeStringToAnsiString(&AnsiString,
922 &UnicodeString,
923 FALSE);
924 if (!NT_SUCCESS(Status))
925 {
926 status = RtlNtStatusToDosError(Status);
927 goto done;
928 }
929
930 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
931 BufferSize -= AnsiString.Length + sizeof(CHAR);
932 }
933
934 if (pDomainControllerInfoW->ClientSiteName != NULL)
935 {
936 pDomainControllerInfoA->ClientSiteName = Ptr;
937 RtlInitUnicodeString(&UnicodeString,
938 pDomainControllerInfoW->ClientSiteName);
939 AnsiString.Length = 0;
940 AnsiString.MaximumLength = BufferSize;
941 AnsiString.Buffer = Ptr;
942
943 Status = RtlUnicodeStringToAnsiString(&AnsiString,
944 &UnicodeString,
945 FALSE);
946 if (!NT_SUCCESS(Status))
947 {
948 status = RtlNtStatusToDosError(Status);
949 goto done;
950 }
951 }
952
953 *DomainControllerInfo = pDomainControllerInfoA;
954 pDomainControllerInfoA = NULL;
955
956 done:
957 if (pDomainControllerInfoA != NULL)
958 NetApiBufferFree(pDomainControllerInfoA);
959
960 if (pDomainControllerInfoW != NULL)
961 NetApiBufferFree(pDomainControllerInfoW);
962
963 if (pSiteNameW != NULL)
964 NetApiBufferFree(pSiteNameW);
965
966 if (pDomainNameW != NULL)
967 NetApiBufferFree(pDomainNameW);
968
969 if (pAccountNameW != NULL)
970 NetApiBufferFree(pAccountNameW);
971
972 if (pComputerNameW != NULL)
973 NetApiBufferFree(pComputerNameW);
974
975 return status;
976 }
977
978
979 DWORD
980 WINAPI
981 DsGetDcNameWithAccountW(
982 _In_opt_ LPCWSTR ComputerName,
983 _In_opt_ LPCWSTR AccountName,
984 _In_ ULONG AccountControlBits,
985 _In_ LPCWSTR DomainName,
986 _In_ GUID *DomainGuid,
987 _In_ LPCWSTR SiteName,
988 _In_ ULONG Flags,
989 _Out_ PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo)
990 {
991 NET_API_STATUS status;
992
993 TRACE("DsGetDcNameWithAccountW(%s, %s, %08lx, %s, %s, %s, %08lx, %p): stub\n",
994 debugstr_w(ComputerName), debugstr_w(AccountName), AccountControlBits,
995 debugstr_w(DomainName), debugstr_guid(DomainGuid),
996 debugstr_w(SiteName), Flags, DomainControllerInfo);
997
998 RpcTryExcept
999 {
1000 status = DsrGetDcNameEx2((PWSTR)ComputerName,
1001 (PWSTR)AccountName,
1002 AccountControlBits,
1003 (PWSTR)DomainName,
1004 DomainGuid,
1005 (PWSTR)SiteName,
1006 Flags,
1007 DomainControllerInfo);
1008 }
1009 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1010 {
1011 status = I_RpcMapWin32Status(RpcExceptionCode());
1012 }
1013 RpcEndExcept;
1014
1015 return status;
1016 }
1017
1018
1019 DWORD
1020 WINAPI
1021 DsGetDcSiteCoverageA(
1022 _In_opt_ LPCSTR ServerName,
1023 _Out_ PULONG EntryCount,
1024 _Out_ LPSTR **SiteNames)
1025 {
1026 PWSTR pServerNameW = NULL;
1027 PWSTR *pSiteNamesW = NULL;
1028 PSTR *pSiteNamesA = NULL;
1029 UNICODE_STRING UnicodeString;
1030 ANSI_STRING AnsiString;
1031 PSTR Ptr;
1032 ULONG BufferSize, i;
1033 NTSTATUS Status;
1034 NET_API_STATUS status = NERR_Success;
1035
1036 TRACE("DsGetDcSiteCoverageA(%s, %p, %p)\n",
1037 debugstr_a(ServerName), EntryCount, SiteNames);
1038
1039 if (ServerName != NULL)
1040 {
1041 pServerNameW = NetpAllocWStrFromAnsiStr((PSTR)ServerName);
1042 if (pServerNameW == NULL)
1043 {
1044 status = ERROR_NOT_ENOUGH_MEMORY;
1045 goto done;
1046 }
1047 }
1048
1049 status = DsGetDcSiteCoverageW(pServerNameW,
1050 EntryCount,
1051 &pSiteNamesW);
1052 if (status != ERROR_SUCCESS)
1053 goto done;
1054
1055 BufferSize = *EntryCount * sizeof(PSTR);
1056 for (i = 0; i < *EntryCount; i++)
1057 {
1058 RtlInitUnicodeString(&UnicodeString, pSiteNamesW[i]);
1059 BufferSize += RtlUnicodeStringToAnsiSize(&UnicodeString);
1060 }
1061
1062 status = NetApiBufferAllocate(BufferSize, (PVOID*)&pSiteNamesA);
1063 if (status != NERR_Success)
1064 goto done;
1065
1066 ZeroMemory(pSiteNamesA, BufferSize);
1067
1068 Ptr = (PSTR)((ULONG_PTR)pSiteNamesA + *EntryCount * sizeof(PSTR));
1069 for (i = 0; i < *EntryCount; i++)
1070 {
1071 pSiteNamesA[i] = Ptr;
1072
1073 RtlInitUnicodeString(&UnicodeString, pSiteNamesW[i]);
1074
1075 AnsiString.Length = 0;
1076 AnsiString.MaximumLength = BufferSize;
1077 AnsiString.Buffer = Ptr;
1078
1079 Status = RtlUnicodeStringToAnsiString(&AnsiString,
1080 &UnicodeString,
1081 FALSE);
1082 if (!NT_SUCCESS(Status))
1083 {
1084 status = RtlNtStatusToDosError(Status);
1085 goto done;
1086 }
1087
1088 Ptr = (PSTR)((ULONG_PTR)Ptr + AnsiString.Length + sizeof(CHAR));
1089 BufferSize -= (AnsiString.Length + sizeof(CHAR));
1090 }
1091
1092 *SiteNames = pSiteNamesA;
1093 pSiteNamesA = NULL;
1094
1095 done:
1096 if (status != NERR_Success && pSiteNamesA != NULL)
1097 NetApiBufferFree(pSiteNamesA);
1098
1099 if (pSiteNamesW != NULL)
1100 NetApiBufferFree(pSiteNamesW);
1101
1102 if (pServerNameW != NULL)
1103 NetApiBufferFree(pServerNameW);
1104
1105 return status;
1106 }
1107
1108
1109 DWORD
1110 WINAPI
1111 DsGetDcSiteCoverageW(
1112 _In_opt_ LPCWSTR ServerName,
1113 _Out_ PULONG EntryCount,
1114 _Out_ LPWSTR **SiteNames)
1115 {
1116 PNL_SITE_NAME_ARRAY SiteNameArray = NULL;
1117 PWSTR *SiteNamesBuffer = NULL, Ptr;
1118 ULONG BufferSize, i;
1119 NET_API_STATUS status;
1120
1121 TRACE("DsGetDcSiteCoverageW(%s, %p, %p)\n",
1122 debugstr_w(ServerName), EntryCount, SiteNames);
1123
1124 *EntryCount = 0;
1125 *SiteNames = NULL;
1126
1127 RpcTryExcept
1128 {
1129 status = DsrGetDcSiteCoverageW((PWSTR)ServerName,
1130 &SiteNameArray);
1131 if (status == NERR_Success)
1132 {
1133 if (SiteNameArray->EntryCount == 0)
1134 {
1135 status = ERROR_INVALID_PARAMETER;
1136 }
1137 else
1138 {
1139 BufferSize = SiteNameArray->EntryCount * sizeof(PWSTR);
1140 for (i = 0; i < SiteNameArray->EntryCount; i++)
1141 BufferSize += SiteNameArray->SiteNames[i].Length + sizeof(WCHAR);
1142
1143 status = NetApiBufferAllocate(BufferSize, (PVOID*)&SiteNamesBuffer);
1144 if (status == NERR_Success)
1145 {
1146 ZeroMemory(SiteNamesBuffer, BufferSize);
1147
1148 Ptr = (PWSTR)((ULONG_PTR)SiteNamesBuffer + SiteNameArray->EntryCount * sizeof(PWSTR));
1149 for (i = 0; i < SiteNameArray->EntryCount; i++)
1150 {
1151 SiteNamesBuffer[i] = Ptr;
1152 CopyMemory(Ptr,
1153 SiteNameArray->SiteNames[i].Buffer,
1154 SiteNameArray->SiteNames[i].Length);
1155
1156 Ptr = (PWSTR)((ULONG_PTR)Ptr + SiteNameArray->SiteNames[i].Length + sizeof(WCHAR));
1157 }
1158
1159 *EntryCount = SiteNameArray->EntryCount;
1160 *SiteNames = SiteNamesBuffer;
1161 }
1162 }
1163
1164 MIDL_user_free(SiteNameArray);
1165 }
1166 }
1167 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1168 {
1169 status = I_RpcMapWin32Status(RpcExceptionCode());
1170 }
1171 RpcEndExcept;
1172
1173 return status;
1174 }
1175
1176
1177 DWORD
1178 WINAPI
1179 DsGetForestTrustInformationW(
1180 _In_opt_ LPCWSTR ServerName,
1181 _In_opt_ LPCWSTR TrustedDomainName,
1182 _In_ DWORD Flags,
1183 _Out_ PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
1184 {
1185 NET_API_STATUS status;
1186
1187 TRACE("DsGetForestTrustInformationW(%s, %s, 0x%08lx, %p)\n",
1188 debugstr_w(ServerName), debugstr_w(TrustedDomainName),
1189 Flags, ForestTrustInfo);
1190
1191 RpcTryExcept
1192 {
1193 status = DsrGetForestTrustInformation((PWSTR)ServerName,
1194 (PWSTR)TrustedDomainName,
1195 Flags,
1196 ForestTrustInfo);
1197 }
1198 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1199 {
1200 status = I_RpcMapWin32Status(RpcExceptionCode());
1201 }
1202 RpcEndExcept;
1203
1204 return status;
1205 }
1206
1207
1208 DWORD
1209 WINAPI
1210 DsGetSiteNameA(
1211 _In_opt_ LPCSTR ComputerName,
1212 _Out_ LPSTR *SiteName)
1213 {
1214 PWSTR pComputerNameW = NULL;
1215 PWSTR pSiteNameW = NULL;
1216 NET_API_STATUS status = ERROR_SUCCESS;
1217
1218 TRACE("DsGetSiteNameA(%s, %p)\n",
1219 debugstr_a(ComputerName), SiteName);
1220
1221 if (ComputerName != NULL)
1222 {
1223 pComputerNameW = NetpAllocWStrFromAnsiStr((PSTR)ComputerName);
1224 if (pComputerNameW == NULL)
1225 {
1226 status = ERROR_NOT_ENOUGH_MEMORY;
1227 goto done;
1228 }
1229 }
1230
1231 status = DsGetSiteNameW(pComputerNameW,
1232 &pSiteNameW);
1233 if (status != ERROR_SUCCESS)
1234 goto done;
1235
1236 *SiteName = NetpAllocAnsiStrFromWStr(pSiteNameW);
1237 if (*SiteName == NULL)
1238 {
1239 status = ERROR_NOT_ENOUGH_MEMORY;
1240 }
1241
1242 done:
1243 if (pSiteNameW != NULL)
1244 NetApiBufferFree(pSiteNameW);
1245
1246 if (pComputerNameW != NULL)
1247 NetApiBufferFree(pComputerNameW);
1248
1249 return status;
1250 }
1251
1252
1253 DWORD
1254 WINAPI
1255 DsGetSiteNameW(
1256 _In_opt_ LPCWSTR ComputerName,
1257 _Out_ LPWSTR *SiteName)
1258 {
1259 NET_API_STATUS status;
1260
1261 TRACE("DsGetSiteNameW(%s, %p)\n",
1262 debugstr_w(ComputerName), SiteName);
1263
1264 RpcTryExcept
1265 {
1266 status = DsrGetSiteName((PWSTR)ComputerName,
1267 SiteName);
1268 }
1269 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1270 {
1271 status = I_RpcMapWin32Status(RpcExceptionCode());
1272 }
1273 RpcEndExcept;
1274
1275 return status;
1276 }
1277
1278
1279 DWORD
1280 WINAPI
1281 DsMergeForestTrustInformationW(
1282 _In_ LPCWSTR DomainName,
1283 _In_ PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo,
1284 _In_opt_ PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo,
1285 _Out_ PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
1286 {
1287 FIXME("DsMergeForestTrustInformationW(%s, %p, %p, %p)\n",
1288 debugstr_w(DomainName), NewForestTrustInfo,
1289 OldForestTrustInfo, ForestTrustInfo);
1290 return ERROR_CALL_NOT_IMPLEMENTED;
1291 }
1292
1293
1294 DWORD
1295 WINAPI
1296 DsValidateSubnetNameA(
1297 _In_ LPCSTR SubnetName)
1298 {
1299 FIXME("DsValidateSubnetNameA(%s)\n",
1300 debugstr_a(SubnetName));
1301 return ERROR_CALL_NOT_IMPLEMENTED;
1302 }
1303
1304
1305 DWORD
1306 WINAPI
1307 DsValidateSubnetNameW(
1308 _In_ LPCWSTR SubnetName)
1309 {
1310 FIXME("DsValidateSubnetNameW(%s)\n",
1311 debugstr_w(SubnetName));
1312 return ERROR_CALL_NOT_IMPLEMENTED;
1313 }
1314
1315
1316 NTSTATUS
1317 WINAPI
1318 NetEnumerateTrustedDomains(
1319 _In_ LPWSTR ServerName,
1320 _Out_ LPWSTR *DomainNames)
1321 {
1322 DOMAIN_NAME_BUFFER DomainNameBuffer = {0, NULL};
1323 NTSTATUS Status = 0;
1324
1325 TRACE("NetEnumerateTrustedDomains(%s, %p)\n",
1326 debugstr_w(ServerName), DomainNames);
1327
1328 RpcTryExcept
1329 {
1330 Status = NetrEnumerateTrustedDomains(ServerName,
1331 &DomainNameBuffer);
1332 if (NT_SUCCESS(Status))
1333 {
1334 *DomainNames = (LPWSTR)DomainNameBuffer.DomainNames;
1335 }
1336 }
1337 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1338 {
1339 Status = I_RpcMapWin32Status(RpcExceptionCode());
1340 } RpcEndExcept;
1341
1342 return Status;
1343 }
1344
1345
1346 NET_API_STATUS
1347 WINAPI
1348 NetGetAnyDCName(
1349 _In_opt_ LPCWSTR ServerName,
1350 _In_opt_ LPCWSTR DomainName,
1351 _Out_ LPBYTE *BufPtr)
1352 {
1353 NET_API_STATUS Status;
1354
1355 TRACE("NetGetAnyDCName(%s, %s, %p)\n",
1356 debugstr_w(ServerName), debugstr_w(DomainName), BufPtr);
1357
1358 *BufPtr = NULL;
1359
1360 RpcTryExcept
1361 {
1362 Status = NetrGetAnyDCName((PWSTR)ServerName,
1363 (PWSTR)DomainName,
1364 (PWSTR*)BufPtr);
1365 }
1366 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1367 {
1368 Status = I_RpcMapWin32Status(RpcExceptionCode());
1369 }
1370 RpcEndExcept;
1371
1372 return Status;
1373 }
1374
1375
1376 NET_API_STATUS
1377 WINAPI
1378 NetGetDCName(
1379 _In_opt_ LPCWSTR ServerName,
1380 _In_opt_ LPCWSTR DomainName,
1381 _Out_ LPBYTE *BufPtr)
1382 {
1383 PDOMAIN_CONTROLLER_INFOW pDomainControllerInfo = NULL;
1384 NET_API_STATUS Status;
1385
1386 FIXME("NetGetDCName(%s, %s, %p)\n",
1387 debugstr_w(ServerName), debugstr_w(DomainName), BufPtr);
1388
1389 if (ServerName == NULL || *ServerName == UNICODE_NULL)
1390 {
1391 Status = DsGetDcNameWithAccountW(NULL,
1392 NULL,
1393 0,
1394 DomainName,
1395 NULL,
1396 NULL,
1397 0, //???
1398 &pDomainControllerInfo);
1399 if (Status != NERR_Success)
1400 goto done;
1401
1402 Status = NetApiBufferAllocate((wcslen(pDomainControllerInfo->DomainControllerName) + 1) * sizeof(WCHAR),
1403 (PVOID*)BufPtr);
1404 if (Status != NERR_Success)
1405 goto done;
1406
1407 wcscpy((PWSTR)*BufPtr,
1408 pDomainControllerInfo->DomainControllerName);
1409 }
1410 else
1411 {
1412 FIXME("Not implemented yet!\n");
1413 Status = NERR_DCNotFound;
1414 }
1415
1416 done:
1417 if (pDomainControllerInfo != NULL)
1418 NetApiBufferFree(pDomainControllerInfo);
1419
1420 return Status;
1421 }
1422
1423
1424 NET_API_STATUS
1425 WINAPI
1426 NetLogonGetTimeServiceParentDomain(
1427 _In_ LPWSTR ServerName,
1428 _Out_ LPWSTR *DomainName,
1429 _Out_ LPBOOL PdcSameSite)
1430 {
1431 NET_API_STATUS Status;
1432
1433 TRACE("NetLogonGetTimeServiceParentDomain(%s, %p, %p)\n",
1434 debugstr_w(ServerName), DomainName, PdcSameSite);
1435
1436 RpcTryExcept
1437 {
1438 Status = NetrLogonGetTimeServiceParentDomain(ServerName,
1439 DomainName,
1440 PdcSameSite);
1441 }
1442 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1443 {
1444 Status = I_RpcMapWin32Status(RpcExceptionCode());
1445 }
1446 RpcEndExcept;
1447
1448 return Status;
1449 }
1450
1451
1452 NTSTATUS
1453 WINAPI
1454 NetLogonSetServiceBits(
1455 _In_ LPWSTR ServerName,
1456 _In_ DWORD ServiceBitsOfInterest,
1457 _In_ DWORD ServiceBits)
1458 {
1459 NTSTATUS Status;
1460
1461 TRACE("NetLogonSetServiceBits(%s 0x%lx 0x%lx)\n",
1462 debugstr_w(ServerName), ServiceBitsOfInterest, ServiceBits);
1463
1464 RpcTryExcept
1465 {
1466 Status = NetrLogonSetServiceBits(ServerName,
1467 ServiceBitsOfInterest,
1468 ServiceBits);
1469 }
1470 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1471 {
1472 Status = RpcExceptionCode();
1473 }
1474 RpcEndExcept;
1475
1476 return Status;
1477 }
1478
1479 /* EOF */