Back to index

php5  5.3.10
Classes | Defines | Functions | Variables
ldap.c File Reference
#include "php.h"
#include "php_ini.h"
#include <stddef.h>
#include "ext/standard/dl.h"
#include "php_ldap.h"
#include "ext/standard/php_string.h"
#include "ext/standard/info.h"

Go to the source code of this file.

Classes

struct  ldap_linkdata
struct  ldap_resultentry

Defines

#define IS_EXT_MODULE
#define PHP_LD_FULL_ADD   0xff

Functions

static PHP_GINIT_FUNCTION (ldap)
static void _close_ldap_link (zend_rsrc_list_entry *rsrc TSRMLS_DC)
static void _free_ldap_result (zend_rsrc_list_entry *rsrc TSRMLS_DC)
static void _free_ldap_result_entry (zend_rsrc_list_entry *rsrc TSRMLS_DC)
 PHP_MINIT_FUNCTION (ldap)
 PHP_MSHUTDOWN_FUNCTION (ldap)
 PHP_MINFO_FUNCTION (ldap)
 PHP_FUNCTION (ldap_connect)
static int _get_lderrno (LDAP *ldap)
 PHP_FUNCTION (ldap_bind)
 PHP_FUNCTION (ldap_unbind)
static void php_set_opts (LDAP *ldap, int sizelimit, int timelimit, int deref, int *old_sizelimit, int *old_timelimit, int *old_deref)
static void php_ldap_do_search (INTERNAL_FUNCTION_PARAMETERS, int scope)
 PHP_FUNCTION (ldap_read)
 PHP_FUNCTION (ldap_list)
 PHP_FUNCTION (ldap_search)
 PHP_FUNCTION (ldap_free_result)
 PHP_FUNCTION (ldap_count_entries)
 PHP_FUNCTION (ldap_first_entry)
 PHP_FUNCTION (ldap_next_entry)
 PHP_FUNCTION (ldap_get_entries)
 PHP_FUNCTION (ldap_first_attribute)
 PHP_FUNCTION (ldap_next_attribute)
 PHP_FUNCTION (ldap_get_attributes)
 PHP_FUNCTION (ldap_get_values_len)
 PHP_FUNCTION (ldap_get_dn)
 PHP_FUNCTION (ldap_explode_dn)
 PHP_FUNCTION (ldap_dn2ufn)
static void php_ldap_do_modify (INTERNAL_FUNCTION_PARAMETERS, int oper)
 PHP_FUNCTION (ldap_add)
 PHP_FUNCTION (ldap_mod_replace)
 PHP_FUNCTION (ldap_mod_add)
 PHP_FUNCTION (ldap_mod_del)
 PHP_FUNCTION (ldap_delete)
 PHP_FUNCTION (ldap_errno)
 PHP_FUNCTION (ldap_err2str)
 PHP_FUNCTION (ldap_error)
 PHP_FUNCTION (ldap_compare)
 PHP_FUNCTION (ldap_sort)

Variables

static int le_link
static int le_result
static int le_result_entry
const zend_function_entry ldap_functions []
zend_module_entry ldap_module_entry

Class Documentation

struct ldap_linkdata

Definition at line 70 of file ldap.c.

Class Members
LDAP * link
struct ldap_resultentry

Definition at line 77 of file ldap.c.

Class Members
BerElement * ber
LDAPMessage * data
int id

Define Documentation

#define IS_EXT_MODULE

Definition at line 27 of file ldap.c.

#define PHP_LD_FULL_ADD   0xff

Definition at line 1255 of file ldap.c.


Function Documentation

static void _close_ldap_link ( zend_rsrc_list_entry *rsrc  TSRMLS_DC) [static]

Definition at line 92 of file ldap.c.

{
       ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;

       ldap_unbind_s(ld->link);
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
       if (ld->rebindproc != NULL) {
              zval_dtor(ld->rebindproc);
              FREE_ZVAL(ld->rebindproc);
       }
#endif
       efree(ld);
       LDAPG(num_links)--;
}

Here is the caller graph for this function:

static void _free_ldap_result ( zend_rsrc_list_entry *rsrc  TSRMLS_DC) [static]

Definition at line 108 of file ldap.c.

{
       LDAPMessage *result = (LDAPMessage *)rsrc->ptr;
       ldap_msgfree(result);
}

Here is the caller graph for this function:

static void _free_ldap_result_entry ( zend_rsrc_list_entry *rsrc  TSRMLS_DC) [static]

Definition at line 115 of file ldap.c.

{
       ldap_resultentry *entry = (ldap_resultentry *)rsrc->ptr;

       if (entry->ber != NULL) {
              ber_free(entry->ber, 0);
              entry->ber = NULL;
       }
       zend_list_delete(entry->id);
       efree(entry);
} 

Here is the caller graph for this function:

static int _get_lderrno ( LDAP *  ldap) [static]

Definition at line 361 of file ldap.c.

{
#if !HAVE_NSLDAP
#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP_10
       int lderr;

       /* New versions of OpenLDAP do it this way */
       ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr);
       return lderr;
#else
       return ldap->ld_errno;
#endif
#else
       return ldap_get_lderrno(ldap, NULL, NULL);
