Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param resource            $search     Search result identifier.
  * @param Horde_Ldap|resource $ldap       Horde_Ldap object or a LDAP link
  *                                        resource
  * @param array               $attributes The searched attribute names,
  *                                        see {@link $_searchedAttrs}.
  */
 public function __construct($search, $ldap, $attributes = array())
 {
     $this->setSearch($search);
     if ($ldap instanceof Horde_Ldap) {
         $this->_ldap = $ldap;
         $this->setLink($this->_ldap->getLink());
     } else {
         $this->setLink($ldap);
     }
     $this->_errorCode = @ldap_errno($this->_link);
     if (is_array($attributes) && !empty($attributes)) {
         $this->_searchedAttrs = $attributes;
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor.
  *
  * Sets up the distinguished name and the entries attributes.
  *
  * Use {@link Horde_Ldap_Entry::createFresh()} or {@link
  * Horde_Ldap_Entry::createConnected()} to create Horde_Ldap_Entry objects.
  *
  * @param Horde_Ldap|resource|array $ldap Horde_Ldap object, LDAP
  *                                        connection resource or
  *                                        array of attributes.
  * @param string|resource          $entry Either a DN or a LDAP entry
  *                                        resource.
  */
 protected function __construct($ldap, $entry = null)
 {
     /* Set up entry resource or DN. */
     if (is_resource($entry)) {
         $this->_entry = $entry;
     } else {
         $this->_dn = $entry;
     }
     /* Set up LDAP link. */
     if ($ldap instanceof Horde_Ldap) {
         $this->_ldap = $ldap;
         $this->_link = $ldap->getLink();
     } elseif (is_resource($ldap)) {
         $this->_link = $ldap;
     } elseif (is_array($ldap)) {
         /* Special case: here $ldap is an array of attributes, this means,
          * we have no link. This is a "virtual" entry.  We just set up the
          * attributes so one can work with the object as expected, but an
          * update() fails unless setLDAP() is called. */
         $this->_loadAttributes($ldap);
     }
     /* If this is an entry existing in the directory, then set up as old
      * and fetch attributes. */
     if (is_resource($this->_entry) && is_resource($this->_link)) {
         $this->_new = false;
         $this->_dn = @ldap_get_dn($this->_link, $this->_entry);
         /* Fetch attributes from server. */
         $this->_loadAttributes();
     }
 }
Exemplo n.º 3
0
 /**
  * Test getLink().
  */
 public function testGetLink()
 {
     $ldap = new Horde_Ldap(self::$ldapcfg['server']);
     $this->assertTrue(is_resource($ldap->getLink()));
 }