[Asterisk-code-review] Fixed ldap modify error issue ASTERISK-26580 (asterisk[11.24])

Nicholas John Koch asteriskteam at digium.com
Sat Nov 12 02:03:41 CST 2016


Nicholas John Koch has uploaded a new change for review. ( https://gerrit.asterisk.org/4403 )

Change subject: Fixed ldap modify error issue ASTERISK-26580
......................................................................

Fixed ldap modify error issue ASTERISK-26580

Change-Id: I18d6101641cd5eb54efa2e113189089e6600d2fc
---
M res/res_config_ldap.c
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/4403/1

diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 0e50de3..b5dd91d 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1239,11 +1239,18 @@
 	ldap_mods = ldap_memcalloc(sizeof(LDAPMod *), mods_size);
 	ldap_mods[0] = ldap_memcalloc(1, sizeof(LDAPMod));
 
-	ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
-	ldap_mods[0]->mod_type = ldap_strdup(newparam);
+	/* If newval is empty we need to delete instead of modify the attribute. */
+	if (strlen(newval) == 0) {
+		ldap_mods[0]->mod_op = LDAP_MOD_DELETE;
+	} else {
 
-	ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
-	ldap_mods[0]->mod_values[0] = ldap_strdup(newval);
+		ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
+
+		ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
+		ldap_mods[0]->mod_values[0] = ldap_strdup(newval);
+	}	
+	
+	ldap_mods[0]->mod_type = ldap_strdup(newparam);
 
 	while ((newparam = va_arg(ap, const char *))) {
 		newparam = convert_attribute_name_to_ldap(table_config, newparam);

-- 
To view, visit https://gerrit.asterisk.org/4403
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18d6101641cd5eb54efa2e113189089e6600d2fc
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11.24
Gerrit-Owner: Nicholas John Koch <koch at njk-it.de>



More information about the asterisk-code-review mailing list