#endif
}

Here is the caller graph for this function:

PHP_FUNCTION ( ldap_connect  )

Definition at line 282 of file ldap.c.

{
       char *host = NULL;
       int hostlen;
       long port = 389; /* Default port */
#ifdef HAVE_ORALDAP
       char *wallet = NULL, *walletpasswd = NULL;
       int walletlen = 0, walletpasswdlen = 0;
       long authmode = GSLC_SSL_NO_AUTH;
       int ssl=0;
#endif
       ldap_linkdata *ld;
       LDAP *ldap;

#ifdef HAVE_ORALDAP
       if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
              WRONG_PARAM_COUNT;
       }

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|slssl", &host, &hostlen, &port, &wallet, &walletlen, &walletpasswd, &walletpasswdlen, &authmode) != SUCCESS) {
              RETURN_FALSE;
       }

       if (ZEND_NUM_ARGS() == 5) {
              ssl = 1;
       }
#else
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", &host, &hostlen, &port) != SUCCESS) {
              RETURN_FALSE;
       }
#endif

       if (LDAPG(max_links) != -1 && LDAPG(num_links) >= LDAPG(max_links)) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", LDAPG(num_links));
              RETURN_FALSE;
       }

       ld = ecalloc(1, sizeof(ldap_linkdata));

#ifdef LDAP_API_FEATURE_X_OPENLDAP
       if (host != NULL && strchr(host, '/')) {
              int rc;
              
              rc = ldap_initialize(&ldap, host);
              if (rc != LDAP_SUCCESS) {
                     efree(ld);
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create session handle: %s", ldap_err2string(rc));
                     RETURN_FALSE;
              }
       } else {
              ldap = ldap_init(host, port);
       }
#else
       ldap = ldap_open(host, port);
#endif
       
       if (ldap == NULL) {
              efree(ld);
              RETURN_FALSE;
       } else {
#ifdef HAVE_ORALDAP
              if (ssl) {
                     if (ldap_init_SSL(&ldap->ld_sb, wallet, walletpasswd, authmode)) {
                            efree(ld);
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL init failed");
                            RETURN_FALSE;
                     }
              }                    
#endif
              LDAPG(num_links)++;
              ld->link = ldap;
              ZEND_REGISTER_RESOURCE(return_value, ld, le_link);
       }

}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_bind  )

Definition at line 381 of file ldap.c.

{
       zval *link;
       char *ldap_bind_dn = NULL, *ldap_bind_pw = NULL;
       int ldap_bind_dnlen, ldap_bind_pwlen;
       ldap_linkdata *ld;
       int rc;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ss", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen) != SUCCESS) {
              RETURN_FALSE;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
              RETURN_FALSE;
       } else {
              RETURN_TRUE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_unbind  )

Definition at line 531 of file ldap.c.

{
       zval *link;
       ldap_linkdata *ld;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &link) != SUCCESS) {
              RETURN_FALSE;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       zend_list_delete(Z_LVAL_P(link));
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_read  )

Definition at line 797 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_list  )

Definition at line 805 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_search  )

Definition at line 813 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_free_result  )

Definition at line 821 of file ldap.c.

{
       zval *result;
       LDAPMessage *ldap_result;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &result) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, &result, -1, "ldap result", le_result);

       zend_list_delete(Z_LVAL_P(result));  /* Delete list entry */
       RETVAL_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_count_entries  )

Definition at line 839 of file ldap.c.

{
       zval *link, *result;
       ldap_linkdata *ld;
       LDAPMessage *ldap_result;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, &result, -1, "ldap result", le_result);

       RETURN_LONG(ldap_count_entries(ld->link, ldap_result));
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_first_entry  )

Definition at line 858 of file ldap.c.

{
       zval *link, *result;
       ldap_linkdata *ld;   
       ldap_resultentry *resultentry;
       LDAPMessage *ldap_result, *entry;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, &result, -1, "ldap result", le_result);

       if ((entry = ldap_first_entry(ld->link, ldap_result)) == NULL) {
              RETVAL_FALSE;
       } else {
              resultentry = emalloc(sizeof(ldap_resultentry));
              ZEND_REGISTER_RESOURCE(return_value, resultentry, le_result_entry);
              resultentry->id = Z_LVAL_P(result);
              zend_list_addref(resultentry->id);
              resultentry->data = entry;
              resultentry->ber = NULL;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_next_entry  )

Definition at line 887 of file ldap.c.

{
       zval *link, *result_entry;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry, *resultentry_next;
       LDAPMessage *entry_next;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result_entry) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       if ((entry_next = ldap_next_entry(ld->link, resultentry->data)) == NULL) {
              RETVAL_FALSE;
       } else {
              resultentry_next = emalloc(sizeof(ldap_resultentry));
              ZEND_REGISTER_RESOURCE(return_value, resultentry_next, le_result_entry);
              resultentry_next->id = resultentry->id;
              zend_list_addref(resultentry->id);
              resultentry_next->data = entry_next;
              resultentry_next->ber = NULL;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_get_entries  )

Definition at line 916 of file ldap.c.

