/** * Reload node attributes from LDAP. * * This is an online method. * * @param \Zend\Ldap\Ldap $ldap * @return AbstractNode Provides a fluid interface */ 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 the RootDse. * * @param \Zend\Ldap\Ldap $ldap * @return RootDse */ public static function create(Ldap\Ldap $ldap) { $dn = Ldap\Dn::fromString(''); $data = $ldap->getEntry($dn, ['*', '+'], true); if (isset($data['domainfunctionality'])) { return new RootDse\ActiveDirectory($dn, $data); } elseif (isset($data['dsaname'])) { return new RootDse\eDirectory($dn, $data); } elseif (isset($data['structuralobjectclass']) && $data['structuralobjectclass'][0] === 'OpenLDAProotDSE') { return new RootDse\OpenLdap($dn, $data); } return new static($dn, $data); }
/** * Factory method to create the Schema node. * * @param \Zend\Ldap\Ldap $ldap * @return \Zend\Ldap\Node\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::SERVER_TYPE_ACTIVEDIRECTORY: return new Schema\ActiveDirectory($dn, $data, $ldap); case RootDSE::SERVER_TYPE_OPENLDAP: return new Schema\OpenLdap($dn, $data, $ldap); case RootDSE::SERVER_TYPE_EDIRECTORY: default: return new self($dn, $data, $ldap); } }
public function findByUsername($username) { $this->bind(); $entryDN = "uid={$username}," . $this->active_server['baseDn']; $this->log("Attempting to get username entry: {$entryDN} against the active ldap server"); try { $hm = $this->ldap->getEntry($entryDN); $this->log("Raw Ldap Object: " . var_export($hm, true), 7); $this->log("Username entry lookup response: " . var_export($hm, true)); return $hm; } catch (LdapException $exc) { return $exc->getMessage(); } }
/** * Factory method to create an attached Zend\Ldap\Node for a given DN. * * @param string|array|Dn $dn * @param Ldap $ldap * @return Node|null * @throws Exception\LdapException */ public static function fromLdap($dn, Ldap $ldap) { if (is_string($dn) || is_array($dn)) { $dn = Dn::factory($dn); } elseif ($dn instanceof Dn) { $dn = clone $dn; } else { throw new Exception\LdapException(null, '$dn is of a wrong data type.'); } $data = $ldap->getEntry($dn, ['*', '+'], true); if ($data === null) { return; } $entry = new static($dn, $data, true, $ldap); return $entry; }