com php-src: Added controls support to ldap_delete: ext/l dap/ldap.c ext/ldap/tests/ldap_controls.phpt
| From: | Côme Bernigaud | Date: | Thu, 21 Sep 2017 08:05:40 +0000 |
| Subject: | com php-src: Added controls support to ldap_delete: ext/l dap/ldap.c ext/ldap/tests/ldap_controls.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99499@lists.php.net to get a copy of this message | ||
Commit: 93fbbbf5a6162411a03794b9621236bc04920dc2
Author: Côme Chilliet <mcmic@php.net> Thu, 7 Sep 2017 11:21:47 +0200
Parents: 5ee0fc9b56eb0c210020d1f0a56af16fb2e1f546
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=93fbbbf5a6162411a03794b9621236bc04920dc2
Log:
Added controls support to ldap_delete
Changed paths:
M ext/ldap/ldap.c
M ext/ldap/tests/ldap_controls.phpt
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 892dfa2..2bff9fe 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap..c
@@ -1986,17 +1986,19 @@ PHP_FUNCTION(ldap_mod_del)
}
/* }}} */
-/* {{{ proto bool ldap_delete(resource link, string dn)
+/* {{{ proto bool ldap_delete(resource link, string dn [, array servercontrols [, array
clientcontrols]])
Delete an entry from a directory */
PHP_FUNCTION(ldap_delete)
{
+ zval *serverctrls = NULL, *clientctrls = NULL;
zval *link;
ldap_linkdata *ld;
+ LDAPControl **lserverctrls = NULL, **lclientctrls = NULL;
char *dn;
int rc;
size_t dn_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &link, &dn, &dn_len) !=
SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|aa", &link, &dn, &dn_len,
&serverctrls, &clientctrls) != SUCCESS) {
return;
}
@@ -2004,12 +2006,37 @@ PHP_FUNCTION(ldap_delete)
RETURN_FALSE;
}
- if ((rc = ldap_delete_ext_s(ld->link, dn, NULL, NULL)) != LDAP_SUCCESS) {
+ if (serverctrls) {
+ lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls);
+ if (lserverctrls == NULL) {
+ RETVAL_FALSE;
+ goto cleanup;
+ }
+ }
+ if (clientctrls) {
+ lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls);
+ if (lclientctrls == NULL) {
+ RETVAL_FALSE;
+ goto cleanup;
+ }
+ }
+
+ if ((rc = ldap_delete_ext_s(ld->link, dn, lserverctrls, lclientctrls)) != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Delete: %s", ldap_err2string(rc));
- RETURN_FALSE;
+ RETVAL_FALSE;
+ } else {
+ RETVAL_TRUE;
}
- RETURN_TRUE;
+cleanup:
+ if (lserverctrls) {
+ _php_ldap_controls_free(&lserverctrls);
+ }
+ if (lclientctrls) {
+ _php_ldap_controls_free(&lclientctrls);
+ }
+
+ return;
}
/* }}} */
@@ -3997,6 +4024,8 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_delete, 0, 0, 2)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, dn)
+ ZEND_ARG_INFO(0, servercontrols)
+ ZEND_ARG_INFO(0, clientcontrols)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_modify, 0, 0, 3)
diff --git a/ext/ldap/tests/ldap_controls.phpt b/ext/ldap/tests/ldap_controls.phpt
index bb0226b..85a0b8c 100644
--- a/ext/ldap/tests/ldap_controls.phpt
+++ b/ext/ldap/tests/ldap_controls.phpt
@@ -28,7 +28,10 @@ var_dump(
ldap_modify($link, "o=test,$base", ['description' => 'desc2'],
[['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value'
=> ['filter' => '(!(description=*))']]]),
$result = ldap_read($link, "o=test,$base", "objectClass=*",
array('description')),
- ldap_get_entries($link, $result)
+ ldap_get_entries($link, $result),
+ ldap_delete($link, "o=test,$base", [['oid' => LDAP_CONTROL_ASSERT,
'iscritical' => TRUE, 'value' => ['filter' =>
'(description=desc2)']]]),
+ ldap_errno($link),
+ ldap_error($link)
);
?>
===DONE===
@@ -43,6 +46,8 @@ remove_dummy_data($link, $base);
Warning: ldap_search(): Search: Assertion Failed in %s on line %d
Warning: ldap_modify(): Modify: Assertion Failed in %s on line %d
+
+Warning: ldap_delete(): Delete: Assertion Failed in %s on line %d
resource(%d) of type (ldap result)
array(2) {
["count"]=>
@@ -109,4 +114,7 @@ array(2) {
string(%d) "o=test,%s"
}
}
+bool(false)
+int(122)
+string(16) "Assertion Failed"
===DONE===