You are here

public static function SimpleLdap::ldap_add in Simple LDAP 7.2

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

Wrapper function for ldap_add().

@throw SimpleLdapException

Parameters

resource $link_identifier: An LDAP link identifier.

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

array $entry: An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0.

Return value

boolean TRUE on success.

1 call to SimpleLdap::ldap_add()
SimpleLdapServer::add in ./SimpleLdapServer.class.php
Add an entry to the LDAP directory.

File

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

Class

SimpleLdap
Simple LDAP class.

Code

public static function ldap_add($link_identifier, $dn, $entry) {

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

  // Wrapped function call.
  $return = @ldap_add($link_identifier, $dn, $entry);

  // Debugging.
  if (variable_get('simple_ldap_debug', FALSE)) {
    $message = __FUNCTION__ . '($link_identifier = @link_identifier, $dn = @dn, $entry = @entry) returns @return';
    $variables = array(
      '@link_identifier' => print_r($link_identifier, TRUE),
      '@dn' => print_r($dn, TRUE),
      '@entry' => print_r($entry, 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;
}