]> granicus.if.org Git - pdns/commitdiff
Add PowerLDAP::del() and PowerLDAP::add()
authorGrégory Oestreicher <greg@kamago.net>
Sat, 24 Jun 2017 22:00:11 +0000 (00:00 +0200)
committerGrégory Oestreicher <greg@kamago.net>
Tue, 10 Apr 2018 20:41:26 +0000 (22:41 +0200)
modules/ldapbackend/powerldap.cc
modules/ldapbackend/powerldap.hh

index 131e1c82cdddc9a0e8e7c5467f991de8b64db57b..2b3ae4044b11df4c719b5b11e1bdc00a2d522b69 100644 (file)
@@ -278,6 +278,18 @@ void PowerLDAP::simpleBind( const string& ldapbinddn, const string& ldapsecret )
 }
 
 
+void PowerLDAP::add( const string &dn, LDAPMod *mods[] )
+{
+  int rc;
+
+  rc = ldap_add_ext_s( d_ld, dn.c_str(), mods, NULL, NULL );
+  if ( rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR )
+    throw LDAPNoConnection();
+  else if ( rc != LDAP_SUCCESS )
+    throw LDAPException( "Error adding LDAP entry " + dn + ": " + getError( rc ) );
+}
+
+
 void PowerLDAP::modify( const string &dn, LDAPMod *mods[], LDAPControl **scontrols, LDAPControl **ccontrols )
 {
   int rc;
@@ -290,6 +302,18 @@ void PowerLDAP::modify( const string &dn, LDAPMod *mods[], LDAPControl **scontro
 }
 
 
+void PowerLDAP::del( const string& dn )
+{
+  int rc;
+
+  rc = ldap_delete_ext_s( d_ld, dn.c_str(), NULL, NULL );
+  if ( rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR )
+    throw LDAPNoConnection();
+  else if ( rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_OBJECT )
+    throw LDAPException( "Error deleting LDAP entry " + dn + ": " + getError( rc ) );
+}
+
+
 PowerLDAP::SearchResult::Ptr PowerLDAP::search( const string& base, int scope, const string& filter, const char** attr )
 {
   int msgid, rc;
index 81b064e976eda06194005ea9004f1795e9436c0a..8ff3441df30640c4254c02cf638b6351da49eea1 100644 (file)
@@ -90,7 +90,9 @@ class PowerLDAP
     void bind( const string& ldapbinddn = "", const string& ldapsecret = "", int method = LDAP_AUTH_SIMPLE );
     void simpleBind( const string& ldapbinddn = "", const string& ldapsecret = "" );
     SearchResult::Ptr search( const string& base, int scope, const string& filter, const char** attr = 0 );
+    void add( const string &dn, LDAPMod *mods[] );
     void modify( const string& dn, LDAPMod *mods[], LDAPControl **scontrols = 0, LDAPControl **ccontrols = 0 );
+    void del( const string& dn );
   
     bool getSearchEntry( int msgid, sentry_t& entry, bool dn = false );
     void getSearchResults( int msgid, sresult_t& result, bool dn = false );