Net_LDAP2
[ class tree: Net_LDAP2 ] [ index: Net_LDAP2 ] [ all elements ]

Source for file RootDSE.php

Documentation is available at RootDSE.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3.  
  4. require_once 'PEAR.php';
  5.  
  6. /**
  7. * Getting the rootDSE entry of a LDAP server
  8. *
  9. @category Net
  10. @package  Net_LDAP2
  11. @author   Jan Wagner <wagner@netsols.de>
  12. @license  http://www.gnu.org/copyleft/lesser.html LGPL
  13. @version  CVS $Id: RootDSE.php,v 1.3 2008/07/30 09:13:57 beni Exp $
  14. @link     http://pear.php.net/package/Net_LDAP22/
  15. */
  16. class Net_LDAP2_RootDSE extends PEAR
  17. {
  18.     /**
  19.     * @access protected
  20.     * @var object Net_LDAP2_Entry 
  21.     ***/
  22.     protected $_entry;
  23.  
  24.     /**
  25.     * Class constructor
  26.     *
  27.     * @param Net_LDAP2_Entry &$entry Net_LDAP2_Entry object of the RootDSE
  28.     */
  29.     protected function __construct(&$entry)
  30.     {
  31.         $this->_entry = $entry;
  32.     }
  33.  
  34.     /**
  35.     * Fetches a RootDSE object from an LDAP connection
  36.     *
  37.     * @param Net_LDAP2 $ldap Directory from which the RootDSE should be fetched
  38.     * @param array $attrs Array of attributes to search for
  39.     *
  40.     * @access static
  41.     * @author Jan Wagner <wagner@netsols.de>
  42.     * @return Net_LDAP2_RootDSE|Net_LDAP2_Error
  43.     */
  44.     public static function fetch(&$ldap$attrs = null)
  45.     {
  46.         if (!$ldap instanceof Net_LDAP2{
  47.             return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!");
  48.         }
  49.  
  50.         if (is_array($attrs&& count($attrs> 0 {
  51.             $attributes $attrs;
  52.         else {
  53.             $attributes = array('vendorName',
  54.                                 'vendorVersion',
  55.                                 'namingContexts',
  56.                                 'altServer',
  57.                                 'supportedExtension',
  58.                                 'supportedControl',
  59.                                 'supportedSASLMechanisms',
  60.                                 'supportedLDAPVersion',
  61.                                 'subschemaSubentry' );
  62.         }
  63.         $result $ldap->search('''(objectClass=*)'array('attributes' => $attributes'scope' => 'base'));
  64.         if (self::isError($result)) {
  65.             return $result;
  66.         }
  67.         $entry $result->shiftEntry();
  68.         if (false === $entry{
  69.             return PEAR::raiseError('Could not fetch RootDSE entry');
  70.         }
  71.         $ret = new Net_LDAP2_RootDSE($entry);
  72.         return $ret;
  73.     }
  74.  
  75.     /**
  76.     * Gets the requested attribute value
  77.     *
  78.     * Same usuage as {@link Net_LDAP2_Entry::getValue()}
  79.     *
  80.     * @param string $attr    Attribute name
  81.     * @param array  $options Array of options
  82.     *
  83.     * @access public
  84.     * @return mixed Net_LDAP2_Error object or attribute values
  85.     * @see Net_LDAP2_Entry::get_value()
  86.     */
  87.     public function getValue($attr ''$options '')
  88.     {
  89.         return $this->_entry->get_value($attr$options);
  90.     }
  91.  
  92.     /**
  93.     * Alias function of getValue() for perl-ldap interface
  94.     *
  95.     * @see getValue()
  96.     */
  97.     public function get_value()
  98.     {
  99.         $args func_get_args();
  100.         return call_user_func_array(array&$this'getValue' )$args);
  101.     }
  102.  
  103.     /**
  104.     * Determines if the extension is supported
  105.     *
  106.     * @param array $oids Array of oids to check
  107.     *
  108.     * @access public
  109.     * @return boolean 
  110.     */
  111.     public function supportedExtension($oids)
  112.     {
  113.         return $this->_checkAttr($oids'supportedExtension');
  114.     }
  115.  
  116.     /**
  117.     * Alias function of supportedExtension() for perl-ldap interface
  118.     *
  119.     * @see supportedExtension()
  120.     */
  121.     public function supported_extension()
  122.     {
  123.         $args func_get_args();
  124.         return call_user_func_array(array&$this'supportedExtension')$args);
  125.     }
  126.  
  127.     /**
  128.     * Determines if the version is supported
  129.     *
  130.     * @param array $versions Versions to check
  131.     *
  132.     * @access public
  133.     * @return boolean 
  134.     */
  135.     public function supportedVersion($versions)
  136.     {
  137.         return $this->_checkAttr($versions'supportedLDAPVersion');
  138.     }
  139.  
  140.     /**
  141.     * Alias function of supportedVersion() for perl-ldap interface
  142.     *
  143.     * @see supportedVersion()
  144.     */
  145.     public function supported_version()
  146.     {
  147.         $args func_get_args();
  148.         return call_user_func_array(array(&$this'supportedVersion')$args);
  149.     }
  150.  
  151.     /**
  152.     * Determines if the control is supported
  153.     *
  154.     * @param array $oids Control oids to check
  155.     *
  156.     * @access public
  157.     * @return boolean 
  158.     */
  159.     public function supportedControl($oids)
  160.     {
  161.         return $this->_checkAttr($oids'supportedControl');
  162.     }
  163.  
  164.     /**
  165.     * Alias function of supportedControl() for perl-ldap interface
  166.     *
  167.     * @see supportedControl()
  168.     */
  169.     public function supported_control()
  170.     {
  171.         $args func_get_args();
  172.         return call_user_func_array(array(&$this'supportedControl' )$args);
  173.     }
  174.  
  175.     /**
  176.     * Determines if the sasl mechanism is supported
  177.     *
  178.     * @param array $mechlist SASL mechanisms to check
  179.     *
  180.     * @access public
  181.     * @return boolean 
  182.     */
  183.     public function supportedSASLMechanism($mechlist)
  184.     {
  185.         return $this->_checkAttr($mechlist'supportedSASLMechanisms');
  186.     }
  187.  
  188.     /**
  189.     * Alias function of supportedSASLMechanism() for perl-ldap interface
  190.     *
  191.     * @see supportedSASLMechanism()
  192.     */
  193.     public function supported_sasl_mechanism()
  194.     {
  195.         $args func_get_args();
  196.         return call_user_func_array(array(&$this'supportedSASLMechanism')$args);
  197.     }
  198.  
  199.     /**
  200.     * Checks for existance of value in attribute
  201.     *
  202.     * @param array  $values values to check
  203.     * @param string $attr   attribute name
  204.     *
  205.     * @access protected
  206.     * @return boolean 
  207.     */
  208.     public function _checkAttr($values$attr)
  209.     {
  210.         if (!is_array($values)) $values = array($values);
  211.  
  212.         foreach ($values as $value{
  213.             if (!@in_array($value$this->get_value($attr'all'))) {
  214.                 return false;
  215.             }
  216.         }
  217.         return true;
  218.     }
  219. }
  220.  
  221. ?>

Documentation generated on Mon, 11 Mar 2019 15:25:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.