diff options
| author | Adam <Adam@anope.org> | 2011-04-27 10:56:20 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2011-05-16 04:09:07 -0400 |
| commit | 284af258bf3c4dc7f409722d66bb0ac59e01e37d (patch) | |
| tree | 5649a27a7a247c2609a4ef13b52a357765cbdfcc /modules/extra/ldap.h | |
| parent | e7887c1f013248274574ab8e3167f742ccb3d69b (diff) | |
Added more useful functions to our LDAP API, allow adding newly registered accounts to LDAP, removed some unnecessary OnPre events and fixed unloading all modules
Diffstat (limited to 'modules/extra/ldap.h')
| -rw-r--r-- | modules/extra/ldap.h | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/modules/extra/ldap.h b/modules/extra/ldap.h index acb9d8f53..6fbba7c11 100644 --- a/modules/extra/ldap.h +++ b/modules/extra/ldap.h @@ -1,3 +1,5 @@ +#ifndef ANOPE_LDAP_H +#define ANOPE_LDAP_H typedef int LDAPQuery; @@ -9,6 +11,21 @@ class LDAPException : public ModuleException virtual ~LDAPException() throw() { } }; +struct LDAPModification +{ + enum LDAPOperation + { + LDAP_ADD, + LDAP_DEL, + LDAP_REPLACE + }; + + LDAPOperation op; + Anope::string name; + std::vector<Anope::string> values; +}; +typedef std::vector<LDAPModification> LDAPMods; + struct LDAPAttributes : public std::map<Anope::string, std::vector<Anope::string> > { size_t size(const Anope::string &attr) const @@ -50,7 +67,10 @@ struct LDAPResult enum QueryType { QUERY_BIND, - QUERY_SEARCH + QUERY_SEARCH, + QUERY_ADD, + QUERY_DELETE, + QUERY_MODIFY }; QueryType type; @@ -61,6 +81,11 @@ struct LDAPResult return this->messages.size(); } + bool empty() const + { + return this->messages.empty(); + } + const LDAPAttributes &get(size_t sz) const { if (sz >= this->messages.size()) @@ -86,14 +111,55 @@ class LDAPInterface virtual void OnError(const LDAPResult &err) { } }; - class LDAPProvider : public Service { public: LDAPProvider(Module *c, const Anope::string &n) : Service(c, n) { } + /** Attempt to bind to the LDAP server as an admin + * @param i The LDAPInterface the result is sent to + * @return The query ID + */ + virtual LDAPQuery BindAsAdmin(LDAPInterface *i) = 0; + + /** Bind to LDAP + * @param i The LDAPInterface the result is sent to + * @param who The binddn + * @param pass The password + * @return The query ID + */ virtual LDAPQuery Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) = 0; + /** Search ldap for the specified filter + * @param i The LDAPInterface the result is sent to + * @param base The base DN to search + * @param filter The filter to apply + * @return The query ID + */ virtual LDAPQuery Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) = 0; + + /** Add an entry to LDAP + * @param i The LDAPInterface the result is sent to + * @param dn The dn of the entry to add + * @param attributes The attributes + * @return The query ID + */ + virtual LDAPQuery Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) = 0; + + /** Delete an entry from LDAP + * @param i The LDAPInterface the result is sent to + * @param dn The dn of the entry to delete + * @return The query ID + */ + virtual LDAPQuery Del(LDAPInterface *i, const Anope::string &dn) = 0; + + /** Modify an existing entry in LDAP + * @param i The LDAPInterface the result is sent to + * @param base The base DN to modify + * @param attributes The attributes to modify + * @return The query ID + */ + virtual LDAPQuery Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0; }; +#endif // ANOPE_LDAP_H |
