Implement ldap_exop_sync

This commit is contained in:
Máté Kocsis 2023-07-12 11:31:15 +02:00
parent 72aada3c7c
commit b3bd55f244
4 changed files with 47 additions and 6 deletions

View file

@ -3883,9 +3883,7 @@ PHP_FUNCTION(ldap_8859_to_t61)
/* {{{ Extended operations, Pierangelo Masarati */ /* {{{ Extended operations, Pierangelo Masarati */
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S #ifdef HAVE_LDAP_EXTENDED_OPERATION_S
/* {{{ Extended operation */ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
PHP_FUNCTION(ldap_exop)
{
zval *serverctrls = NULL; zval *serverctrls = NULL;
zval *link, *retdata = NULL, *retoid = NULL; zval *link, *retdata = NULL, *retoid = NULL;
char *lretoid = NULL; char *lretoid = NULL;
@ -3919,7 +3917,7 @@ PHP_FUNCTION(ldap_exop)
} }
} }
if (retdata) { if (force_sync || retdata) {
/* synchronous call */ /* synchronous call */
rc = ldap_extended_operation_s(ld->link, ZSTR_VAL(reqoid), rc = ldap_extended_operation_s(ld->link, ZSTR_VAL(reqoid),
lreqdata.bv_len > 0 ? &lreqdata: NULL, lreqdata.bv_len > 0 ? &lreqdata: NULL,
@ -3978,12 +3976,23 @@ PHP_FUNCTION(ldap_exop)
result = Z_LDAP_RESULT_P(return_value); result = Z_LDAP_RESULT_P(return_value);
result->result = ldap_res; result->result = ldap_res;
cleanup: cleanup:
if (lserverctrls) { if (lserverctrls) {
_php_ldap_controls_free(&lserverctrls); _php_ldap_controls_free(&lserverctrls);
} }
} }
/* {{{ Extended operation */
PHP_FUNCTION(ldap_exop)
{
php_ldap_exop(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
}
/* }}} */ /* }}} */
PHP_FUNCTION(ldap_exop_sync)
{
php_ldap_exop(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
}
#endif #endif
#ifdef HAVE_LDAP_PASSWD #ifdef HAVE_LDAP_PASSWD

View file

@ -777,6 +777,11 @@ namespace {
* @param string $response_oid * @param string $response_oid
*/ */
function ldap_exop(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAP\Result|bool {} function ldap_exop(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAP\Result|bool {}
/**
* @param string $response_data
* @param string $response_oid
*/
function ldap_exop_sync(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = null, &$response_oid = null): LDAP\Result|bool {}
#endif #endif
#ifdef HAVE_LDAP_PASSWD #ifdef HAVE_LDAP_PASSWD

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead. /* This is a generated file, edit the .stub.php file instead.
* Stub hash: 63ed5b30556367b8ce48a421a85b92ecf41413b7 */ * Stub hash: fec87d81c21ac5d56e62a5e0b4bbe673ea76edd5 */
#if defined(HAVE_ORALDAP) #if defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP\\Connection, MAY_BE_FALSE) ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP\\Connection, MAY_BE_FALSE)
@ -316,6 +316,17 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_exop, 0, 2, LDAP\\Resul
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
#endif #endif
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_exop_sync, 0, 2, LDAP\\Result, MAY_BE_BOOL)
ZEND_ARG_OBJ_INFO(0, ldap, LDAP\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, request_oid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, request_data, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "NULL")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_data, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_oid, "null")
ZEND_END_ARG_INFO()
#endif
#if defined(HAVE_LDAP_PASSWD) #if defined(HAVE_LDAP_PASSWD)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_exop_passwd, 0, 1, MAY_BE_STRING|MAY_BE_BOOL) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_exop_passwd, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_OBJ_INFO(0, ldap, LDAP\\Connection, 0) ZEND_ARG_OBJ_INFO(0, ldap, LDAP\\Connection, 0)
@ -438,6 +449,9 @@ ZEND_FUNCTION(ldap_8859_to_t61);
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) #if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
ZEND_FUNCTION(ldap_exop); ZEND_FUNCTION(ldap_exop);
#endif #endif
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
ZEND_FUNCTION(ldap_exop_sync);
#endif
#if defined(HAVE_LDAP_PASSWD) #if defined(HAVE_LDAP_PASSWD)
ZEND_FUNCTION(ldap_exop_passwd); ZEND_FUNCTION(ldap_exop_passwd);
#endif #endif
@ -544,6 +558,9 @@ static const zend_function_entry ext_functions[] = {
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) #if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
ZEND_FE(ldap_exop, arginfo_ldap_exop) ZEND_FE(ldap_exop, arginfo_ldap_exop)
#endif #endif
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
ZEND_FE(ldap_exop_sync, arginfo_ldap_exop_sync)
#endif
#if defined(HAVE_LDAP_PASSWD) #if defined(HAVE_LDAP_PASSWD)
ZEND_FE(ldap_exop_passwd, arginfo_ldap_exop_passwd) ZEND_FE(ldap_exop_passwd, arginfo_ldap_exop_passwd)
#endif #endif

View file

@ -41,8 +41,13 @@ var_dump(
ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid), ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid),
$retdata, $retdata,
$retoid, $retoid,
ldap_exop_sync($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid),
$retdata,
$retoid,
ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata), ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata),
$retdata, $retdata,
ldap_exop_sync($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata),
$retdata,
$r = ldap_exop($link, LDAP_EXOP_WHO_AM_I), $r = ldap_exop($link, LDAP_EXOP_WHO_AM_I),
ldap_parse_exop($link, $r, $retdata2), ldap_parse_exop($link, $r, $retdata2),
$retdata2, $retdata2,
@ -67,6 +72,11 @@ bool(true)
string(%d) "dn:%s" string(%d) "dn:%s"
string(0) "" string(0) ""
bool(true) bool(true)
string(%d) "dn:%s"
string(0) ""
bool(true)
string(%d) "dn:cn=user%s"
bool(true)
string(%d) "dn:cn=user%s" string(%d) "dn:cn=user%s"
object(LDAP\Result)#%d (0) { object(LDAP\Result)#%d (0) {
} }