/** * Factory method to create the Schema node. * * @param \Zend\LDAP\LDAP $ldap * @return \Zend\LDAP\Node\Schema\Schema * @throws \Zend\LDAP\Exception */ public static function create(LDAP\LDAP $ldap) { $dn = $ldap->getRootDse()->getSchemaDn(); $data = $ldap->getEntry($dn, array('*', '+'), true); switch ($ldap->getRootDse()->getServerType()) { case RootDSE\RootDSE::SERVER_TYPE_ACTIVEDIRECTORY: return new ActiveDirectory($dn, $data, $ldap); case RootDSE\RootDSE::SERVER_TYPE_OPENLDAP: return new OpenLDAP($dn, $data, $ldap); case RootDSE\RootDSE::SERVER_TYPE_EDIRECTORY: default: return new self($dn, $data, $ldap); } }
/** * Factory method to create the RootDSE. * * @param \Zend\LDAP\LDAP $ldap * @return \Zend\LDAP\Node\RootDSE\RootDSE * @throws \Zend\LDAP\Exception */ public static function create(LDAP\LDAP $ldap) { $dn = LDAP\DN::fromString(''); $data = $ldap->getEntry($dn, array('*', '+'), true); if (isset($data['domainfunctionality'])) { return new ActiveDirectory($dn, $data); } else { if (isset($data['dsaname'])) { return new eDirectory($dn, $data); } else { if (isset($data['structuralobjectclass']) && $data['structuralobjectclass'][0] === 'OpenLDAProotDSE') { return new OpenLDAP($dn, $data); } else { return new self($dn, $data); } } } }
/** * Reload node attributes from LDAP. * * This is an online method. * * @param \Zend\LDAP\LDAP $ldap * @return \Zend\LDAP\Node\AbstractNode Provides a fluid interface * @throws \Zend\LDAP\Exception */ public function reload(LDAP\LDAP $ldap = null) { if ($ldap !== null) { $data = $ldap->getEntry($this->_getDn(), array('*', '+'), true); $this->_loadData($data, true); } return $this; }
/** * Factory method to create an attached Zend_LDAP_Node for a given DN. * * @param string|array|\Zend\LDAP\DN $dn * @param \Zend\LDAP\LDAP $ldap * @return \Zend\LDAP\Node\Node|null * @throws \Zend\LDAP\Exception */ public static function fromLDAP($dn, LDAP\LDAP $ldap) { if (is_string($dn) || is_array($dn)) { $dn = LDAP\DN::factory($dn); } else { if ($dn instanceof LDAP\DN) { $dn = clone $dn; } else { throw new LDAP\Exception(null, '$dn is of a wrong data type.'); } } $data = $ldap->getEntry($dn, array('*', '+'), true); if ($data === null) { return null; } $entry = new self($dn, $data, true, $ldap); return $entry; }