]> git.ipfire.org Git - thirdparty/pdns.git/blame - modules/ldapbackend/ldapbackend.hh
Standardize license text in all PDNS files
[thirdparty/pdns.git] / modules / ldapbackend / ldapbackend.hh
CommitLineData
6d5e9bba 1/*
12471842
PL
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 * originally authored by Norbert Sendetzky
6d5e9bba 5 *
12471842
PL
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
6d5e9bba 9 *
12471842
PL
10 * In addition, for the avoidance of any doubt, permission is granted to
11 * link this program with OpenSSL and to (re)distribute the binaries
12 * produced as the result of such linking.
fc3c07b4 13 *
12471842
PL
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
6d5e9bba 18 *
12471842
PL
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6d5e9bba 22 */
38e22b5a 23#include <algorithm>
4bb1fb74
BH
24#include <sstream>
25#include <utility>
26#include <string>
dd233db7
BH
27#include <cstdlib>
28#include <cctype>
c0ff3710 29#include <inttypes.h>
21e99384
RK
30#include "pdns/dns.hh"
31#include "pdns/utility.hh"
32#include "pdns/dnspacket.hh"
33#include "pdns/dnsbackend.hh"
34#include "pdns/ueberbackend.hh"
35#include "pdns/pdnsexception.hh"
36#include "pdns/arguments.hh"
37#include "pdns/logger.hh"
4bb1fb74 38#include "powerldap.hh"
dd233db7 39#include "utils.hh"
4bb1fb74 40
c533708a 41
4bb1fb74
BH
42
43#ifndef LDAPBACKEND_HH
44#define LDAPBACKEND_HH
45
dd233db7
BH
46using std::string;
47using std::vector;
4bb1fb74
BH
48
49
6d5e9bba 50
45480ad8
BH
51/*
52 * Known DNS RR types
53 * Types which aren't active are currently not supported by PDNS
54 */
55
b02286fd 56static const char* ldap_attrany[] = {
e0ec6e79
BH
57 "associatedDomain",
58 "dNSTTL",
59 "aRecord",
60 "nSRecord",
61 "cNAMERecord",
62 "sOARecord",
63 "pTRRecord",
64 "hInfoRecord",
65 "mXRecord",
66 "tXTRecord",
67 "rPRecord",
68 "aFSDBRecord",
69// "SigRecord",
70 "KeyRecord",
71// "gPosRecord",
72 "aAAARecord",
73 "lOCRecord",
74 "sRVRecord",
75 "nAPTRRecord",
76 "kXRecord",
77 "certRecord",
78// "a6Record",
79// "dNameRecord",
80// "aPLRecord",
81 "dSRecord",
82 "sSHFPRecord",
83 "iPSecKeyRecord",
84 "rRSIGRecord",
85 "nSECRecord",
86 "dNSKeyRecord",
87 "dHCIDRecord",
88 "sPFRecord",
d358f209
PD
89 "TYPE65534Record",
90 "EUI48Record",
91 "EUI64Record",
92 "TYPE65226Record",
e0ec6e79
BH
93 "modifyTimestamp",
94 NULL
4bb1fb74
BH
95};
96
97
98
99class LdapBackend : public DNSBackend
100{
e0ec6e79
BH
101 bool m_getdn;
102 bool m_qlog;
103 int m_msgid;
104 uint32_t m_ttl;
105 uint32_t m_default_ttl;
106 unsigned int m_axfrqlen;
107 time_t m_last_modified;
108 string m_myname;
b30fe14b 109 DNSName m_qname;
e0ec6e79
BH
110 PowerLDAP* m_pldap;
111 PowerLDAP::sentry_t m_result;
112 PowerLDAP::sentry_t::iterator m_attribute;
b30fe14b
PD
113 vector<string>::iterator m_value;
114 vector<DNSName>::iterator m_adomain;
115 vector<DNSName> m_adomains;
e0ec6e79 116
b30fe14b
PD
117 bool (LdapBackend::*m_list_fcnt)( const DNSName&, int );
118 void (LdapBackend::*m_lookup_fcnt)( const QType&, const DNSName&, DNSPacket*, int );
e0ec6e79
BH
119 bool (LdapBackend::*m_prepare_fcnt)();
120
b30fe14b
PD
121 bool list_simple( const DNSName& target, int domain_id );
122 bool list_strict( const DNSName& target, int domain_id );
e0ec6e79 123
b30fe14b
PD
124 void lookup_simple( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid );
125 void lookup_strict( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid );
126 void lookup_tree( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid );
e0ec6e79
BH
127
128 bool prepare();
129 bool prepare_simple();
130 bool prepare_strict();
131
132 bool getDomainInfo( const string& domain, DomainInfo& di );
4bb1fb74
BH
133
134public:
135
e0ec6e79
BH
136 LdapBackend( const string &suffix="" );
137 ~LdapBackend();
4bb1fb74 138
b30fe14b
PD
139 bool list( const DNSName& target, int domain_id, bool include_disabled=false );
140 void lookup( const QType& qtype, const DNSName& qdomain, DNSPacket* p = 0, int zoneid = -1 );
e0ec6e79 141 bool get( DNSResourceRecord& rr );
4bb1fb74
BH
142};
143
144#endif /* LDAPBACKEND_HH */