{
       zval *link, *result;
       LDAPMessage *ldap_result, *ldap_result_entry;
       zval *tmp1, *tmp2;
       ldap_linkdata *ld;
       LDAP *ldap;
       int num_entries, num_attrib, num_values, i;
       BerElement *ber;
       char *attribute;
       size_t attr_len;
       struct berval **ldap_value;
       char *dn;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, &result, -1, "ldap result", le_result);

       ldap = ld->link;
       num_entries = ldap_count_entries(ldap, ldap_result);

       array_init(return_value);
       add_assoc_long(return_value, "count", num_entries);

       if (num_entries == 0) {
              return;
       }
       
       ldap_result_entry = ldap_first_entry(ldap, ldap_result);
       if (ldap_result_entry == NULL) {
              zval_dtor(return_value);
              RETURN_FALSE;
       }

       num_entries = 0;
       while (ldap_result_entry != NULL) {
              MAKE_STD_ZVAL(tmp1);
              array_init(tmp1);

              num_attrib = 0;
              attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);

              while (attribute != NULL) {
                     ldap_value = ldap_get_values_len(ldap, ldap_result_entry, attribute);
                     num_values = ldap_count_values_len(ldap_value);

                     MAKE_STD_ZVAL(tmp2);
                     array_init(tmp2);
                     add_assoc_long(tmp2, "count", num_values);
                     for (i = 0; i < num_values; i++) {
                            add_index_stringl(tmp2, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len, 1);
                     }      
                     ldap_value_free_len(ldap_value);

                     attr_len = strlen(attribute);
                     zend_hash_update(Z_ARRVAL_P(tmp1), php_strtolower(attribute, attr_len), attr_len+1, (void *) &tmp2, sizeof(zval *), NULL);
                     add_index_string(tmp1, num_attrib, attribute, 1);

                     num_attrib++;
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
                     ldap_memfree(attribute);
#endif
                     attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
              }
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              if (ber != NULL) {
                     ber_free(ber, 0);
              }
#endif

              add_assoc_long(tmp1, "count", num_attrib);
              dn = ldap_get_dn(ldap, ldap_result_entry);
              add_assoc_string(tmp1, "dn", dn, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(dn);
#else
              free(dn);
#endif

              zend_hash_index_update(Z_ARRVAL_P(return_value), num_entries, (void *) &tmp1, sizeof(zval *), NULL);
              
              num_entries++;
              ldap_result_entry = ldap_next_entry(ldap, ldap_result_entry);
       }

       add_assoc_long(return_value, "count", num_entries);

}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_first_attribute  )

Definition at line 1011 of file ldap.c.

{
       zval *link, *result_entry;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry;
       char *attribute;
       long dummy_ber;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       if ((attribute = ldap_first_attribute(ld->link, resultentry->data, &resultentry->ber)) == NULL) {
              RETURN_FALSE;
       } else {
              RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(attribute);
#endif
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_next_attribute  )

Definition at line 1039 of file ldap.c.

{
       zval *link, *result_entry;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry;
       char *attribute;
       long dummy_ber;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       if (resultentry->ber == NULL) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "called before calling ldap_first_attribute() or no attributes found in result entry");
              RETURN_FALSE;
       }

       if ((attribute = ldap_next_attribute(ld->link, resultentry->data, resultentry->ber)) == NULL) {
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              if (resultentry->ber != NULL) {
                     ber_free(resultentry->ber, 0);
                     resultentry->ber = NULL;
              }
#endif
              RETURN_FALSE;
       } else {
              RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(attribute);
#endif
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_get_attributes  )

Definition at line 1078 of file ldap.c.

{
       zval *link, *result_entry;
       zval *tmp;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry;
       char *attribute;
       struct berval **ldap_value;
       int i, num_values, num_attrib;
       BerElement *ber;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result_entry) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       array_init(return_value);
       num_attrib = 0;
       
       attribute = ldap_first_attribute(ld->link, resultentry->data, &ber);
       while (attribute != NULL) {
              ldap_value = ldap_get_values_len(ld->link, resultentry->data, attribute);
              num_values = ldap_count_values_len(ldap_value);

              MAKE_STD_ZVAL(tmp);
              array_init(tmp);
              add_assoc_long(tmp, "count", num_values);
              for (i = 0; i < num_values; i++) {
                     add_index_stringl(tmp, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len, 1);
              }
              ldap_value_free_len(ldap_value);

              zend_hash_update(Z_ARRVAL_P(return_value), attribute, strlen(attribute)+1, (void *) &tmp, sizeof(zval *), NULL);
              add_index_string(return_value, num_attrib, attribute, 1);

              num_attrib++;
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(attribute);
#endif
              attribute = ldap_next_attribute(ld->link, resultentry->data, ber);
       }
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
       if (ber != NULL) {
              ber_free(ber, 0);
       }
#endif
       
       add_assoc_long(return_value, "count", num_attrib);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_get_values_len  )

Definition at line 1133 of file ldap.c.

