com php-src: Added controls support to ldap_search, ldap _list and ldap_read.: ext/ldap/ldap.c ext/lda p/tests/ldap_list_error.phpt
ext/ldap/tests/ldap_read _error.phpt ext/ldap/tests/ldap_search_paged_result _controls.phpt
| From: | Côme Bernigaud | Date: | Thu, 21 Sep 2017 08:05:40 +0000 |
| Subject: | com php-src: Added controls support to ldap_search, ldap _list and ldap_read.: ext/ldap/ldap.c ext/lda p/tests/ldap_list_error.phpt ext/ldap/tests/ldap_read _error.phpt ext/ldap/tests/ldap_search_paged_result _controls.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99509@lists.php.net to get a copy of this message | ||
Commit: 8de071e0f76784ef2fd18fb1d270c30b08274be0
Author: Côme Chilliet <mcmic@php.net> Wed, 26 Jul 2017 16:41:44 +0200
Parents: 5ccb31e49ee117808bed4775dc40521f418b783b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8de071e0f76784ef2fd18fb1d270c30b08274be0
Log:
Added controls support to ldap_search, ldap_list and ldap_read.
Changed paths:
M ext/ldap/ldap.c
M ext/ldap/tests/ldap_list_error.phpt
M ext/ldap/tests/ldap_read_error.phpt
A ext/ldap/tests/ldap_search_paged_result_controls.phpt
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index a1843ee..82ac072 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -324,6 +324,21 @@ static LDAPControl** _php_ldap_controls_from_array(LDAP *ld, zval* array) return ctrls; } + +static void _php_ldap_controls_free (LDAPControl*** ctrls) +{ + LDAPControl **ctrlp; + + if (*ctrls) { + ctrlp = *ctrls; + while (*ctrlp) { + ldap_control_free(*ctrlp); + ctrlp++; + } + efree(*ctrls); + *ctrls = NULL; + } +} /* }}} */ /* {{{ PHP_INI_BEGIN @@ -1018,22 +1033,25 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in */ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) { - zval *link, *base_dn, *filter, *attrs = NULL, *attr; + zval *link, *base_dn, *filter, *attrs = NULL, *attr, *serverctrls, *clientctrls; zend_long attrsonly, sizelimit, timelimit, deref; char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL; ldap_linkdata *ld = NULL; LDAPMessage *ldap_res; + LDAPControl **lserverctrls = NULL, **lclientctrls = NULL; int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1; int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1; int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argcount, "zzz|allll", &link, &base_dn, &filter, &attrs, &attrsonly, - &sizelimit, &timelimit, &deref) == FAILURE) { + if (zend_parse_parameters(argcount, "zzz|allllzz", &link, &base_dn, &filter, &attrs, &attrsonly, + &sizelimit, &timelimit, &deref, &serverctrls, &clientctrls) == FAILURE) { return; } /* Reverse -> fall through */ switch (argcount) { + case 10: + case 9: case 8: ldap_deref = deref; case 7: @@ -1136,10 +1154,28 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ldap_filter = Z_STRVAL_P(entry); } + if (argcount > 8) { + // We have to parse controls again for each link as they use it + _php_ldap_controls_free(&lserverctrls); + lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls); + if (lserverctrls == NULL) { + rcs[i] = -1; + continue; + } + if (argcount > 9) { + _php_ldap_controls_free(&lclientctrls); + lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls); + if (lclientctrls == NULL) { + rcs[i] = -1; + continue; + } + } + } + php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref); /* Run the actual search */ - ldap_search_ext(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, NULL, NULL, NULL, ldap_sizelimit, &rcs[i]); + ldap_search_ext(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, lserverctrls, lclientctrls, NULL, ldap_sizelimit, &rcs[i]); lds[i] = ld; zend_hash_move_forward(Z_ARRVAL_P(link)); } @@ -1177,10 +1213,25 @@ cleanup_parallel: goto cleanup; } + if (argcount > 8) { + lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls); + if (lserverctrls == NULL) { + ret = 0; + goto cleanup; + } + if (argcount > 9) { + lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls); + if (lclientctrls == NULL) { + ret = 0; + goto cleanup; + } + } + } + php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref); /* Run the actual search */ - errno = ldap_search_ext_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, NULL, NULL, NULL, ldap_sizelimit, &ldap_res); + errno = ldap_search_ext_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, lserverctrls, lclientctrls, NULL, ldap_sizelimit, &ldap_res); if (errno != LDAP_SUCCESS && errno != LDAP_SIZELIMIT_EXCEEDED @@ -1218,10 +1269,16 @@ cleanup: if (!ret) { RETVAL_BOOL(ret); } + if (lserverctrls) { + _php_ldap_controls_free(&lserverctrls); + } + if (lclientctrls) { + _php_ldap_controls_free(&lclientctrls); + } } /* }}} */ -/* {{{ proto resource ldap_read(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_read(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Read an entry */ PHP_FUNCTION(ldap_read) { @@ -1229,7 +1286,7 @@ PHP_FUNCTION(ldap_read) } /* }}} */ -/* {{{ proto resource ldap_list(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_list(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Single-level search */ PHP_FUNCTION(ldap_list) { @@ -1237,7 +1294,7 @@ PHP_FUNCTION(ldap_list) } /* }}} */ -/* {{{ proto resource ldap_search(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_search(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Search LDAP tree under base_dn */ PHP_FUNCTION(ldap_search) { @@ -2711,7 +2768,7 @@ PHP_FUNCTION(ldap_set_option) case LDAP_OPT_SERVER_CONTROLS: case LDAP_OPT_CLIENT_CONTROLS: { - LDAPControl **ctrls, **ctrlp; + LDAPControl **ctrls; int rc; if (Z_TYPE_P(newval) != IS_ARRAY) { @@ -2725,12 +2782,7 @@ PHP_FUNCTION(ldap_set_option) RETURN_FALSE; } else { rc = ldap_set_option(ldap, option, ctrls); - ctrlp = ctrls; - while (*ctrlp) { - ldap_control_free(*ctrlp); - ctrlp++; - } - efree(ctrls); + _php_ldap_controls_free(&ctrls); if (rc != LDAP_SUCCESS) { RETURN_FALSE; } @@ -3778,6 +3830,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_read, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_list, 0, 0, 3) @@ -3789,6 +3843,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_list, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_search, 0, 0, 3) @@ -3800,6 +3856,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_search, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_count_entries, 0, 0, 2) diff --git a/ext/ldap/tests/ldap_list_error.phpt b/ext/ldap/tests/ldap_list_error.phpt index 51bcaa5..801d246 100644 --- a/ext/ldap/tests/ldap_list_error.phpt +++ b/ext/ldap/tests/ldap_list_error.phpt @@ -17,7 +17,7 @@ var_dump(ldap_list($link)); var_dump(ldap_list($link, $link)); // Too many parameters -var_dump(ldap_list($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0 , "Additional data")); +var_dump(ldap_list($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0, [], [], "Additional data")); ?> ===DONE=== --EXPECTF-- @@ -30,6 +30,6 @@ NULL Warning: ldap_list() expects at least 3 parameters, 2 given in %s on line %d NULL -Warning: ldap_list() expects at most 8 parameters, 9 given in %s on line %d +Warning: ldap_list() expects at most 10 parameters, 11 given in %s on line %d NULL ===DONE=== diff --git a/ext/ldap/tests/ldap_read_error.phpt b/ext/ldap/tests/ldap_read_error.phpt index 7d57172..c1e15a6 100644 --- a/ext/ldap/tests/ldap_read_error.phpt +++ b/ext/ldap/tests/ldap_read_error.phpt @@ -17,7 +17,7 @@ var_dump(ldap_read($link)); var_dump(ldap_read($link, $link)); // Too many parameters -var_dump(ldap_read($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0 , "Additional data")); +var_dump(ldap_read($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0, [], [], "Additional data")); ?> ===DONE=== --EXPECTF-- @@ -30,6 +30,6 @@ NULL Warning: ldap_read() expects at least 3 parameters, 2 given in %s on line %d NULL -Warning: ldap_read() expects at most 8 parameters, 9 given in %s on line %d +Warning: ldap_read() expects at most 10 parameters, 11 given in %s on line %d NULL ===DONE=== diff --git a/ext/ldap/tests/ldap_search_paged_result_controls.phpt b/ext/ldap/tests/ldap_search_paged_result_controls.phpt new file mode 100644 index 0000000..e75f408 --- /dev/null +++ b/ext/ldap/tests/ldap_search_paged_result_controls.phpt @@ -0,0 +1,97 @@ +--TEST-- +ldap_search() test with paged result controls +--CREDITS-- +Côme Chilliet <mcmic@php.net> +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifbindfailure.inc'); +?> +--FILE-- +<?php +include "connect.inc"; + +$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); +insert_dummy_data($link, $base); + +$dn = "$base"; +$filter = "(cn=user*)"; +var_dump( + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 2]]]), + ldap_get_entries($link, $result), + ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 20, 'cookie' => $controls[0]['value']['cookie']]]]), + ldap_get_entries($link, $result) +); +?> +===DONE=== +--CLEAN-- +<?php +include "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) +array(3) { + ["count"]=> + int(2) + [0]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userA" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userA,%s" + } + [1]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userB" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userB,%s" + } +} +bool(true) +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userC" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userC,cn=userB,%s" + } +} +===DONE===
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index a1843ee..82ac072 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -324,6 +324,21 @@ static LDAPControl** _php_ldap_controls_from_array(LDAP *ld, zval* array) return ctrls; } + +static void _php_ldap_controls_free (LDAPControl*** ctrls) +{ + LDAPControl **ctrlp; + + if (*ctrls) { + ctrlp = *ctrls; + while (*ctrlp) { + ldap_control_free(*ctrlp); + ctrlp++; + } + efree(*ctrls); + *ctrls = NULL; + } +} /* }}} */ /* {{{ PHP_INI_BEGIN @@ -1018,22 +1033,25 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in */ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) { - zval *link, *base_dn, *filter, *attrs = NULL, *attr; + zval *link, *base_dn, *filter, *attrs = NULL, *attr, *serverctrls, *clientctrls; zend_long attrsonly, sizelimit, timelimit, deref; char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL; ldap_linkdata *ld = NULL; LDAPMessage *ldap_res; + LDAPControl **lserverctrls = NULL, **lclientctrls = NULL; int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1; int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1; int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argcount, "zzz|allll", &link, &base_dn, &filter, &attrs, &attrsonly, - &sizelimit, &timelimit, &deref) == FAILURE) { + if (zend_parse_parameters(argcount, "zzz|allllzz", &link, &base_dn, &filter, &attrs, &attrsonly, + &sizelimit, &timelimit, &deref, &serverctrls, &clientctrls) == FAILURE) { return; } /* Reverse -> fall through */ switch (argcount) { + case 10: + case 9: case 8: ldap_deref = deref; case 7: @@ -1136,10 +1154,28 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ldap_filter = Z_STRVAL_P(entry); } + if (argcount > 8) { + // We have to parse controls again for each link as they use it + _php_ldap_controls_free(&lserverctrls); + lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls); + if (lserverctrls == NULL) { + rcs[i] = -1; + continue; + } + if (argcount > 9) { + _php_ldap_controls_free(&lclientctrls); + lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls); + if (lclientctrls == NULL) { + rcs[i] = -1; + continue; + } + } + } + php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref); /* Run the actual search */ - ldap_search_ext(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, NULL, NULL, NULL, ldap_sizelimit, &rcs[i]); + ldap_search_ext(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, lserverctrls, lclientctrls, NULL, ldap_sizelimit, &rcs[i]); lds[i] = ld; zend_hash_move_forward(Z_ARRVAL_P(link)); } @@ -1177,10 +1213,25 @@ cleanup_parallel: goto cleanup; } + if (argcount > 8) { + lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls); + if (lserverctrls == NULL) { + ret = 0; + goto cleanup; + } + if (argcount > 9) { + lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls); + if (lclientctrls == NULL) { + ret = 0; + goto cleanup; + } + } + } + php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref); /* Run the actual search */ - errno = ldap_search_ext_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, NULL, NULL, NULL, ldap_sizelimit, &ldap_res); + errno = ldap_search_ext_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, lserverctrls, lclientctrls, NULL, ldap_sizelimit, &ldap_res); if (errno != LDAP_SUCCESS && errno != LDAP_SIZELIMIT_EXCEEDED @@ -1218,10 +1269,16 @@ cleanup: if (!ret) { RETVAL_BOOL(ret); } + if (lserverctrls) { + _php_ldap_controls_free(&lserverctrls); + } + if (lclientctrls) { + _php_ldap_controls_free(&lclientctrls); + } } /* }}} */ -/* {{{ proto resource ldap_read(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_read(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Read an entry */ PHP_FUNCTION(ldap_read) { @@ -1229,7 +1286,7 @@ PHP_FUNCTION(ldap_read) } /* }}} */ -/* {{{ proto resource ldap_list(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_list(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Single-level search */ PHP_FUNCTION(ldap_list) { @@ -1237,7 +1294,7 @@ PHP_FUNCTION(ldap_list) } /* }}} */ -/* {{{ proto resource ldap_search(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]]) +/* {{{ proto resource ldap_search(resource|array link, string base_dn, string filter [, array attrs [, int attrsonly [, int sizelimit [, int timelimit [, int deref [, array servercontrols [, array clientcontrols]]]]]]]) Search LDAP tree under base_dn */ PHP_FUNCTION(ldap_search) { @@ -2711,7 +2768,7 @@ PHP_FUNCTION(ldap_set_option) case LDAP_OPT_SERVER_CONTROLS: case LDAP_OPT_CLIENT_CONTROLS: { - LDAPControl **ctrls, **ctrlp; + LDAPControl **ctrls; int rc; if (Z_TYPE_P(newval) != IS_ARRAY) { @@ -2725,12 +2782,7 @@ PHP_FUNCTION(ldap_set_option) RETURN_FALSE; } else { rc = ldap_set_option(ldap, option, ctrls); - ctrlp = ctrls; - while (*ctrlp) { - ldap_control_free(*ctrlp); - ctrlp++; - } - efree(ctrls); + _php_ldap_controls_free(&ctrls); if (rc != LDAP_SUCCESS) { RETURN_FALSE; } @@ -3778,6 +3830,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_read, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_list, 0, 0, 3) @@ -3789,6 +3843,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_list, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_search, 0, 0, 3) @@ -3800,6 +3856,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_search, 0, 0, 3) ZEND_ARG_INFO(0, sizelimit) ZEND_ARG_INFO(0, timelimit) ZEND_ARG_INFO(0, deref) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_count_entries, 0, 0, 2) diff --git a/ext/ldap/tests/ldap_list_error.phpt b/ext/ldap/tests/ldap_list_error.phpt index 51bcaa5..801d246 100644 --- a/ext/ldap/tests/ldap_list_error.phpt +++ b/ext/ldap/tests/ldap_list_error.phpt @@ -17,7 +17,7 @@ var_dump(ldap_list($link)); var_dump(ldap_list($link, $link)); // Too many parameters -var_dump(ldap_list($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0 , "Additional data")); +var_dump(ldap_list($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0, [], [], "Additional data")); ?> ===DONE=== --EXPECTF-- @@ -30,6 +30,6 @@ NULL Warning: ldap_list() expects at least 3 parameters, 2 given in %s on line %d NULL -Warning: ldap_list() expects at most 8 parameters, 9 given in %s on line %d +Warning: ldap_list() expects at most 10 parameters, 11 given in %s on line %d NULL ===DONE=== diff --git a/ext/ldap/tests/ldap_read_error.phpt b/ext/ldap/tests/ldap_read_error.phpt index 7d57172..c1e15a6 100644 --- a/ext/ldap/tests/ldap_read_error.phpt +++ b/ext/ldap/tests/ldap_read_error.phpt @@ -17,7 +17,7 @@ var_dump(ldap_read($link)); var_dump(ldap_read($link, $link)); // Too many parameters -var_dump(ldap_read($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0 , "Additional data")); +var_dump(ldap_read($link, "$base", "(objectClass=*)", array(), 0, 0, 0, 0, [], [], "Additional data")); ?> ===DONE=== --EXPECTF-- @@ -30,6 +30,6 @@ NULL Warning: ldap_read() expects at least 3 parameters, 2 given in %s on line %d NULL -Warning: ldap_read() expects at most 8 parameters, 9 given in %s on line %d +Warning: ldap_read() expects at most 10 parameters, 11 given in %s on line %d NULL ===DONE=== diff --git a/ext/ldap/tests/ldap_search_paged_result_controls.phpt b/ext/ldap/tests/ldap_search_paged_result_controls.phpt new file mode 100644 index 0000000..e75f408 --- /dev/null +++ b/ext/ldap/tests/ldap_search_paged_result_controls.phpt @@ -0,0 +1,97 @@ +--TEST-- +ldap_search() test with paged result controls +--CREDITS-- +Côme Chilliet <mcmic@php.net> +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifbindfailure.inc'); +?> +--FILE-- +<?php +include "connect.inc"; + +$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); +insert_dummy_data($link, $base); + +$dn = "$base"; +$filter = "(cn=user*)"; +var_dump( + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 2]]]), + ldap_get_entries($link, $result), + ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 20, 'cookie' => $controls[0]['value']['cookie']]]]), + ldap_get_entries($link, $result) +); +?> +===DONE=== +--CLEAN-- +<?php +include "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) +array(3) { + ["count"]=> + int(2) + [0]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userA" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userA,%s" + } + [1]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userB" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userB,%s" + } +} +bool(true) +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userC" + } + [0]=> + string(2) "cn" + ["count"]=> + int(1) + ["dn"]=> + string(%d) "cn=userC,cn=userB,%s" + } +} +===DONE===