summaryrefslogtreecommitdiff
path: root/ext/ldap/ldap.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ldap/ldap.c')
-rw-r--r--ext/ldap/ldap.c189
1 files changed, 0 insertions, 189 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 13ea7647fc..489984ba81 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -3879,195 +3879,6 @@ PHP_FUNCTION(ldap_8859_to_t61)
/* }}} */
#endif
-#ifdef LDAP_CONTROL_PAGEDRESULTS
-/* {{{ Inject paged results control*/
-PHP_FUNCTION(ldap_control_paged_result)
-{
- zend_long pagesize;
- zend_bool iscritical;
- zval *link;
- char *cookie = NULL;
- size_t cookie_len = 0;
- struct berval lcookie = { 0L, NULL };
- ldap_linkdata *ld;
- LDAP *ldap;
- BerElement *ber = NULL;
- LDAPControl ctrl, *ctrlsp[2];
- int rc, myargcount = ZEND_NUM_ARGS();
-
- if (zend_parse_parameters(myargcount, "rl|bs", &link, &pagesize, &iscritical, &cookie, &cookie_len) != SUCCESS) {
- RETURN_THROWS();
- }
-
- if (Z_TYPE_P(link) == IS_NULL) {
- ldap = NULL;
- } else {
- if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
- ldap = ld->link;
- }
-
- ber = ber_alloc_t(LBER_USE_DER);
- if (ber == NULL) {
- php_error_docref(NULL, E_WARNING, "Unable to alloc BER encoding resources for paged results control");
- RETURN_FALSE;
- }
-
- ctrl.ldctl_iscritical = 0;
-
- switch (myargcount) {
- case 4:
- lcookie.bv_val = cookie;
- lcookie.bv_len = cookie_len;
- /* fallthru */
- case 3:
- ctrl.ldctl_iscritical = (int)iscritical;
- /* fallthru */
- }
-
- if (ber_printf(ber, "{iO}", (int)pagesize, &lcookie) == LBER_ERROR) {
- php_error_docref(NULL, E_WARNING, "Unable to BER printf paged results control");
- RETVAL_FALSE;
- goto lcpr_error_out;
- }
- rc = ber_flatten2(ber, &ctrl.ldctl_value, 0);
- if (rc == LBER_ERROR) {
- php_error_docref(NULL, E_WARNING, "Unable to BER encode paged results control");
- RETVAL_FALSE;
- goto lcpr_error_out;
- }
-
- ctrl.ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
-
- if (ldap) {
- /* directly set the option */
- ctrlsp[0] = &ctrl;
- ctrlsp[1] = NULL;
-
- rc = ldap_set_option(ldap, LDAP_OPT_SERVER_CONTROLS, ctrlsp);
- if (rc != LDAP_SUCCESS) {
- php_error_docref(NULL, E_WARNING, "Unable to set paged results control: %s (%d)", ldap_err2string(rc), rc);
- RETVAL_FALSE;
- goto lcpr_error_out;
- }
- RETVAL_TRUE;
- } else {
- /* return a PHP control object */
- array_init(return_value);
-
- add_assoc_string(return_value, "oid", ctrl.ldctl_oid);
- if (ctrl.ldctl_value.bv_len) {
- add_assoc_stringl(return_value, "value", ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len);
- }
- if (ctrl.ldctl_iscritical) {
- add_assoc_bool(return_value, "iscritical", ctrl.ldctl_iscritical);
- }
- }
-
-lcpr_error_out:
- if (ber != NULL) {
- ber_free(ber, 1);
- }
- return;
-}
-/* }}} */
-
-/* {{{ Extract paged results control response */
-PHP_FUNCTION(ldap_control_paged_result_response)
-{
- zval *link, *result, *cookie, *estimated;
- struct berval lcookie;
- int lestimated;
- ldap_linkdata *ld;
- LDAPMessage *ldap_result;
- LDAPControl **lserverctrls, *lctrl;
- BerElement *ber;
- ber_tag_t tag;
- int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
-
- if (zend_parse_parameters(myargcount, "rr|zz", &link, &result, &cookie, &estimated) != SUCCESS) {
- RETURN_THROWS();
- }
-
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
-
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
-
- rc = ldap_parse_result(ld->link,
- ldap_result,
- &lerrcode,
- NULL, /* matcheddn */
- NULL, /* errmsg */
- NULL, /* referrals */
- &lserverctrls,
- 0);
-
- if (rc != LDAP_SUCCESS) {
- php_error_docref(NULL, E_WARNING, "Unable to parse result: %s (%d)", ldap_err2string(rc), rc);
- RETURN_FALSE;
- }
-
- if (lerrcode != LDAP_SUCCESS) {
- php_error_docref(NULL, E_WARNING, "Result is: %s (%d)", ldap_err2string(lerrcode), lerrcode);
- RETURN_FALSE;
- }
-
- if (lserverctrls == NULL) {
- php_error_docref(NULL, E_WARNING, "No server controls in result");
- RETURN_FALSE;
- }
-
- lctrl = ldap_control_find(LDAP_CONTROL_PAGEDRESULTS, lserverctrls, NULL);
- if (lctrl == NULL) {
- ldap_controls_free(lserverctrls);
- php_error_docref(NULL, E_WARNING, "No paged results control response in result");
- RETURN_FALSE;
- }
-
- ber = ber_init(&lctrl->ldctl_value);
- if (ber == NULL) {
- ldap_controls_free(lserverctrls);
- php_error_docref(NULL, E_WARNING, "Unable to alloc BER decoding resources for paged results control response");
- RETURN_FALSE;
- }
-
- tag = ber_scanf(ber, "{io}", &lestimated, &lcookie);
- (void)ber_free(ber, 1);
-
- if (tag == LBER_ERROR) {
- ldap_controls_free(lserverctrls);
- php_error_docref(NULL, E_WARNING, "Unable to decode paged results control response");
- RETURN_FALSE;
- }
-
- if (lestimated < 0) {
- ldap_controls_free(lserverctrls);
- php_error_docref(NULL, E_WARNING, "Invalid paged results control response value");
- RETURN_FALSE;
- }
-
- ldap_controls_free(lserverctrls);
- if (myargcount == 4) {
- ZEND_TRY_ASSIGN_REF_LONG(estimated, lestimated);
- }
-
- if (lcookie.bv_len == 0) {
- ZEND_TRY_ASSIGN_REF_EMPTY_STRING(cookie);
- } else {
- ZEND_TRY_ASSIGN_REF_STRINGL(cookie, lcookie.bv_val, lcookie.bv_len);
- }
- ldap_memfree(lcookie.bv_val);
-
- RETURN_TRUE;
-}
-/* }}} */
-#endif
-
/* {{{ Extended operations, Pierangelo Masarati */
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
/* {{{ Extended operation */