You are here

public static function SimpleLdap::ldap_compare in Simple LDAP 7

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

Wrapper function for ldap_compare().

@throw SimpleLdapException

Parameters

resource $link_identifier: An LDAP link identifier.

string $dn: The distinguished name of an LDAP entity.

string $attribute: The attribute name.

string $value: The compared value.

Return value

boolean Returns TRUE if value matches otherwise returns FALSE.

1 call to SimpleLdap::ldap_compare()
SimpleLdapServer::compare in ./SimpleLdapServer.class.php
Compare the given attribute value with what is in the LDAP server.

File

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

Class

SimpleLdap
Simple LDAP class.

Code

public static function ldap_compare($link_identifier, $dn, $attribute, $value) {

  // Devel debugging.
  if (variable_get('simple_ldap_devel', FALSE)) {
    dpm(__FUNCTION__);
    dpm(array(
      '$dn' => $dn,
      '$attribute' => $attribute,
      '$value' => $value,
    ));
  }

  // Wrapped function call.
  $return = @ldap_compare($link_identifier, $dn, $attribute, $value);

  // Debugging.
  if (variable_get('simple_ldap_debug', FALSE)) {
    $message = __FUNCTION__ . '($link_identifier = @link_identifier, $dn = @dn, $attribute = @attribute, $value = @value) returns @return';
    $variables = array(
      '@link_identifier' => print_r($link_identifier, TRUE),
      '@dn' => print_r($dn, TRUE),
      '@attribute' => print_r($attribute, TRUE),
      '@value' => print_r($value, TRUE),
      '@return' => print_r($return, TRUE),
    );
    watchdog('simple_ldap', $message, $variables, WATCHDOG_DEBUG);
  }

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