diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 376f9aff88b73cf0e398d377472683943cf874ca..cb1bd78cb555968d8688d8a4eafb9f52165acdcd 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1285,7 +1285,7 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
 
 		for (i = 0; ldap_entry; i++) { 
 			dn = ldap_get_dn(ldapConn, ldap_entry);
-			if (!(error = ldap_modify_ext_s(ldapConn, dn, ldap_mods, NULL, NULL))) 
+			if ((error = ldap_modify_ext_s(ldapConn, dn, ldap_mods, NULL, NULL)) != LDAP_SUCCESS) 
 				ast_log(LOG_ERROR, "Couldn't modify dn:%s because %s", dn, ldap_err2string(error));
 
 			ldap_entry = ldap_next_entry(ldapConn, ldap_entry);