2 Unix SMB/CIFS implementation.
6 Copyright (C) 2010 Kai Blin <kai@samba.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "libcli/util/ntstatus.h"
24 #include "libcli/util/werror.h"
25 #include "librpc/ndr/libndr.h"
26 #include "librpc/gen_ndr/ndr_dns.h"
27 #include "librpc/gen_ndr/ndr_dnsp.h"
29 #include "dsdb/samdb/samdb.h"
30 #include "dsdb/common/util.h"
31 #include "dns_server/dns_server.h"
34 #define DBGC_CLASS DBGC_DNS
38 * Lookup a DNS record, performing an exact match.
39 * i.e. DNS wild card records are not considered.
41 WERROR
dns_lookup_records(struct dns_server
*dns
,
44 struct dnsp_DnssrvRpcRecord
**records
,
47 return dns_common_lookup(dns
->samdb
, mem_ctx
, dn
,
48 records
, rec_count
, NULL
);
52 * Lookup a DNS record, will match DNS wild card records if an exact match
55 WERROR
dns_lookup_records_wildcard(struct dns_server
*dns
,
58 struct dnsp_DnssrvRpcRecord
**records
,
61 return dns_common_wildcard_lookup(dns
->samdb
, mem_ctx
, dn
,
65 WERROR
dns_replace_records(struct dns_server
*dns
,
69 struct dnsp_DnssrvRpcRecord
*records
,
72 /* TODO: Autogenerate this somehow */
73 uint32_t dwSerial
= 110;
74 return dns_common_replace(dns
->samdb
, mem_ctx
, dn
,
75 needs_add
, dwSerial
, records
, rec_count
);
78 bool dns_authoritative_for_zone(struct dns_server
*dns
,
81 const struct dns_server_zone
*z
;
82 size_t host_part_len
= 0;
88 if (strcmp(name
, "") == 0) {
91 for (z
= dns
->zones
; z
!= NULL
; z
= z
->next
) {
94 match
= dns_name_match(z
->name
, name
, &host_part_len
);
106 const char *dns_get_authoritative_zone(struct dns_server
*dns
,
109 const struct dns_server_zone
*z
;
110 size_t host_part_len
= 0;
112 for (z
= dns
->zones
; z
!= NULL
; z
= z
->next
) {
114 match
= dns_name_match(z
->name
, name
, &host_part_len
);
122 WERROR
dns_name2dn(struct dns_server
*dns
,
127 return dns_common_name2dn(dns
->samdb
, dns
->zones
,