src/Authentication/Handlers/HandlerLDAP.php
public function addObject($identifier, $attributes) {
		// bind using the add credentials
		$this->bind(
			$this->add_dn,
			$this->add_pw
		);

		// generate a new node and set its DN within the add subtree
		$node = new Node();

		// if the identifier contains a comma, it's likely a DN
		if(strpos($identifier, ',') !== FALSE) {
			$dn = $identifier;
		}
		else
		{
			// generate the DN from the identifier
			$dn = $this->search_username . '=' . $identifier . ',' .
				$this->add_base_dn;
		}
		
		$node->setDn($dn);

		// if the node already exists we want to return false to prevent any
		// potential updates (as updates would be performed by modifyObject())
		try {
			$this->ldap->getNode($dn);
			return false;
		}
		catch(NodeNotFoundException $e) {
			// iterate over the attributes and add them to the node
			foreach($attributes as $key => $value) {
				// this can handle both arrays of values as well as single values
				// to be added for the record
				$node->get($key, true)->add($value);
			}

			// save the node into the store
			$this->ldap->save($node);
			return true;
		}
	}
public function addObject($identifier, $attributes) {
		// bind using the add credentials
		$this->bind(
			$this->add_dn,
			$this->add_pw
		);

		// generate a new node and set its DN within the add subtree
		$node = new Node();

		// if the identifier contains a comma, it's likely a DN
		if(strpos($identifier, ',') !== FALSE) {
			$dn = $identifier;
		}
		else
		{
			// generate the DN from the identifier
			$dn = $this->search_username . '=' . $identifier . ',' .
				$this->add_base_dn;
		}
		
		$node->setDn($dn);

		// if the node already exists we want to return false to prevent any
		// potential updates (as updates would be performed by modifyObject())
		try {
			$this->ldap->getNode($dn);
			return false;
		}
		catch(NodeNotFoundException $e) {
			// iterate over the attributes and add them to the node
			foreach($attributes as $key => $value) {
				// this can handle both arrays of values as well as single values
				// to be added for the record
				$node->get($key, true)->add($value);
			}

			// save the node into the store
			$this->ldap->save($node);
			return true;
		}
	}
public function addObject ( $ identifier , $ attributes ) { // bind using the add credentials $ this -> bind ( $ this -> add_dn , $ this -> add_pw ) ; // generate a new node and set its DN within the add subtree $ node = new Node ( ) ; // if the identifier contains a comma, it's likely a DN if ( strpos ( $ identifier , ',' ) !== FALSE ) { $ dn = $ identifier ; } else { // generate the DN from the identifier $ dn = $ this -> search_username . '=' . $ identifier . ',' . $ this -> add_base_dn ; } $ node -> setDn ( $ dn ) ; // if the node already exists we want to return false to prevent any // potential updates (as updates would be performed by modifyObject()) try { $ this -> ldap -> getNode ( $ dn ) ; return false ; } catch ( NodeNotFoundException $ e ) { // iterate over the attributes and add them to the node foreach ( $ attributes as $ key => $ value ) { // this can handle both arrays of values as well as single values // to be added for the record $ node -> get ( $ key , true ) -> add ( $ value ) ; } // save the node into the store $ this -> ldap -> save ( $ node ) ; return true ; } }
Adds an object into the add subtree using the specified identifier and
an associative array of attributes. Returns a boolean describing whether
the operation was successful. Throws an exception if the bind fails.

@param string $identifier The value to use as the "username" identifier
@param array $attributes Associative array of attributes to add

@return bool
@throws BindException
Adds an object into the add subtree using the specified identifier and an associative array of attributes . Returns a boolean describing whether the operation was successful . Throws an exception if the bind fails .