You are here

public function SimpleLdapServer::add in Simple LDAP 7.2

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

Add an entry to the LDAP directory.

@throw SimpleLdapException

Parameters

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

array $attributes: An array of LDAP attributes and values.

Return value

boolean TRUE on success.

1 call to SimpleLdapServer::add()
SimpleLdapServer::copy in ./SimpleLdapServer.class.php
Copy an entry to a new DN.

File

./SimpleLdapServer.class.php, line 485
Class to handle LDAP server connections and related operations.

Class

SimpleLdapServer
Simple LDAP server class.

Code

public function add($dn, $attributes) {

  // Make sure changes are allowed.
  if ($this->readonly) {
    throw new SimpleLdapException('The LDAP Server is configured as read-only');
  }

  // Make sure there is a valid binding.
  $this
    ->bind();

  // Clean up the attributes array.
  $attributes = SimpleLdap::removeEmptyAttributes($attributes);

  // Add the entry.
  return SimpleLdap::ldap_add($this->resource, $dn, $attributes);
}