Skip to content

Commit b3bd55f

Browse files
committed
Implement ldap_exop_sync
1 parent 72aada3 commit b3bd55f

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

ext/ldap/ldap.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,9 +3883,7 @@ PHP_FUNCTION(ldap_8859_to_t61)
38833883

38843884
/* {{{ Extended operations, Pierangelo Masarati */
38853885
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
3886-
/* {{{ Extended operation */
3887-
PHP_FUNCTION(ldap_exop)
3888-
{
3886+
static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
38893887
zval *serverctrls = NULL;
38903888
zval *link, *retdata = NULL, *retoid = NULL;
38913889
char *lretoid = NULL;
@@ -3919,7 +3917,7 @@ PHP_FUNCTION(ldap_exop)
39193917
}
39203918
}
39213919

3922-
if (retdata) {
3920+
if (force_sync || retdata) {
39233921
/* synchronous call */
39243922
rc = ldap_extended_operation_s(ld->link, ZSTR_VAL(reqoid),
39253923
lreqdata.bv_len > 0 ? &lreqdata: NULL,
@@ -3978,12 +3976,23 @@ PHP_FUNCTION(ldap_exop)
39783976
result = Z_LDAP_RESULT_P(return_value);
39793977
result->result = ldap_res;
39803978

3981-
cleanup:
3979+
cleanup:
39823980
if (lserverctrls) {
39833981
_php_ldap_controls_free(&lserverctrls);
39843982
}
39853983
}
3984+
3985+
/* {{{ Extended operation */
3986+
PHP_FUNCTION(ldap_exop)
3987+
{
3988+
php_ldap_exop(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
3989+
}
39863990
/* }}} */
3991+
3992+
PHP_FUNCTION(ldap_exop_sync)
3993+
{
3994+
php_ldap_exop(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
3995+
}
39873996
#endif
39883997

39893998
#ifdef HAVE_LDAP_PASSWD

ext/ldap/ldap.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,11 @@ function ldap_8859_to_t61(string $value): string|false {}
777777
* @param string $response_oid
778778
*/
779779
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 {}
780+
/**
781+
* @param string $response_data
782+
* @param string $response_oid
783+
*/
784+
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 {}
780785
#endif
781786

782787
#ifdef HAVE_LDAP_PASSWD

ext/ldap/ldap_arginfo.h

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/ldap/tests/ldap_exop.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ var_dump(
4141
ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid),
4242
$retdata,
4343
$retoid,
44+
ldap_exop_sync($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid),
45+
$retdata,
46+
$retoid,
4447
ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata),
4548
$retdata,
49+
ldap_exop_sync($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata),
50+
$retdata,
4651
$r = ldap_exop($link, LDAP_EXOP_WHO_AM_I),
4752
ldap_parse_exop($link, $r, $retdata2),
4853
$retdata2,
@@ -67,6 +72,11 @@ bool(true)
6772
string(%d) "dn:%s"
6873
string(0) ""
6974
bool(true)
75+
string(%d) "dn:%s"
76+
string(0) ""
77+
bool(true)
78+
string(%d) "dn:cn=user%s"
79+
bool(true)
7080
string(%d) "dn:cn=user%s"
7181
object(LDAP\Result)#%d (0) {
7282
}

0 commit comments

Comments
 (0)