{
       zval *link, *result_entry;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry;
       char *attr;
       struct berval **ldap_value_len;
       int i, num_values, attr_len;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrs", &link, &result_entry, &attr, &attr_len) != SUCCESS) {
              return;
       }
       
       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       if ((ldap_value_len = ldap_get_values_len(ld->link, resultentry->data, attr)) == NULL) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ld->link)));
              RETURN_FALSE;
       }
       
       num_values = ldap_count_values_len(ldap_value_len);
       array_init(return_value);
       
       for (i=0; i<num_values; i++) {
              add_next_index_stringl(return_value, ldap_value_len[i]->bv_val, ldap_value_len[i]->bv_len, 1);
       }
       
       add_assoc_long(return_value, "count", num_values);
       ldap_value_free_len(ldap_value_len);

}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_get_dn  )

Definition at line 1169 of file ldap.c.

{
       zval *link, *result_entry;
       ldap_linkdata *ld;
       ldap_resultentry *resultentry;
       char *text;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result_entry) != SUCCESS) {
              return;
       }
       
       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
       ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);

       text = ldap_get_dn(ld->link, resultentry->data);
       if (text != NULL) {
              RETVAL_STRING(text, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(text);
#else
              free(text);
#endif
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_explode_dn  )

Definition at line 1199 of file ldap.c.

{
       long with_attrib;
       char *dn, **ldap_value;
       int i, count, dn_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &dn, &dn_len, &with_attrib) != SUCCESS) {
              return;
       }

       if (!(ldap_value = ldap_explode_dn(dn, with_attrib))) {
              /* Invalid parameters were passed to ldap_explode_dn */
              RETURN_FALSE;
       }

       i=0;
       while (ldap_value[i] != NULL) i++;
       count = i;

       array_init(return_value);

       add_assoc_long(return_value, "count", count);
       for (i = 0; i<count; i++) {
              add_index_string(return_value, i, ldap_value[i], 1);
       }

       ldap_value_free(ldap_value);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_dn2ufn  )

Definition at line 1231 of file ldap.c.

{
       char *dn, *ufn;
       int dn_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dn, &dn_len) != SUCCESS) {
              return;
       }
       
       ufn = ldap_dn2ufn(dn);
       
       if (ufn != NULL) {
              RETVAL_STRING(ufn, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
              ldap_memfree(ufn);
#endif
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_add  )

Definition at line 1378 of file ldap.c.

{
       /* use a newly define parameter into the do_modify so ldap_mod_add can be used the way it is supposed to be used , Gerrit THomson */
       php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_mod_replace  )

Definition at line 1389 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_mod_add  )

Definition at line 1397 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_mod_del  )

Definition at line 1405 of file ldap.c.

Here is the call graph for this function:

PHP_FUNCTION ( ldap_delete  )

Definition at line 1413 of file ldap.c.

{
       zval *link;
       ldap_linkdata *ld;
       char *dn;
       int rc, dn_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &link, &dn, &dn_len) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       if ((rc = ldap_delete_s(ld->link, dn)) != LDAP_SUCCESS) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Delete: %s", ldap_err2string(rc));
              RETURN_FALSE;
       }

       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_errno  )

Definition at line 1437 of file ldap.c.

{
       zval *link;
       ldap_linkdata *ld;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &link) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       RETURN_LONG(_get_lderrno(ld->link));
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_err2str  )

Definition at line 1454 of file ldap.c.

{
       long perrno;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perrno) != SUCCESS) {
              return;
       }

       RETURN_STRING(ldap_err2string(perrno), 1);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_error  )

Definition at line 1468 of file ldap.c.

{
       zval *link;
       ldap_linkdata *ld;
       int ld_errno;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &link) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       ld_errno = _get_lderrno(ld->link);

       RETURN_STRING(ldap_err2string(ld_errno), 1);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_compare  )

Definition at line 1488 of file ldap.c.

{
       zval *link;
       char *dn, *attr, *value;
       int dn_len, attr_len, value_len;
       ldap_linkdata *ld;
       int errno;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &link, &dn, &dn_len, &attr, &attr_len, &value, &value_len) != SUCCESS) {
              return;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       errno = ldap_compare_s(ld->link, dn, attr, value);

       switch (errno) {
              case LDAP_COMPARE_TRUE:
                     RETURN_TRUE;
                     break;

              case LDAP_COMPARE_FALSE:
                     RETURN_FALSE;
                     break;
       }
       
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno));
       RETURN_LONG(-1);
}

Here is the call graph for this function:

PHP_FUNCTION ( ldap_sort  )

Definition at line 1521 of file ldap.c.

{
       zval *link, *result;
       ldap_linkdata *ld;
       char *sortfilter;
       int sflen;
       zend_rsrc_list_entry *le;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrs", &link, &result, &sortfilter, &sflen) != SUCCESS) {
              RETURN_FALSE;
       }

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       if (zend_hash_index_find(&EG(regular_list), Z_LVAL_P(result), (void **) &le) != SUCCESS || le->type != le_result) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied resource is not a valid ldap result resource");
              RETURN_FALSE;
       }

       if (ldap_sort_entries(ld->link, (LDAPMessage **) &le->ptr, sflen ? sortfilter : NULL, strcmp) != LDAP_SUCCESS) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ldap_err2string(errno));
              RETURN_FALSE;
       }

       RETURN_TRUE;
}

Here is the call graph for this function:

