/* {{{ Extended operation response parsing, Pierangelo Masarati */
#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
-/* {{{ proto bool ldap_parse_exop(resource link, resource result [, string retoid [, string retdata]])
+/* {{{ proto bool ldap_parse_exop(resource link, resource result [, string retdata [, string retoid]])
Extract information from extended operation result */
PHP_FUNCTION(ldap_parse_exop)
{
- zval *link, *result, *retoid, *retdata;
+ zval *link, *result, *retdata, *retoid;
ldap_linkdata *ld;
LDAPMessage *ldap_result;
char *lretoid;
struct berval *lretdata;
int rc, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|z/z/", &link, &result, &retoid, &retdata) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|z/z/", &link, &result, &retdata, &retoid) != SUCCESS) {
WRONG_PARAM_COUNT;
}
}
rc = ldap_parse_extended_result(ld->link, ldap_result,
- myargcount > 2 ? &lretoid: NULL,
- myargcount > 3 ? &lretdata: NULL,
+ myargcount > 3 ? &lretoid: NULL,
+ myargcount > 2 ? &lretdata: NULL,
0);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse extended operation result: %s", ldap_err2string(rc));
/* Reverse -> fall through */
switch (myargcount) {
case 4:
- /* use arg #4 as the data returned by the server */
+ zval_dtor(retoid);
+ if (lretoid == NULL) {
+ ZVAL_EMPTY_STRING(retoid);
+ } else {
+ ZVAL_STRING(retoid, lretoid);
+ ldap_memfree(lretoid);
+ }
+ case 3:
+ /* use arg #3 as the data returned by the server */
zval_dtor(retdata);
if (lretdata == NULL) {
ZVAL_EMPTY_STRING(retdata);
ldap_memfree(lretdata->bv_val);
ldap_memfree(lretdata);
}
- case 3:
- zval_dtor(retoid);
- if (lretoid == NULL) {
- ZVAL_EMPTY_STRING(retoid);
- } else {
- ZVAL_STRING(retoid, lretoid);
- ldap_memfree(lretoid);
- }
}
RETURN_TRUE;
}
/* {{{ Extended operations, Pierangelo Masarati */
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
-/* {{{ proto ? ldap_exop(resource link, string reqoid [, string reqdata [, string retoid [, string retdata]]])
+/* {{{ proto ? ldap_exop(resource link, string reqoid [, string reqdata [, string retdata [, string retoid]]])
Extended operation */
PHP_FUNCTION(ldap_exop)
{
- zval *link, *reqoid, *reqdata, *retoid, *retdata;
+ zval *link, *reqoid, *reqdata, *retdata, *retoid;
char *lreqoid, *lretoid = NULL;
struct berval lreqdata, *lretdata = NULL;
ldap_linkdata *ld;
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|zz/z/", &link, &reqoid, &reqdata, &retoid, &retdata) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|zz/z/", &link, &reqoid, &reqdata, &retdata, &retoid) != SUCCESS) {
WRONG_PARAM_COUNT;
}
lreqdata.bv_len > 0 ? &lreqdata: NULL,
NULL,
NULL,
- &lretoid,
- myargcount > 4 ? &lretdata : NULL );
+ myargcount > 4 ? &lretoid : NULL,
+ &lretdata );
if (rc != LDAP_SUCCESS ) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Extended operation %s failed: %s (%d)", lreqoid, ldap_err2string(rc), rc);
RETURN_FALSE;
/* Reverse -> fall through */
switch (myargcount) {
case 5:
+ zval_dtor(retoid);
+ if (lretoid == NULL) {
+ ZVAL_EMPTY_STRING(retoid);
+ } else {
+ ZVAL_STRING(retoid, lretoid);
+ ldap_memfree(lretoid);
+ }
+ case 4:
/* use arg #4 as the data returned by the server */
zval_dtor(retdata);
if (lretdata == NULL) {
ldap_memfree(lretdata->bv_val);
ldap_memfree(lretdata);
}
- case 4:
- zval_dtor(retoid);
- if (lretoid == NULL) {
- ZVAL_EMPTY_STRING(retoid);
- } else {
- ZVAL_STRING(retoid, lretoid);
- ldap_memfree(lretoid);
- }
}
RETURN_TRUE;
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, reqoid)
ZEND_ARG_INFO(0, reqdata)
- ZEND_ARG_INFO(1, repoid)
- ZEND_ARG_INFO(1, repdata)
+ ZEND_ARG_INFO(1, retdata)
+ ZEND_ARG_INFO(1, retoid)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_parse_exop, 0, 0, 4)
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, result)
- ZEND_ARG_INFO(1, retoid)
ZEND_ARG_INFO(1, retdata)
+ ZEND_ARG_INFO(1, retoid)
ZEND_END_ARG_INFO()
#endif
/* }}} */
// 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, LDAP_EXOP_WHO_AM_I, NULL, $retoid, $retdata),
+ ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, $retdata, $retoid),
$retdata,
$retoid,
$r = ldap_exop($link, LDAP_EXOP_WHO_AM_I),
- ldap_parse_exop($link, $r, $retoid2, $retdata2),
+ ldap_parse_exop($link, $r, $retdata2),
$retdata2,
- $retoid2,
test_bind($host, $port, "cn=userA,$base", $userAPassword, $protocol_version),
$r = ldap_exop($link, LDAP_EXOP_MODIFY_PASSWD, build_reqdata_passwd("cn=userA,$base", $userAPassword, "")),
- ldap_parse_exop($link, $r, $retpwoid, $retpwdata),
+ ldap_parse_exop($link, $r, $retpwdata, $retpwoid),
$genpw = extract_genpw($retpwdata),
$retpwoid,
test_bind($host, $port, "cn=userA,$base", $genpw, $protocol_version)
resource(%d) of type (ldap result)
bool(true)
string(%d) "dn:%s"
-string(0) ""
bool(true)
resource(%d) of type (ldap result)
bool(true)