2 Unix SMB/CIFS implementation.
4 Copyright (C) Gerald (Jerry) Carter 2006.
5 Copyright (C) Jeremy Allison 2007.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "libads/dns.h"
24 /* AIX resolv.h uses 'class' in struct ns_rr */
32 /* resolver headers */
34 #include <sys/types.h>
35 #include <netinet/in.h>
36 #include <arpa/nameser.h>
40 #define MAX_DNS_PACKET_SIZE 0xffff
42 #ifdef NS_HFIXEDSZ /* Bind 8/9 interface */
43 #if !defined(C_IN) /* AIX 5.3 already defines C_IN */
46 #if !defined(T_A) /* AIX 5.3 already defines T_A */
50 #if defined(HAVE_IPV6)
52 # define T_AAAA ns_t_aaaa
56 # define T_SRV ns_t_srv
57 #if !defined(T_NS) /* AIX 5.3 already defines T_NS */
62 # define NS_HFIXEDSZ HFIXEDSZ
64 # define NS_HFIXEDSZ sizeof(HEADER)
65 # endif /* HFIXEDSZ */
67 # define NS_PACKETSZ PACKETSZ
68 # else /* 512 is usually the default */
69 # define NS_PACKETSZ 512
70 # endif /* PACKETSZ */
74 /*********************************************************************
75 *********************************************************************/
77 static bool ads_dns_parse_query( TALLOC_CTX
*ctx
, uint8
*start
, uint8
*end
,
78 uint8
**ptr
, struct dns_query
*q
)
81 char hostname
[MAX_DNS_NAME_LENGTH
];
86 if ( !start
|| !end
|| !q
|| !*ptr
)
89 /* See RFC 1035 for details. If this fails, then return. */
91 namelen
= dn_expand( start
, end
, p
, hostname
, sizeof(hostname
) );
96 q
->hostname
= talloc_strdup( ctx
, hostname
);
98 /* check that we have space remaining */
100 if ( PTR_DIFF(p
+4, end
) > 0 )
103 q
->type
= RSVAL( p
, 0 );
104 q
->in_class
= RSVAL( p
, 2 );
112 /*********************************************************************
113 *********************************************************************/
115 static bool ads_dns_parse_rr( TALLOC_CTX
*ctx
, uint8
*start
, uint8
*end
,
116 uint8
**ptr
, struct dns_rr
*rr
)
119 char hostname
[MAX_DNS_NAME_LENGTH
];
122 if ( !start
|| !end
|| !rr
|| !*ptr
)
126 /* pull the name from the answer */
128 namelen
= dn_expand( start
, end
, p
, hostname
, sizeof(hostname
) );
133 rr
->hostname
= talloc_strdup( ctx
, hostname
);
135 /* check that we have space remaining */
137 if ( PTR_DIFF(p
+10, end
) > 0 )
140 /* pull some values and then skip onto the string */
142 rr
->type
= RSVAL(p
, 0);
143 rr
->in_class
= RSVAL(p
, 2);
144 rr
->ttl
= RIVAL(p
, 4);
145 rr
->rdatalen
= RSVAL(p
, 8);
149 /* sanity check the available space */
151 if ( PTR_DIFF(p
+rr
->rdatalen
, end
) > 0 ) {
156 /* save a point to the rdata for this section */
166 /*********************************************************************
167 *********************************************************************/
169 static bool ads_dns_parse_rr_srv( TALLOC_CTX
*ctx
, uint8
*start
, uint8
*end
,
170 uint8
**ptr
, struct dns_rr_srv
*srv
)
174 char dcname
[MAX_DNS_NAME_LENGTH
];
177 if ( !start
|| !end
|| !srv
|| !*ptr
)
180 /* Parse the RR entry. Coming out of the this, ptr is at the beginning
181 of the next record */
183 if ( !ads_dns_parse_rr( ctx
, start
, end
, ptr
, &rr
) ) {
184 DEBUG(1,("ads_dns_parse_rr_srv: Failed to parse RR record\n"));
188 if ( rr
.type
!= T_SRV
) {
189 DEBUG(1,("ads_dns_parse_rr_srv: Bad answer type (%d)\n",
196 srv
->priority
= RSVAL(p
, 0);
197 srv
->weight
= RSVAL(p
, 2);
198 srv
->port
= RSVAL(p
, 4);
202 namelen
= dn_expand( start
, end
, p
, dcname
, sizeof(dcname
) );
204 DEBUG(1,("ads_dns_parse_rr_srv: Failed to uncompress name!\n"));
208 srv
->hostname
= talloc_strdup( ctx
, dcname
);
210 DEBUG(10,("ads_dns_parse_rr_srv: Parsed %s [%u, %u, %u]\n",
219 /*********************************************************************
220 *********************************************************************/
222 static bool ads_dns_parse_rr_ns( TALLOC_CTX
*ctx
, uint8
*start
, uint8
*end
,
223 uint8
**ptr
, struct dns_rr_ns
*nsrec
)
227 char nsname
[MAX_DNS_NAME_LENGTH
];
230 if ( !start
|| !end
|| !nsrec
|| !*ptr
)
233 /* Parse the RR entry. Coming out of the this, ptr is at the beginning
234 of the next record */
236 if ( !ads_dns_parse_rr( ctx
, start
, end
, ptr
, &rr
) ) {
237 DEBUG(1,("ads_dns_parse_rr_ns: Failed to parse RR record\n"));
241 if ( rr
.type
!= T_NS
) {
242 DEBUG(1,("ads_dns_parse_rr_ns: Bad answer type (%d)\n",
249 /* ame server hostname */
251 namelen
= dn_expand( start
, end
, p
, nsname
, sizeof(nsname
) );
253 DEBUG(1,("ads_dns_parse_rr_ns: Failed to uncompress name!\n"));
256 nsrec
->hostname
= talloc_strdup( ctx
, nsname
);
261 /*********************************************************************
262 Sort SRV record list based on weight and priority. See RFC 2782.
263 *********************************************************************/
265 static int dnssrvcmp( struct dns_rr_srv
*a
, struct dns_rr_srv
*b
)
267 if ( a
->priority
== b
->priority
) {
269 /* randomize entries with an equal weight and priority */
270 if ( a
->weight
== b
->weight
)
273 /* higher weights should be sorted lower */
274 if ( a
->weight
> b
->weight
)
280 if ( a
->priority
< b
->priority
)
286 /*********************************************************************
287 Simple wrapper for a DNS query
288 *********************************************************************/
290 #define DNS_FAILED_WAITTIME 30
292 static NTSTATUS
dns_send_req( TALLOC_CTX
*ctx
, const char *name
, int q_type
,
293 uint8
**buf
, int *resp_length
)
295 uint8
*buffer
= NULL
;
297 int resp_len
= NS_PACKETSZ
;
298 static time_t last_dns_check
= 0;
299 static NTSTATUS last_dns_status
= NT_STATUS_OK
;
300 time_t now
= time_mono(NULL
);
302 /* Try to prevent bursts of DNS lookups if the server is down */
304 /* Protect against large clock changes */
306 if ( last_dns_check
> now
)
309 /* IF we had a DNS timeout or a bad server and we are still
310 in the 30 second cache window, just return the previous
311 status and save the network timeout. */
313 if ( (NT_STATUS_EQUAL(last_dns_status
,NT_STATUS_IO_TIMEOUT
) ||
314 NT_STATUS_EQUAL(last_dns_status
,NT_STATUS_CONNECTION_REFUSED
)) &&
315 (last_dns_check
+DNS_FAILED_WAITTIME
) > now
)
317 DEBUG(10,("last_dns_check: Returning cached status (%s)\n",
318 nt_errstr(last_dns_status
) ));
319 return last_dns_status
;
325 TALLOC_FREE( buffer
);
327 buf_len
= resp_len
* sizeof(uint8
);
330 if ((buffer
= TALLOC_ARRAY(ctx
, uint8
, buf_len
))
332 DEBUG(0,("ads_dns_lookup_srv: "
333 "talloc() failed!\n"));
334 last_dns_status
= NT_STATUS_NO_MEMORY
;
335 last_dns_check
= time_mono(NULL
);
336 return last_dns_status
;
340 if ((resp_len
= res_query(name
, C_IN
, q_type
, buffer
, buf_len
))
342 DEBUG(3,("ads_dns_lookup_srv: "
343 "Failed to resolve %s (%s)\n",
344 name
, strerror(errno
)));
345 TALLOC_FREE( buffer
);
346 last_dns_status
= NT_STATUS_UNSUCCESSFUL
;
348 if (errno
== ETIMEDOUT
) {
349 last_dns_status
= NT_STATUS_IO_TIMEOUT
;
351 if (errno
== ECONNREFUSED
) {
352 last_dns_status
= NT_STATUS_CONNECTION_REFUSED
;
354 last_dns_check
= time_mono(NULL
);
355 return last_dns_status
;
358 /* On AIX, Solaris, and possibly some older glibc systems (e.g. SLES8)
359 truncated replies never give back a resp_len > buflen
360 which ends up causing DNS resolve failures on large tcp DNS replies */
362 if (buf_len
== resp_len
) {
363 if (resp_len
== MAX_DNS_PACKET_SIZE
) {
364 DEBUG(1,("dns_send_req: DNS reply too large when resolving %s\n",
366 TALLOC_FREE( buffer
);
367 last_dns_status
= NT_STATUS_BUFFER_TOO_SMALL
;
368 last_dns_check
= time_mono(NULL
);
369 return last_dns_status
;
372 resp_len
= MIN(resp_len
*2, MAX_DNS_PACKET_SIZE
);
376 } while ( buf_len
< resp_len
&& resp_len
<= MAX_DNS_PACKET_SIZE
);
379 *resp_length
= resp_len
;
381 last_dns_check
= time_mono(NULL
);
382 last_dns_status
= NT_STATUS_OK
;
383 return last_dns_status
;
386 /*********************************************************************
387 Simple wrapper for a DNS SRV query
388 *********************************************************************/
390 static NTSTATUS
ads_dns_lookup_srv( TALLOC_CTX
*ctx
,
392 struct dns_rr_srv
**dclist
,
395 uint8
*buffer
= NULL
;
397 struct dns_rr_srv
*dcs
= NULL
;
398 int query_count
, answer_count
, auth_count
, additional_count
;
404 if ( !ctx
|| !name
|| !dclist
) {
405 return NT_STATUS_INVALID_PARAMETER
;
408 /* Send the request. May have to loop several times in case
411 status
= dns_send_req( ctx
, name
, T_SRV
, &buffer
, &resp_len
);
412 if ( !NT_STATUS_IS_OK(status
) ) {
413 DEBUG(3,("ads_dns_lookup_srv: Failed to send DNS query (%s)\n",
419 /* For some insane reason, the ns_initparse() et. al. routines are only
420 available in libresolv.a, and not the shared lib. Who knows why....
421 So we have to parse the DNS reply ourselves */
423 /* Pull the answer RR's count from the header.
424 * Use the NMB ordering macros */
426 query_count
= RSVAL( p
, 4 );
427 answer_count
= RSVAL( p
, 6 );
428 auth_count
= RSVAL( p
, 8 );
429 additional_count
= RSVAL( p
, 10 );
431 DEBUG(4,("ads_dns_lookup_srv: "
432 "%d records returned in the answer section.\n",
436 if ((dcs
= TALLOC_ZERO_ARRAY(ctx
, struct dns_rr_srv
,
437 answer_count
)) == NULL
) {
438 DEBUG(0,("ads_dns_lookup_srv: "
439 "talloc() failure for %d char*'s\n",
441 return NT_STATUS_NO_MEMORY
;
447 /* now skip the header */
451 /* parse the query section */
453 for ( rrnum
=0; rrnum
<query_count
; rrnum
++ ) {
456 if (!ads_dns_parse_query(ctx
, buffer
,
457 buffer
+resp_len
, &p
, &q
)) {
458 DEBUG(1,("ads_dns_lookup_srv: "
459 "Failed to parse query record [%d]!\n", rrnum
));
460 return NT_STATUS_UNSUCCESSFUL
;
464 /* now we are at the answer section */
466 for ( rrnum
=0; rrnum
<answer_count
; rrnum
++ ) {
467 if (!ads_dns_parse_rr_srv(ctx
, buffer
, buffer
+resp_len
,
469 DEBUG(1,("ads_dns_lookup_srv: "
470 "Failed to parse answer recordi [%d]!\n", rrnum
));
471 return NT_STATUS_UNSUCCESSFUL
;
476 /* Parse the authority section */
477 /* just skip these for now */
479 for ( rrnum
=0; rrnum
<auth_count
; rrnum
++ ) {
482 if (!ads_dns_parse_rr( ctx
, buffer
,
483 buffer
+resp_len
, &p
, &rr
)) {
484 DEBUG(1,("ads_dns_lookup_srv: "
485 "Failed to parse authority record! [%d]\n", rrnum
));
486 return NT_STATUS_UNSUCCESSFUL
;
490 /* Parse the additional records section */
492 for ( rrnum
=0; rrnum
<additional_count
; rrnum
++ ) {
496 if (!ads_dns_parse_rr(ctx
, buffer
, buffer
+resp_len
,
498 DEBUG(1,("ads_dns_lookup_srv: Failed "
499 "to parse additional records section! [%d]\n", rrnum
));
500 return NT_STATUS_UNSUCCESSFUL
;
503 /* Only interested in A or AAAA records as a shortcut for having
504 * to come back later and lookup the name. For multi-homed
505 * hosts, the number of additional records and exceed the
506 * number of answer records. */
508 if (rr
.type
!= T_A
|| rr
.rdatalen
!= 4) {
509 #if defined(HAVE_IPV6)
510 /* RFC2874 defines A6 records. This
511 * requires recusive and horribly complex lookups.
512 * Bastards. Ignore this for now.... JRA.
513 * Luckily RFC3363 reprecates A6 records.
515 if (rr
.type
!= T_AAAA
|| rr
.rdatalen
!= 16)
520 for ( i
=0; i
<idx
; i
++ ) {
521 if ( strcmp( rr
.hostname
, dcs
[i
].hostname
) == 0 ) {
522 int num_ips
= dcs
[i
].num_ips
;
523 struct sockaddr_storage
*tmp_ss_s
;
525 /* allocate new memory */
527 if (dcs
[i
].num_ips
== 0) {
528 if ((dcs
[i
].ss_s
= TALLOC_ARRAY(dcs
,
529 struct sockaddr_storage
, 1 ))
531 return NT_STATUS_NO_MEMORY
;
534 if ((tmp_ss_s
= TALLOC_REALLOC_ARRAY(dcs
,
536 struct sockaddr_storage
,
539 return NT_STATUS_NO_MEMORY
;
542 dcs
[i
].ss_s
= tmp_ss_s
;
546 /* copy the new IP address */
547 if (rr
.type
== T_A
) {
549 memcpy(&ip
, rr
.rdata
, 4);
550 in_addr_to_sockaddr_storage(
551 &dcs
[i
].ss_s
[num_ips
],
554 #if defined(HAVE_IPV6)
555 if (rr
.type
== T_AAAA
) {
557 memcpy(&ip6
, rr
.rdata
, rr
.rdatalen
);
558 in6_addr_to_sockaddr_storage(
559 &dcs
[i
].ss_s
[num_ips
],
567 TYPESAFE_QSORT(dcs
, idx
, dnssrvcmp
);
575 /*********************************************************************
576 Simple wrapper for a DNS NS query
577 *********************************************************************/
579 NTSTATUS
ads_dns_lookup_ns(TALLOC_CTX
*ctx
,
580 const char *dnsdomain
,
581 struct dns_rr_ns
**nslist
,
584 uint8
*buffer
= NULL
;
586 struct dns_rr_ns
*nsarray
= NULL
;
587 int query_count
, answer_count
, auth_count
, additional_count
;
593 if ( !ctx
|| !dnsdomain
|| !nslist
) {
594 return NT_STATUS_INVALID_PARAMETER
;
597 /* Send the request. May have to loop several times in case
600 status
= dns_send_req( ctx
, dnsdomain
, T_NS
, &buffer
, &resp_len
);
601 if ( !NT_STATUS_IS_OK(status
) ) {
602 DEBUG(3,("ads_dns_lookup_ns: Failed to send DNS query (%s)\n",
608 /* For some insane reason, the ns_initparse() et. al. routines are only
609 available in libresolv.a, and not the shared lib. Who knows why....
610 So we have to parse the DNS reply ourselves */
612 /* Pull the answer RR's count from the header.
613 * Use the NMB ordering macros */
615 query_count
= RSVAL( p
, 4 );
616 answer_count
= RSVAL( p
, 6 );
617 auth_count
= RSVAL( p
, 8 );
618 additional_count
= RSVAL( p
, 10 );
620 DEBUG(4,("ads_dns_lookup_ns: "
621 "%d records returned in the answer section.\n",
625 if ((nsarray
= TALLOC_ARRAY(ctx
, struct dns_rr_ns
,
626 answer_count
)) == NULL
) {
627 DEBUG(0,("ads_dns_lookup_ns: "
628 "talloc() failure for %d char*'s\n",
630 return NT_STATUS_NO_MEMORY
;
636 /* now skip the header */
640 /* parse the query section */
642 for ( rrnum
=0; rrnum
<query_count
; rrnum
++ ) {
645 if (!ads_dns_parse_query(ctx
, buffer
, buffer
+resp_len
,
647 DEBUG(1,("ads_dns_lookup_ns: "
648 " Failed to parse query record!\n"));
649 return NT_STATUS_UNSUCCESSFUL
;
653 /* now we are at the answer section */
655 for ( rrnum
=0; rrnum
<answer_count
; rrnum
++ ) {
656 if (!ads_dns_parse_rr_ns(ctx
, buffer
, buffer
+resp_len
,
657 &p
, &nsarray
[rrnum
])) {
658 DEBUG(1,("ads_dns_lookup_ns: "
659 "Failed to parse answer record!\n"));
660 return NT_STATUS_UNSUCCESSFUL
;
665 /* Parse the authority section */
666 /* just skip these for now */
668 for ( rrnum
=0; rrnum
<auth_count
; rrnum
++ ) {
671 if ( !ads_dns_parse_rr(ctx
, buffer
, buffer
+resp_len
,
673 DEBUG(1,("ads_dns_lookup_ns: "
674 "Failed to parse authority record!\n"));
675 return NT_STATUS_UNSUCCESSFUL
;
679 /* Parse the additional records section */
681 for ( rrnum
=0; rrnum
<additional_count
; rrnum
++ ) {
685 if (!ads_dns_parse_rr(ctx
, buffer
, buffer
+resp_len
,
687 DEBUG(1,("ads_dns_lookup_ns: Failed "
688 "to parse additional records section!\n"));
689 return NT_STATUS_UNSUCCESSFUL
;
692 /* only interested in A records as a shortcut for having to come
693 back later and lookup the name */
695 if (rr
.type
!= T_A
|| rr
.rdatalen
!= 4) {
696 #if defined(HAVE_IPV6)
697 if (rr
.type
!= T_AAAA
|| rr
.rdatalen
!= 16)
702 for ( i
=0; i
<idx
; i
++ ) {
703 if (strcmp(rr
.hostname
, nsarray
[i
].hostname
) == 0) {
704 if (rr
.type
== T_A
) {
706 memcpy(&ip
, rr
.rdata
, 4);
707 in_addr_to_sockaddr_storage(
711 #if defined(HAVE_IPV6)
712 if (rr
.type
== T_AAAA
) {
714 memcpy(&ip6
, rr
.rdata
, rr
.rdatalen
);
715 in6_addr_to_sockaddr_storage(
730 /********************************************************************
731 Query with optional sitename.
732 ********************************************************************/
734 static NTSTATUS
ads_dns_query_internal(TALLOC_CTX
*ctx
,
735 const char *servicename
,
736 const char *dc_pdc_gc_domains
,
738 const char *sitename
,
739 struct dns_rr_srv
**dclist
,
744 name
= talloc_asprintf(ctx
, "%s._tcp.%s._sites.%s._msdcs.%s",
745 servicename
, sitename
,
746 dc_pdc_gc_domains
, realm
);
748 name
= talloc_asprintf(ctx
, "%s._tcp.%s._msdcs.%s",
749 servicename
, dc_pdc_gc_domains
, realm
);
752 return NT_STATUS_NO_MEMORY
;
754 return ads_dns_lookup_srv( ctx
, name
, dclist
, numdcs
);
757 /********************************************************************
759 ********************************************************************/
761 NTSTATUS
ads_dns_query_dcs(TALLOC_CTX
*ctx
,
763 const char *sitename
,
764 struct dns_rr_srv
**dclist
,
769 status
= ads_dns_query_internal(ctx
, "_ldap", "dc", realm
, sitename
,
772 if (NT_STATUS_EQUAL(status
, NT_STATUS_IO_TIMEOUT
) ||
773 NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_REFUSED
)) {
778 ((!NT_STATUS_IS_OK(status
)) ||
779 (NT_STATUS_IS_OK(status
) && (numdcs
== 0)))) {
780 /* Sitename DNS query may have failed. Try without. */
781 status
= ads_dns_query_internal(ctx
, "_ldap", "dc", realm
,
782 NULL
, dclist
, numdcs
);
787 /********************************************************************
789 ********************************************************************/
791 NTSTATUS
ads_dns_query_gcs(TALLOC_CTX
*ctx
,
793 const char *sitename
,
794 struct dns_rr_srv
**dclist
,
799 status
= ads_dns_query_internal(ctx
, "_ldap", "gc", realm
, sitename
,
802 if (NT_STATUS_EQUAL(status
, NT_STATUS_IO_TIMEOUT
) ||
803 NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_REFUSED
)) {
808 ((!NT_STATUS_IS_OK(status
)) ||
809 (NT_STATUS_IS_OK(status
) && (numdcs
== 0)))) {
810 /* Sitename DNS query may have failed. Try without. */
811 status
= ads_dns_query_internal(ctx
, "_ldap", "gc", realm
,
812 NULL
, dclist
, numdcs
);
817 /********************************************************************
819 Even if our underlying kerberos libraries are UDP only, this
820 is pretty safe as it's unlikely that a KDC supports TCP and not UDP.
821 ********************************************************************/
823 NTSTATUS
ads_dns_query_kdcs(TALLOC_CTX
*ctx
,
824 const char *dns_forest_name
,
825 const char *sitename
,
826 struct dns_rr_srv
**dclist
,
831 status
= ads_dns_query_internal(ctx
, "_kerberos", "dc",
832 dns_forest_name
, sitename
, dclist
,
835 if (NT_STATUS_EQUAL(status
, NT_STATUS_IO_TIMEOUT
) ||
836 NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_REFUSED
)) {
841 ((!NT_STATUS_IS_OK(status
)) ||
842 (NT_STATUS_IS_OK(status
) && (numdcs
== 0)))) {
843 /* Sitename DNS query may have failed. Try without. */
844 status
= ads_dns_query_internal(ctx
, "_kerberos", "dc",
845 dns_forest_name
, NULL
,
851 /********************************************************************
852 Query for AD PDC. Sitename is obsolete here.
853 ********************************************************************/
855 NTSTATUS
ads_dns_query_pdc(TALLOC_CTX
*ctx
,
856 const char *dns_domain_name
,
857 struct dns_rr_srv
**dclist
,
860 return ads_dns_query_internal(ctx
, "_ldap", "pdc", dns_domain_name
,
861 NULL
, dclist
, numdcs
);
864 /********************************************************************
865 Query for AD DC by guid. Sitename is obsolete here.
866 ********************************************************************/
868 NTSTATUS
ads_dns_query_dcs_guid(TALLOC_CTX
*ctx
,
869 const char *dns_forest_name
,
870 const struct GUID
*domain_guid
,
871 struct dns_rr_srv
**dclist
,
874 /*_ldap._tcp.DomainGuid.domains._msdcs.DnsForestName */
879 guid_string
= GUID_string(ctx
, domain_guid
);
881 return NT_STATUS_NO_MEMORY
;
885 domains
= talloc_asprintf(ctx
, "%s.domains", guid_string
);
887 return NT_STATUS_NO_MEMORY
;
889 TALLOC_FREE(guid_string
);
891 return ads_dns_query_internal(ctx
, "_ldap", domains
, dns_forest_name
,
892 NULL
, dclist
, numdcs
);