static PHP_GINIT_FUNCTION ( ldap  ) [static]

Definition at line 137 of file ldap.c.

{
       ldap_globals->num_links = 0;
}
static void php_ldap_do_modify ( INTERNAL_FUNCTION_PARAMETERS  ,
int  oper 
) [static]

Definition at line 1258 of file ldap.c.

{
       zval *link, *entry, **value, **ivalue;
       ldap_linkdata *ld;
       char *dn;
       LDAPMod **ldap_mods;
       int i, j, num_attribs, num_values, dn_len;
       int *num_berval;
       char *attribute;
       ulong index;
       int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &link, &dn, &dn_len, &entry) != SUCCESS) {
              return;
       }      

       ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);

       num_attribs = zend_hash_num_elements(Z_ARRVAL_P(entry));
       ldap_mods = safe_emalloc((num_attribs+1), sizeof(LDAPMod *), 0);
       num_berval = safe_emalloc(num_attribs, sizeof(int), 0);
       zend_hash_internal_pointer_reset(Z_ARRVAL_P(entry));

       /* added by gerrit thomson to fix ldap_add using ldap_mod_add */
       if (oper == PHP_LD_FULL_ADD) {
              oper = LDAP_MOD_ADD;
              is_full_add = 1;
       }
       /* end additional , gerrit thomson */

       for (i = 0; i < num_attribs; i++) {
              ldap_mods[i] = emalloc(sizeof(LDAPMod));
              ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES;
              ldap_mods[i]->mod_type = NULL;

              if (zend_hash_get_current_key(Z_ARRVAL_P(entry), &attribute, &index, 0) == HASH_KEY_IS_STRING) {
                     ldap_mods[i]->mod_type = estrdup(attribute);
              } else {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown attribute in the data");
                     /* Free allocated memory */
                     while (i >= 0) {
                            if (ldap_mods[i]->mod_type) {
                                   efree(ldap_mods[i]->mod_type);
                            }
                            efree(ldap_mods[i]);
                            i--;
                     }
                     efree(num_berval);
                     efree(ldap_mods);    
                     RETURN_FALSE;
              }

              zend_hash_get_current_data(Z_ARRVAL_P(entry), (void **)&value);

              if (Z_TYPE_PP(value) != IS_ARRAY) {
                     num_values = 1;
              } else {
                     num_values = zend_hash_num_elements(Z_ARRVAL_PP(value));
              }
              
              num_berval[i] = num_values;
              ldap_mods[i]->mod_bvalues = safe_emalloc((num_values + 1), sizeof(struct berval *), 0);

/* allow for arrays with one element, no allowance for arrays with none but probably not required, gerrit thomson. */
              if ((num_values == 1) && (Z_TYPE_PP(value) != IS_ARRAY)) {
                     convert_to_string_ex(value);
                     ldap_mods[i]->mod_bvalues[0] = (struct berval *) emalloc (sizeof(struct berval));
                     ldap_mods[i]->mod_bvalues[0]->bv_len = Z_STRLEN_PP(value);
                     ldap_mods[i]->mod_bvalues[0]->bv_val = Z_STRVAL_PP(value);
              } else {      
                     for (j = 0; j < num_values; j++) {
                            if (zend_hash_index_find(Z_ARRVAL_PP(value), j, (void **) &ivalue) != SUCCESS) {
                                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value array must have consecutive indices 0, 1, ...");
                                   num_berval[i] = j;
                                   num_attribs = i + 1;
                                   RETVAL_FALSE;
                                   goto errexit;
                            }
                            convert_to_string_ex(ivalue);
                            ldap_mods[i]->mod_bvalues[j] = (struct berval *) emalloc (sizeof(struct berval));
                            ldap_mods[i]->mod_bvalues[j]->bv_len = Z_STRLEN_PP(ivalue);
                            ldap_mods[i]->mod_bvalues[j]->bv_val = Z_STRVAL_PP(ivalue);
                     }
              }
              ldap_mods[i]->mod_bvalues[num_values] = NULL;
              zend_hash_move_forward(Z_ARRVAL_P(entry));
       }
       ldap_mods[num_attribs] = NULL;

/* check flag to see if do_mod was called to perform full add , gerrit thomson */
       if (is_full_add == 1) {
              if ((i = ldap_add_s(ld->link, dn, ldap_mods)) != LDAP_SUCCESS) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Add: %s", ldap_err2string(i));
                     RETVAL_FALSE;
              } else RETVAL_TRUE;
       } else {
              if ((i = ldap_modify_ext_s(ld->link, dn, ldap_mods, NULL, NULL)) != LDAP_SUCCESS) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Modify: %s", ldap_err2string(i));
                     RETVAL_FALSE;
              } else RETVAL_TRUE;  
       }

errexit:
       for (i = 0; i < num_attribs; i++) {
              efree(ldap_mods[i]->mod_type);
              for (j = 0; j < num_berval[i]; j++) {
                     efree(ldap_mods[i]->mod_bvalues[j]);
              }
              efree(ldap_mods[i]->mod_bvalues);
              efree(ldap_mods[i]);
       }
       efree(num_berval);
       efree(ldap_mods);    

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void php_ldap_do_search ( INTERNAL_FUNCTION_PARAMETERS  ,
int  scope 
) [static]

