getConnection() public method

Returns the current Connection instance.
public getConnection ( ) : Adldap\Connections\ConnectionInterface
return Adldap\Connections\ConnectionInterface
Esempio n. 1
0
 /**
  * Moves the current model to a new RDN and new parent.
  *
  * @param string      $rdn
  * @param string|null $newParentDn
  * @param bool|true   $deleteOldRdn
  *
  * @return bool
  */
 public function move($rdn, $newParentDn = null, $deleteOldRdn = true)
 {
     $moved = $this->query->getConnection()->rename($this->getDn(), $rdn, $newParentDn, $deleteOldRdn);
     if ($moved) {
         // If the model was successfully moved, we'll set its
         // new DN so we can sync it's attributes properly.
         $this->setDn("{$rdn},{$newParentDn}");
         $this->syncRaw();
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Deletes the current entry.
  *
  * @throws ModelNotFoundException
  * @throws AdldapException
  *
  * @return bool
  */
 public function delete()
 {
     $dn = $this->getDn();
     if (!$this->exists) {
         // Make sure the record exists before we can delete it
         $message = 'Model does not exist in active directory.';
         throw new ModelNotFoundException($message);
     } elseif (is_null($dn) || empty($dn)) {
         // If the record exists but the DN attribute does
         // not exist, we can't process a delete.
         $message = 'Unable to delete. The current model does not have a distinguished name present.';
         throw new AdldapException($message);
     }
     $deleted = $this->query->getConnection()->delete($dn);
     if ($deleted) {
         // We'll set the exists property to false on delete
         // so the dev can run create operations
         $this->exists = false;
         return true;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @param Builder $builder
  */
 public function __construct(Builder $builder)
 {
     $this->builder = $builder;
     $this->connection = $builder->getConnection();
     $this->schema = $builder->getSchema();
 }
Esempio n. 4
0
 /**
  * Moves the current model to a new RDN and new parent.
  *
  * @param string    $rdn
  * @param string    $newParentDn
  * @param bool|true $deleteOldRdn
  *
  * @return bool
  */
 public function move($rdn, $newParentDn, $deleteOldRdn = true)
 {
     return $this->query->getConnection()->rename($this->getDn(), $rdn, $newParentDn, $deleteOldRdn);
 }