Exemplo n.º 1
0
 /**
  * Internal Constructor
  *
  * Constructor of the entry. Sets up the distinguished name and the entries
  * attributes.
  * You should not call this method manually! Use {@link Net_LDAP2_Entry::createFresh()}
  * or {@link Net_LDAP2_Entry::createConnected()} instead!
  *
  * @param Net_LDAP2|ressource|array $ldap Net_LDAP2 object, ldap-link ressource or array of attributes
  * @param string|ressource          $entry Either a DN or a LDAP-Entry ressource
  *
  * @access protected
  * @return none
  */
 public function __construct($ldap, $entry = null)
 {
     parent::__construct('Net_LDAP2_Error');
     // set up entry resource or DN
     if (is_resource($entry)) {
         $this->_entry = $entry;
     } else {
         $this->_dn = $entry;
     }
     // set up LDAP link
     if ($ldap instanceof Net_LDAP2) {
         $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->setAttributes($ldap);
     }
     // if this is an entry existing in the directory,
     // then set up as old and fetch attrs
     if (is_resource($this->_entry) && is_resource($this->_link)) {
         $this->_new = false;
         $this->_dn = @ldap_get_dn($this->_link, $this->_entry);
         $this->setAttributes();
         // fetch attributes from server
     }
 }