You are here

public static function SimpleLdap::ldap_list in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 SimpleLdap.class.php \SimpleLdap::ldap_list()

Wrapper function for ldap_list().

@throw SimpleLdapException

@todo debug $result

Parameters

resource $link_identifier: An LDAP link identifier.

string $base_dn: The base DN for the directory.

string $filter: The LDAP filter to apply.

array $attributes: An array of the required attributes.

int $attrsonly: Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour.

int $sizelimit: Enables you to limit the count of entries fetched. Setting this to 0 means no limit.

int $timelimit: Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.

int $deref: Specifies how aliases should be handled during the search.

Return value

resource LDAP search result identifier.

1 call to SimpleLdap::ldap_list()
SimpleLdapServer::search in ./SimpleLdapServer.class.php
Search the LDAP server.

File

./SimpleLdap.class.php, line 798
Class defining base Simple LDAP functionallity.

Class

SimpleLdap
Simple LDAP class.

Code

public static function ldap_list($link_identifier, $base_dn, $filter, $attributes = array(), $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = LDAP_DEREF_NEVER) {

  // Devel debugging.
  if (variable_get('simple_ldap_devel', FALSE)) {
    dpm(__FUNCTION__);
    dpm(array(
      '$base_dn' => $base_dn,
      '$filter' => $filter,
      '$attributes' => $attributes,
      '$attrsonly' => $attrsonly,
      '$sizelimit' => $sizelimit,
      '$timelimit' => $timelimit,
      '$deref' => $deref,
    ));
  }

  // Wrapped function call.
  $return = @ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);

  // Debugging.
  if (variable_get('simple_ldap_debug', FALSE)) {
    $message = __FUNCTION__ . '($link_identifier = @link_identifier, $base_dn = @base_dn, $filter = @filter, $attributes = @attributes, $attrsonly = @attrsonly, $sizelimit = @sizelimit, $timelimit = @timelimit, $deref = @deref) returns @return';
    $variables = array(
      '@link_identifier' => print_r($link_identifier, TRUE),
      '@base_dn' => print_r($base_dn, TRUE),
      '@filter' => print_r($filter, TRUE),
      '@attributes' => print_r($attributes, TRUE),
      '@attrsonly' => print_r($attrsonly, TRUE),
      '@sizelimit' => print_r($sizelimit, TRUE),
      '@timelimit' => print_r($timelimit, TRUE),
      '@deref' => print_r($deref, TRUE),
      '@return' => print_r($return, TRUE),
    );
    watchdog('simple_ldap', $message, $variables, WATCHDOG_DEBUG);
  }

  // Error handling.
  if ($return === FALSE) {
    throw new SimpleLdapException($link_identifier);
  }
  return $return;
}