2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 * originally authored by Norbert Sendetzky
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.
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.
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.
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.
41 class LdapAuthenticator;
51 const string getError(int rc = -1);
52 int waitResult(int msgid = LDAP_RES_ANY, LDAPMessage** result = NULL);
56 typedef map<string, vector<string>> sentry_t;
57 typedef vector<sentry_t> sresult_t;
65 SearchResult(const SearchResult& other);
66 SearchResult& operator=(const SearchResult& other);
69 typedef std::unique_ptr<SearchResult> Ptr;
71 SearchResult(int msgid, LDAP* ld);
74 bool getNext(PowerLDAP::sentry_t& entry, bool dn = false, int timeout = 5);
75 void getAll(PowerLDAP::sresult_t& results, bool dn = false, int timeout = 5);
78 PowerLDAP(const string& hosts, uint16_t port, bool tls, int timeout);
83 void getOption(int option, int* value);
84 void setOption(int option, int value);
86 void bind(LdapAuthenticator* authenticator);
87 void bind(const string& ldapbinddn = "", const string& ldapsecret = "", int method = LDAP_AUTH_SIMPLE);
88 void simpleBind(const string& ldapbinddn = "", const string& ldapsecret = "");
89 SearchResult::Ptr search(const string& base, int scope, const string& filter, const char** attr = 0);
90 void add(const string& dn, LDAPMod* mods[]);
91 void modify(const string& dn, LDAPMod* mods[], LDAPControl** scontrols = 0, LDAPControl** ccontrols = 0);
92 void del(const string& dn);
94 bool getSearchEntry(int msgid, sentry_t& entry, bool dn = false);
95 void getSearchResults(int msgid, sresult_t& result, bool dn = false);
97 static const string escape(const string& tobe);