Definition at line 588 of file ldap.c.

{
       zval *link, *base_dn, **filter, *attrs, **attr;
       long attrsonly, sizelimit, timelimit, deref;
       char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL; 
       ldap_linkdata *ld = NULL;
       LDAPMessage *ldap_res;
       int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;   
       int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;    
       int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS();

       if (zend_parse_parameters(argcount TSRMLS_CC, "zzZ|allll", &link, &base_dn, &filter, &attrs, &attrsonly,
              &sizelimit, &timelimit, &deref) == FAILURE) {
              return;
       }

       /* Reverse -> fall through */
       switch (argcount) {
              case 8:
                     ldap_deref = deref;
              case 7:
                     ldap_timelimit = timelimit;
              case 6:
                     ldap_sizelimit = sizelimit;
              case 5:
                     ldap_attrsonly = attrsonly;
              case 4:
                     num_attribs = zend_hash_num_elements(Z_ARRVAL_P(attrs));
                     ldap_attrs = safe_emalloc((num_attribs+1), sizeof(char *), 0);

                     for (i = 0; i<num_attribs; i++) {
                            if (zend_hash_index_find(Z_ARRVAL_P(attrs), i, (void **) &attr) != SUCCESS) {
                                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array initialization wrong");
                                   ret = 0;
                                   goto cleanup;
                            }

                            SEPARATE_ZVAL(attr);
                            convert_to_string_ex(attr);
                            ldap_attrs[i] = Z_STRVAL_PP(attr);
                     }
                     ldap_attrs[num_attribs] = NULL;
              default:
                     break;
       }

       /* parallel search? */
       if (Z_TYPE_P(link) == IS_ARRAY) {
              int i, nlinks, nbases, nfilters, *rcs;
              ldap_linkdata **lds;
              zval **entry, *resource;
              
              nlinks = zend_hash_num_elements(Z_ARRVAL_P(link));
              if (nlinks == 0) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "No links in link array");
                     ret = 0;
                     goto cleanup;
              }

              if (Z_TYPE_P(base_dn) == IS_ARRAY) {
                     nbases = zend_hash_num_elements(Z_ARRVAL_P(base_dn));
                     if (nbases != nlinks) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Base must either be a string, or an array with the same number of elements as the links array");
                            ret = 0;
                            goto cleanup;
                     }
                     zend_hash_internal_pointer_reset(Z_ARRVAL_P(base_dn));
              } else {
                     nbases = 0; /* this means string, not array */
                     /* If anything else than string is passed, ldap_base_dn = NULL */
                     if (Z_TYPE_P(base_dn) == IS_STRING) {
                            ldap_base_dn = Z_STRVAL_P(base_dn);
                     } else {
                            ldap_base_dn = NULL;
                     }
              }

              if (Z_TYPE_PP(filter) == IS_ARRAY) {
                     nfilters = zend_hash_num_elements(Z_ARRVAL_PP(filter));
                     if (nfilters != nlinks) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter must either be a string, or an array with the same number of elements as the links array");
                            ret = 0;
                            goto cleanup;
                     }
                     zend_hash_internal_pointer_reset(Z_ARRVAL_PP(filter));
              } else {
                     nfilters = 0; /* this means string, not array */
                     convert_to_string_ex(filter);
                     ldap_filter = Z_STRVAL_PP(filter);
              }

              lds = safe_emalloc(nlinks, sizeof(ldap_linkdata), 0);
              rcs = safe_emalloc(nlinks, sizeof(*rcs), 0);
              
              zend_hash_internal_pointer_reset(Z_ARRVAL_P(link));
              for (i=0; i<nlinks; i++) {
                     zend_hash_get_current_data(Z_ARRVAL_P(link), (void **)&entry);

                     ld = (ldap_linkdata *) zend_fetch_resource(entry TSRMLS_CC, -1, "ldap link", NULL, 1, le_link);
                     if (ld == NULL) {
                            ret = 0;
                            goto cleanup_parallel;
                     }
                     if (nbases != 0) { /* base_dn an array? */
                            zend_hash_get_current_data(Z_ARRVAL_P(base_dn), (void **)&entry);
                            zend_hash_move_forward(Z_ARRVAL_P(base_dn));

                            /* If anything else than string is passed, ldap_base_dn = NULL */
                            if (Z_TYPE_PP(entry) == IS_STRING) {
                                   ldap_base_dn = Z_STRVAL_PP(entry);
                            } else {
                                   ldap_base_dn = NULL;
                            }
                     }
                     if (nfilters != 0) { /* filter an array? */
                            zend_hash_get_current_data(Z_ARRVAL_PP(filter), (void **)&entry);
                            zend_hash_move_forward(Z_ARRVAL_PP(filter));
                            convert_to_string_ex(entry);
                            ldap_filter = Z_STRVAL_PP(entry);
                     }

                     php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref);

                     /* Run the actual search */ 
                     rcs[i] = ldap_search(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly);
                     lds[i] = ld;
                     zend_hash_move_forward(Z_ARRVAL_P(link));
              }
              
              array_init(return_value);

              /* Collect results from the searches */
              for (i=0; i<nlinks; i++) {
                     MAKE_STD_ZVAL(resource);
                     if (rcs[i] != -1) {
                            rcs[i] = ldap_result(lds[i]->link, LDAP_RES_ANY, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res);
                     }
                     if (rcs[i] != -1) {
                            ZEND_REGISTER_RESOURCE(resource, ldap_res, le_result);
                            add_next_index_zval(return_value, resource);
                     } else {
                            add_next_index_bool(return_value, 0);
                     }
              }

