com php-src: Added ldap_mod_*_ext methods for modif ication with controls: ext/ldap/ldap.c ext/ldap/tes ts/ldap_mod_ext.phpt
| From: | Côme Bernigaud | Date: | Thu, 21 Sep 2017 08:05:42 +0000 |
| Subject: | com php-src: Added ldap_mod_*_ext methods for modif ication with controls: ext/ldap/ldap.c ext/ldap/tes ts/ldap_mod_ext.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99492@lists.php.net to get a copy of this message | ||
Commit: 17e490a2e3389da09c4a656f571292f14ddefb18
Author: Côme Chilliet <mcmic@php.net> Tue, 12 Sep 2017 11:13:23 +0200
Parents: 32b51035bedda2786d80f170b3aad1b2bf0f329f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=17e490a2e3389da09c4a656f571292f14ddefb18
Log:
Added ldap_mod_*_ext methods for modification with controls
Changed paths:
M ext/ldap/ldap.c
A ext/ldap/tests/ldap_mod_ext.phpt
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 00b6050..666251f 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2183,6 +2183,14 @@ PHP_FUNCTION(ldap_mod_replace)
}
/* }}} */
+/* {{{ proto resource ldap_mod_replace_ext(resource link, string dn, array entry [, array
servercontrols])
+ Replace attribute values with new ones */
+PHP_FUNCTION(ldap_mod_replace_ext)
+{
+ php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, 1);
+}
+/* }}} */
+
/* {{{ proto bool ldap_mod_add(resource link, string dn, array entry [, array servercontrols])
Add attribute values to current */
PHP_FUNCTION(ldap_mod_add)
@@ -2191,6 +2199,14 @@ PHP_FUNCTION(ldap_mod_add)
}
/* }}} */
+/* {{{ proto resource ldap_mod_add(resource link, string dn, array entry [, array servercontrols])
+ Add attribute values to current */
+PHP_FUNCTION(ldap_mod_add_ext)
+{
+ php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD, 1);
+}
+/* }}} */
+
/* {{{ proto bool ldap_mod_del(resource link, string dn, array entry [, array servercontrols])
Delete attribute values */
PHP_FUNCTION(ldap_mod_del)
@@ -2199,6 +2215,14 @@ PHP_FUNCTION(ldap_mod_del)
}
/* }}} */
+/* {{{ proto resource ldap_mod_del_ext(resource link, string dn, array entry [, array
servercontrols])
+ Delete attribute values */
+PHP_FUNCTION(ldap_mod_del_ext)
+{
+ php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE, 1);
+}
+/* }}} */
+
/* {{{ proto bool ldap_delete(resource link, string dn [, array servercontrols])
Delete an entry from a directory */
PHP_FUNCTION(ldap_delete)
@@ -4314,6 +4338,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_add, 0, 0, 3)
ZEND_ARG_INFO(0, servercontrols)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_add_ext, 0, 0, 3)
+ ZEND_ARG_INFO(0, link_identifier)
+ ZEND_ARG_INFO(0, dn)
+ ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_INFO(0, servercontrols)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_replace, 0, 0, 3)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, dn)
@@ -4321,6 +4352,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_replace, 0, 0, 3)
ZEND_ARG_INFO(0, servercontrols)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_replace_ext, 0, 0, 3)
+ ZEND_ARG_INFO(0, link_identifier)
+ ZEND_ARG_INFO(0, dn)
+ ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_INFO(0, servercontrols)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_del, 0, 0, 3)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, dn)
@@ -4328,6 +4366,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_del, 0, 0, 3)
ZEND_ARG_INFO(0, servercontrols)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_del_ext, 0, 0, 3)
+ ZEND_ARG_INFO(0, link_identifier)
+ ZEND_ARG_INFO(0, dn)
+ ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_INFO(0, servercontrols)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_err2str, 0, 0, 1)
ZEND_ARG_INFO(0, errno)
ZEND_END_ARG_INFO()
@@ -4523,8 +4568,11 @@ const zend_function_entry ldap_functions[] = {
/* additional functions for attribute based modifications, Gerrit Thomson */
PHP_FE(ldap_mod_add, arginfo_ldap_mod_add)
+ PHP_FE(ldap_mod_add_ext, arginfo_ldap_mod_add_ext)
PHP_FE(ldap_mod_replace, arginfo_ldap_mod_replace)
+ PHP_FE(ldap_mod_replace_ext, arginfo_ldap_mod_replace_ext)
PHP_FE(ldap_mod_del, arginfo_ldap_mod_del)
+ PHP_FE(ldap_mod_del_ext, arginfo_ldap_mod_del_ext)
/* end gjt mod */
PHP_FE(ldap_errno, arginfo_ldap_resource)
diff --git a/ext/ldap/tests/ldap_mod_ext.phpt b/ext/ldap/tests/ldap_mod_ext.phpt
new file mode 100644
index 0000000..3f161f3
--- /dev/null
+++ b/ext/ldap/tests/ldap_mod_ext.phpt
@@ -0,0 +1,175 @@
+--TEST--
+ldap_mod_ext() - Modify operations with controls
+--CREDITS--
+Patrick Allaert <patrickallaert@php..net>
+# Belgian PHP Testfest 2009
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+<?php require_once('skipifbindfailure.inc'); ?>
+--FILE--
+<?php
+require "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link, $base);
+
+$entry = array(
+ "description" => "Domain description",
+);
+
+var_dump(
+ $result = ldap_mod_add_ext($link, "o=test,$base", $entry,
+ [
+ ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE,
'value' => ['attrs' => ['description']]],
+ ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE,
'value' => ['attrs' => ['description']]],
+ ]
+ ),
+ ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
+ $errcode,
+ $errmsg,
+ $ctrls,
+ ldap_get_entries(
+ $link,
+ ldap_search($link, "o=test,$base", "(Description=Domain description)")
+ ),
+ $result = ldap_mod_del_ext($link, "o=test,$base", $entry,
+ [
+ ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE,
'value' => ['attrs' => ['description']]],
+ ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE,
'value' => ['attrs' => ['description']]],
+ ]
+ ),
+ ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
+ $errcode,
+ $errmsg,
+ $ctrls,
+ ldap_get_entries(
+ $link,
+ ldap_search($link, "o=test,$base", "(Description=Domain description)")
+ )
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+require "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+
+remove_dummy_data($link, $base);
+?>
+--EXPECTF--
+resource(%d) of type (ldap result)
+bool(true)
+int(0)
+string(0) ""
+array(2) {
+ [0]=>
+ array(3) {
+ ["oid"]=>
+ string(14) "1.3.6.1..1.13.1"
+ ["iscritical"]=>
+ bool(false)
+ ["value"]=>
+ array(1) {
+ ["dn"]=>
+ string(%d) "o=test,%s"
+ }
+ }
+ [1]=>
+ array(3) {
+ ["oid"]=>
+ string(14) "1.3.6.1.1.13.2"
+ ["iscritical"]=>
+ bool(false)
+ ["value"]=>
+ array(2) {
+ ["dn"]=>
+ string(%d) "o=test,%s"
+ ["description"]=>
+ array(1) {
+ [0]=>
+ string(18) "Domain description"
+ }
+ }
+ }
+}
+array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ array(8) {
+ ["objectclass"]=>
+ array(3) {
+ ["count"]=>
+ int(2)
+ [0]=>
+ string(3) "top"
+ [1]=>
+ string(12) "organization"
+ }
+ [0]=>
+ string(11) "objectclass"
+ ["o"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(4) "test"
+ }
+ [1]=>
+ string(1) "o"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(18) "Domain description"
+ }
+ [2]=>
+ string(11) "description"
+ ["count"]=>
+ int(3)
+ ["dn"]=>
+ string(%d) "o=test,%s"
+ }
+}
+resource(%d) of type (ldap result)
+bool(true)
+int(0)
+string(0) ""
+array(2) {
+ [0]=>
+ array(3) {
+ ["oid"]=>
+ string(14) "1.3.6.1.1.13.1"
+ ["iscritical"]=>
+ bool(false)
+ ["value"]=>
+ array(2) {
+ ["dn"]=>
+ string(%d) "o=test,%s"
+ ["description"]=>
+ array(1) {
+ [0]=>
+ string(18) "Domain description"
+ }
+ }
+ }
+ [1]=>
+ array(3) {
+ ["oid"]=>
+ string(14) "1.3.6.1.1.13.2"
+ ["iscritical"]=>
+ bool(false)
+ ["value"]=>
+ array(1) {
+ ["dn"]=>
+ string(%d) "o=test,%s"
+ }
+ }
+}
+array(1) {
+ ["count"]=>
+ int(0)
+}
+===DONE===