/** * Constructor. * * Fetches a RootDSE object from an LDAP connection. * * @param Horde_Ldap $ldap Directory from which the RootDSE should be * fetched. * @param array $attrs Array of attributes to search for. * * @throws Horde_Ldap_Exception */ public function __construct(Horde_Ldap $ldap, $attrs = null) { if (is_array($attrs) && count($attrs)) { $attributes = $attrs; } else { $attributes = array('vendorName', 'vendorVersion', 'namingContexts', 'altServer', 'supportedExtension', 'supportedControl', 'supportedSASLMechanisms', 'supportedLDAPVersion', 'subschemaSubentry'); } $referral = $ldap->getOption('LDAP_OPT_REFERRALS'); $ldap->setOption('LDAP_OPT_REFERRALS', false); try { $result = $ldap->search('', '(objectClass=*)', array('attributes' => $attributes, 'scope' => 'base')); } catch (Horde_Ldap_Exception $e) { $ldap->setOption('LDAP_OPT_REFERRALS', $referral); throw $e; } $ldap->setOption('LDAP_OPT_REFERRALS', $referral); $entry = $result->shiftEntry(); if (!$entry) { throw new Horde_Ldap_Exception('Could not fetch RootDSE entry'); } $this->_entry = $entry; }