cleanup_parallel:
              efree(lds);
              efree(rcs);
       } else {
              convert_to_string_ex(filter);
              ldap_filter = Z_STRVAL_PP(filter);

              /* If anything else than string is passed, ldap_base_dn = NULL */
              if (Z_TYPE_P(base_dn) == IS_STRING) {
                     ldap_base_dn = Z_STRVAL_P(base_dn);
              }

              ld = (ldap_linkdata *) zend_fetch_resource(&link TSRMLS_CC, -1, "ldap link", NULL, 1, le_link);
              if (ld == NULL) {
                     ret = 0;
                     goto cleanup;
              }

              php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref);

              /* Run the actual search */ 
              errno = ldap_search_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, &ldap_res);
       
              if (errno != LDAP_SUCCESS
                     && errno != LDAP_SIZELIMIT_EXCEEDED
#ifdef LDAP_ADMINLIMIT_EXCEEDED
                     && errno != LDAP_ADMINLIMIT_EXCEEDED
#endif
#ifdef LDAP_REFERRAL
                     && errno != LDAP_REFERRAL
#endif
              ) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Search: %s", ldap_err2string(errno));
                     ret = 0;
              } else {
                     if (errno == LDAP_SIZELIMIT_EXCEEDED) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Partial search results returned: Sizelimit exceeded");
                     }
#ifdef LDAP_ADMINLIMIT_EXCEEDED
                     else if (errno == LDAP_ADMINLIMIT_EXCEEDED) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Partial search results returned: Adminlimit exceeded");
                     }
#endif
                     
                     ZEND_REGISTER_RESOURCE(return_value, ldap_res, le_result);
              }
       }

