From: Grégory Oestreicher Date: Wed, 14 Sep 2016 21:17:50 +0000 (+0200) Subject: Add a modify() method to PowerLDAP X-Git-Tag: rec-4.1.0-alpha1~170^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e21881f988729a6f96463ac9accd0206cf22650e;p=thirdparty%2Fpdns.git Add a modify() method to PowerLDAP --- diff --git a/modules/ldapbackend/powerldap.cc b/modules/ldapbackend/powerldap.cc index 8fb82eeac7..e7f6cc3cb7 100644 --- a/modules/ldapbackend/powerldap.cc +++ b/modules/ldapbackend/powerldap.cc @@ -167,6 +167,18 @@ void PowerLDAP::simpleBind( const string& ldapbinddn, const string& ldapsecret ) } +void PowerLDAP::modify( const string &dn, LDAPMod *mods[], LDAPControl **scontrols, LDAPControl **ccontrols ) +{ + int rc; + + rc = ldap_modify_ext_s( d_ld, dn.c_str(), mods, scontrols, ccontrols ); + if ( rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR ) + throw LDAPNoConnection(); + else if ( rc != LDAP_SUCCESS ) + throw LDAPException( "Error modifying LDAP entry " + dn + ": " + getError( rc ) ); +} + + int PowerLDAP::search( const string& base, int scope, const string& filter, const char** attr ) { int msgid, rc; diff --git a/modules/ldapbackend/powerldap.hh b/modules/ldapbackend/powerldap.hh index ed5351f33c..27e2f032c0 100644 --- a/modules/ldapbackend/powerldap.hh +++ b/modules/ldapbackend/powerldap.hh @@ -68,6 +68,7 @@ class PowerLDAP void bind( const string& ldapbinddn = "", const string& ldapsecret = "", int method = LDAP_AUTH_SIMPLE, int timeout = 5 ); void simpleBind( const string& ldapbinddn = "", const string& ldapsecret = "" ); int search( const string& base, int scope, const string& filter, const char** attr = 0 ); + void modify( const string& dn, LDAPMod *mods[], LDAPControl **scontrols = 0, LDAPControl **ccontrols = 0 ); bool getSearchEntry( int msgid, sentry_t& entry, bool dn = false, int timeout = 5 ); void getSearchResults( int msgid, sresult_t& result, bool dn = false, int timeout = 5 );