From: Côme Chilliet Date: Thu, 20 Jul 2017 14:14:47 +0000 (+0200) Subject: Added ldap_exop_refresh helper for EXOP REFRESH operation on dds overlay X-Git-Tag: php-7.3.0alpha1~1869 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e56d050e582d845e977377a1f8ba8deb15ab082;p=php Added ldap_exop_refresh helper for EXOP REFRESH operation on dds overlay ldap_exop_refresh(resource link, string dn, int ttl) Returns FALSE on failure, newttl on success --- diff --git a/NEWS b/NEWS index 06ebc476d7..fd284f3317 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ PHP NEWS . Fixed bug #74941 (session fails to start after having headers sent). (morozov) +- LDAP: + . Added ldap_exop_refresh helper for EXOP REFRESH operation with dds overlay + - ODBC: . Removed support for Birdstep. (Kalle) diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4 index 7ea238f5a5..f77ff5a4c5 100644 --- a/ext/ldap/config.m4 +++ b/ext/ldap/config.m4 @@ -204,7 +204,7 @@ if test "$PHP_LDAP" != "no"; then dnl Solaris 2.8 claims to be 2004 API, but doesn't have dnl ldap_parse_reference() nor ldap_start_tls_s() - AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s ldap_control_find ldap_parse_extended_result ldap_extended_operation ldap_extended_operation_s ldap_passwd_s ldap_whoami_s]) + AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s ldap_control_find ldap_parse_extended_result ldap_extended_operation ldap_extended_operation_s ldap_passwd_s ldap_whoami_s ldap_refresh_s]) dnl dnl SASL check diff --git a/ext/ldap/config.w32 b/ext/ldap/config.w32 index 7713bdc42b..626375502e 100644 --- a/ext/ldap/config.w32 +++ b/ext/ldap/config.w32 @@ -25,6 +25,7 @@ if (PHP_LDAP != "no") { AC_DEFINE('HAVE_LDAP_EXTENDED_OPERATION_S', 1); AC_DEFINE('HAVE_LDAP_PASSWD_S', 1); AC_DEFINE('HAVE_LDAP_WHOAMI_S', 1); + AC_DEFINE('HAVE_LDAP_REFRESH_S', 1); AC_DEFINE('HAVE_LDAP_EXTENDED_OPERATION', 1); } else { diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index a710025af0..3232414de7 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -3513,7 +3513,44 @@ PHP_FUNCTION(ldap_exop_whoami) } /* }}} */ #endif + +#ifdef HAVE_LDAP_REFRESH_S +/* {{{ proto bool|int ldap_exop_refresh(resource link , string dn , int ttl) + DDS refresh extended operation */ +PHP_FUNCTION(ldap_exop_refresh) +{ + zval *link, *dn, *ttl; + struct berval ldn; + ber_int_t lttl; + ber_int_t newttl; + ldap_linkdata *ld; + int rc; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rzz", &link, &dn, &ttl) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) { + RETURN_FALSE; + } + + convert_to_string_ex(dn); + ldn.bv_val = Z_STRVAL_P(dn); + ldn.bv_len = Z_STRLEN_P(dn); + + convert_to_long_ex(ttl); + lttl = (ber_int_t)Z_LVAL_P(ttl); + + rc = ldap_refresh_s(ld->link, &ldn, lttl, &newttl, NULL, NULL); + if (rc != LDAP_SUCCESS ) { + php_error_docref(NULL, E_WARNING, "Refresh extended operation failed: %s (%d)", ldap_err2string(rc), rc); + RETURN_FALSE; + } + + RETURN_LONG(newttl); +} /* }}} */ +#endif /* }}} */ @@ -3818,6 +3855,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop_whoami, 0, 0, 1) ZEND_END_ARG_INFO() #endif +#ifdef HAVE_LDAP_REFRESH_S +ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop_refresh, 0, 0, 3) + ZEND_ARG_INFO(0, link) + ZEND_ARG_INFO(0, dn) + ZEND_ARG_INFO(0, ttl) +ZEND_END_ARG_INFO() +#endif + #ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_parse_exop, 0, 0, 4) ZEND_ARG_INFO(0, link) @@ -3899,6 +3944,9 @@ const zend_function_entry ldap_functions[] = { #ifdef HAVE_LDAP_WHOAMI_S PHP_FE(ldap_exop_whoami, arginfo_ldap_exop_whoami) #endif +#ifdef HAVE_LDAP_REFRESH_S + PHP_FE(ldap_exop_refresh, arginfo_ldap_exop_refresh) +#endif #ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT PHP_FE(ldap_parse_exop, arginfo_ldap_parse_exop) #endif diff --git a/ext/ldap/tests/ldap_exop_refresh.phpt b/ext/ldap/tests/ldap_exop_refresh.phpt new file mode 100644 index 0000000000..170f013943 --- /dev/null +++ b/ext/ldap/tests/ldap_exop_refresh.phpt @@ -0,0 +1,43 @@ +--TEST-- +ldap_exop_refresh() - Test LDAP refresh extended operation +--CREDITS-- +Emmanuel Dreyfus +--SKIPIF-- + + + +--FILE-- + array("person", "dynamicObject"), + "cn" => "tmp", + "sn" => "tmp" +)); +var_dump( + ldap_exop_refresh($link, "cn=tmp,$base", 1234) +); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +int(1234) +===DONE===