You are here

public function LdapServer::createLdapEntry in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_servers/LdapServer.class.php \LdapServer::createLdapEntry()

create ldap entry.

Parameters

array $attributes should follow the structure of ldap_add functions: entry array: http://us.php.net/manual/en/function.ldap-add.php $attributes["attribute1"] = "value"; $attributes["attribute2"][0] = "value1"; $attributes["attribute2"][1] = "value2";

Return value

boolean result

1 call to LdapServer::createLdapEntry()
LdapServer::groupAddGroup in ldap_servers/LdapServer.class.php
NOT TESTED add a group entry
1 method overrides LdapServer::createLdapEntry()
LdapServerTest::createLdapEntry in ldap_test/LdapServerTest.class.php
create ldap entry.

File

ldap_servers/LdapServer.class.php, line 418
Defines server classes and related functions.

Class

LdapServer
LDAP Server Class

Code

public function createLdapEntry($attributes, $dn = NULL) {
  if (!$this->connection) {
    $this
      ->connect();
    $this
      ->bind();
  }
  if (isset($attributes['dn'])) {
    $dn = $attributes['dn'];
    unset($attributes['dn']);
  }
  elseif (!$dn) {
    return FALSE;
  }
  $result = @ldap_add($this->connection, $dn, $attributes);
  if (!$result) {
    $error = "LDAP Server ldap_add(%dn) Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
    $tokens = array(
      '%dn' => $dn,
      '%sid' => $this->sid,
      '%ldap_errno' => ldap_errno($this->connection),
      '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)),
    );
    debug(t($error, $tokens));
    watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
  }
  return $result;
}