]> granicus.if.org Git - php/commitdiff
Fixed ldap_exop and ldap_parse_exop. Only tested them for whoami exop. (see test...
authorCôme Chilliet <mcmic@php.net>
Mon, 26 Jun 2017 09:03:26 +0000 (11:03 +0200)
committerCôme Chilliet <mcmic@php.net>
Mon, 3 Jul 2017 08:58:13 +0000 (10:58 +0200)
ext/ldap/ldap.c
ext/ldap/tests/ldap_exop.phpt [new file with mode: 0644]

index 50f0fb24c374230f03ebef2a135a36c1a55d9f02..e541b352e4328e8774626ae5814eeeb5a8c9a046 100644 (file)
@@ -2577,7 +2577,7 @@ PHP_FUNCTION(ldap_parse_exop)
        struct berval *lretdata;
        int rc, myargcount = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|zz", &link, &result, &retoid, &retdata) == SUCCESS) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|z/z/", &link, &result, &retoid, &retdata) != SUCCESS) {
                WRONG_PARAM_COUNT;
        }
 
@@ -3314,7 +3314,7 @@ PHP_FUNCTION(ldap_exop)
        int rc, msgid, myargcount = ZEND_NUM_ARGS();
        /* int reqoid_len, reqdata_len, retdata_len, retoid_len, retdat_len; */
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|zzz", &link, &reqoid, &reqdata, &retoid, &retdata) != SUCCESS) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|zz/z/", &link, &reqoid, &reqdata, &retoid, &retdata) != SUCCESS) {
                WRONG_PARAM_COUNT;
        }
 
@@ -3879,7 +3879,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop, 0, 0, 5)
        ZEND_ARG_INFO(0, link)
        ZEND_ARG_INFO(0, reqoid)
-       ZEND_ARG_INFO(1, reqdata)
+       ZEND_ARG_INFO(0, reqdata)
        ZEND_ARG_INFO(1, repoid)
        ZEND_ARG_INFO(1, repdata)
 ZEND_END_ARG_INFO()
diff --git a/ext/ldap/tests/ldap_exop.phpt b/ext/ldap/tests/ldap_exop.phpt
new file mode 100644 (file)
index 0000000..883bfa5
--- /dev/null
@@ -0,0 +1,52 @@
+--TEST--
+ldap_exop() and ldap_parse_exop() - EXOP operations
+--CREDITS--
+Côme Chilliet <mcmic@php.net>
+--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);
+
+function ber_encode($string) {
+       $null_padded_string = '';
+       for($i = 0; $i<strlen($string); $i++) {
+               $null_padded_string .= substr($string,$i,1)."\0";
+       }
+       return base64_encode($null_padded_string);
+}
+
+// ldap_exop(resource link, string reqoid [, string reqdata [, string retoid [, string retdata]]])
+// bool ldap_parse_exop(resource link, resource result [, string retoid [, string retdata]])
+var_dump(
+       ldap_exop($link, "1.3.6.1.4.1.4203.1.11.3", NULL, $retoid, $retdata),
+       $retdata,
+       $retoid,
+       $r = ldap_exop($link, "1.3.6.1.4.1.4203.1.11.3"),
+       ldap_parse_exop($link, $r, $retoid2, $retdata2),
+       $retdata2,
+       $retoid2
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+require "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+
+remove_dummy_data($link, $base);
+?>
+--EXPECTF--
+bool(true)
+string(%d) "dn:%s"
+string(0) ""
+resource(%d) of type (ldap result)
+bool(true)
+string(%d) "dn:%s"
+string(0) ""
+===DONE===