getOption() public method

Returns an LDAP option value.
public getOption ( string $option ) : Horde_Ldap_Error | string
$option string Option to get.
return Horde_Ldap_Error | string Horde_Ldap_Error or option value
Exemplo n.º 1
0
 /**
  * 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;
 }