cleanup:
       if (ld) {
              /* Restoring previous options */
              php_set_opts(ld->link, old_ldap_sizelimit, old_ldap_timelimit, old_ldap_deref, &ldap_sizelimit, &ldap_timelimit, &ldap_deref);
       }
       if (ldap_attrs != NULL) {
              efree(ldap_attrs);
       }
       if (!ret) {
              RETVAL_BOOL(ret);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHP_MINFO_FUNCTION ( ldap  )

Definition at line 219 of file ldap.c.

{
       char tmp[32];
#if HAVE_NSLDAP
       LDAPVersion ver;
       double SDKVersion;
#endif

       php_info_print_table_start();
       php_info_print_table_row(2, "LDAP Support", "enabled");
       php_info_print_table_row(2, "RCS Version", "$Id: ldap.c 321634 2012-01-01 13:15:04Z felipe $");

       if (LDAPG(max_links) == -1) {
              snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
       } else {
              snprintf(tmp, 31, "%ld/%ld", LDAPG(num_links), LDAPG(max_links));
       }
       php_info_print_table_row(2, "Total Links", tmp);

#ifdef LDAP_API_VERSION
       snprintf(tmp, 31, "%d", LDAP_API_VERSION);
       php_info_print_table_row(2, "API Version", tmp);
#endif

#ifdef LDAP_VENDOR_NAME
       php_info_print_table_row(2, "Vendor Name", LDAP_VENDOR_NAME);
#endif

#ifdef LDAP_VENDOR_VERSION
       snprintf(tmp, 31, "%d", LDAP_VENDOR_VERSION);
       php_info_print_table_row(2, "Vendor Version", tmp);
#endif

#if HAVE_NSLDAP
       SDKVersion = ldap_version(&ver);
       snprintf(tmp, 31, "%F", SDKVersion/100.0);
       php_info_print_table_row(2, "SDK Version", tmp);

       snprintf(tmp, 31, "%F", ver.protocol_version/100.0);
       php_info_print_table_row(2, "Highest LDAP Protocol Supported", tmp);

       snprintf(tmp, 31, "%F", ver.SSL_version/100.0);
       php_info_print_table_row(2, "SSL Level Supported", tmp);

       if (ver.security_level != LDAP_SECURITY_NONE) {
              snprintf(tmp, 31, "%d", ver.security_level);
       } else {
              strcpy(tmp, "SSL not enabled");
       }
       php_info_print_table_row(2, "Level of Encryption", tmp);
#endif

#ifdef HAVE_LDAP_SASL
       php_info_print_table_row(2, "SASL Support", "Enabled");
#endif

       php_info_print_table_end();
       DISPLAY_INI_ENTRIES();
}

Here is the call graph for this function:

PHP_MINIT_FUNCTION ( ldap  )

Definition at line 145 of file ldap.c.

{
       REGISTER_INI_ENTRIES();

       /* Constants to be used with deref-parameter in php_ldap_do_search() */
       REGISTER_LONG_CONSTANT("LDAP_DEREF_NEVER", LDAP_DEREF_NEVER, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_DEREF_SEARCHING", LDAP_DEREF_SEARCHING, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, CONST_PERSISTENT | CONST_CS);

#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
       /* LDAP options */
       REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_TIMELIMIT", LDAP_OPT_TIMELIMIT, CONST_PERSISTENT | CONST_CS);
#ifdef LDAP_OPT_NETWORK_TIMEOUT
       REGISTER_LONG_CONSTANT("LDAP_OPT_NETWORK_TIMEOUT", LDAP_OPT_NETWORK_TIMEOUT, CONST_PERSISTENT | CONST_CS);
#elif defined (LDAP_X_OPT_CONNECT_TIMEOUT)
       REGISTER_LONG_CONSTANT("LDAP_OPT_NETWORK_TIMEOUT", LDAP_X_OPT_CONNECT_TIMEOUT, CONST_PERSISTENT | CONST_CS);
#endif
       REGISTER_LONG_CONSTANT("LDAP_OPT_PROTOCOL_VERSION", LDAP_OPT_PROTOCOL_VERSION, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_NUMBER", LDAP_OPT_ERROR_NUMBER, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_REFERRALS", LDAP_OPT_REFERRALS, CONST_PERSISTENT | CONST_CS);
#ifdef LDAP_OPT_RESTART
       REGISTER_LONG_CONSTANT("LDAP_OPT_RESTART", LDAP_OPT_RESTART, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LDAP_OPT_HOST_NAME
       REGISTER_LONG_CONSTANT("LDAP_OPT_HOST_NAME", LDAP_OPT_HOST_NAME, CONST_PERSISTENT | CONST_CS);
#endif
       REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_STRING", LDAP_OPT_ERROR_STRING, CONST_PERSISTENT | CONST_CS);
#ifdef LDAP_OPT_MATCHED_DN
       REGISTER_LONG_CONSTANT("LDAP_OPT_MATCHED_DN", LDAP_OPT_MATCHED_DN, CONST_PERSISTENT | CONST_CS);
#endif
       REGISTER_LONG_CONSTANT("LDAP_OPT_SERVER_CONTROLS", LDAP_OPT_SERVER_CONTROLS, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_CLIENT_CONTROLS", LDAP_OPT_CLIENT_CONTROLS, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LDAP_OPT_DEBUG_LEVEL
       REGISTER_LONG_CONSTANT("LDAP_OPT_DEBUG_LEVEL", LDAP_OPT_DEBUG_LEVEL, CONST_PERSISTENT | CONST_CS);
#endif

#ifdef HAVE_LDAP_SASL
       REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_MECH", LDAP_OPT_X_SASL_MECH, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_REALM", LDAP_OPT_X_SASL_REALM, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_AUTHCID", LDAP_OPT_X_SASL_AUTHCID, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_AUTHZID", LDAP_OPT_X_SASL_AUTHZID, CONST_PERSISTENT | CONST_CS);
#endif

#ifdef ORALDAP
       REGISTER_LONG_CONSTANT("GSLC_SSL_NO_AUTH", GSLC_SSL_NO_AUTH, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("GSLC_SSL_ONEWAY_AUTH", GSLC_SSL_ONEWAY_AUTH, CONST_PERSISTENT | CONST_CS);
       REGISTER_LONG_CONSTANT("GSLC_SSL_TWOWAY_AUTH", GSLC_SSL_TWOWAY_AUTH, CONST_PERSISTENT | CONST_CS);
#endif

       le_link = zend_register_list_destructors_ex(_close_ldap_link, NULL, "ldap link", module_number);
       le_result = zend_register_list_destructors_ex(_free_ldap_result, NULL, "ldap result", module_number);
       le_result_entry = zend_register_list_destructors_ex(_free_ldap_result_entry, NULL, "ldap result entry", module_number);

       Z_TYPE(ldap_module_entry) = type;

       return SUCCESS;
}

Here is the call graph for this function:

Definition at line 210 of file ldap.c.

static void php_set_opts ( LDAP *  ldap,
int  sizelimit,
int  timelimit,
int  deref,
int old_sizelimit,
int old_timelimit,
int old_deref 
) [static]

Definition at line 549 of file ldap.c.

{
       /* sizelimit */
       if (sizelimit > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
              ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_sizelimit);
              ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
#else
              *old_sizelimit = ldap->ld_sizelimit; 
              ldap->ld_sizelimit = sizelimit; 
#endif
       }

       /* timelimit */
       if (timelimit > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
              ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_timelimit);
              ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
#else
              *old_timelimit = ldap->ld_timelimit; 
              ldap->ld_timelimit = timelimit; 
#endif
       }

       /* deref */
       if (deref > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
              ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_deref);
              ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#else
              *old_deref = ldap->ld_deref; 
              ldap->ld_deref = deref; 
#endif
       }
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 2443 of file ldap.c.

zend_module_entry ldap_module_entry
Initial value:

Definition at line 2513 of file ldap.c.

int le_link [static]

Definition at line 86 of file ldap.c.

int le_result [static]

Definition at line 86 of file ldap.c.

int le_result_entry [static]

Definition at line 86 of file ldap.c.