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.2 2008/03/20 09:32:39 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('namingContexts',
  54.                                 'altServer',
  55.                                 'supportedExtension',
  56.                                 'supportedControl',
  57.                                 'supportedSASLMechanisms',
  58.                                 'supportedLDAPVersion',
  59.                                 'subschemaSubentry' );
  60.         }
  61.         $result $ldap->search('''(objectClass=*)'array('attributes' => $attributes'scope' => 'base'));
  62.         if (self::isError($result)) {
  63.             return $result;
  64.         }
  65.         $entry $result->shiftEntry();
  66.         if (false === $entry{
  67.             return PEAR::raiseError('Could not fetch RootDSE entry');
  68.         }
  69.         $ret = new Net_LDAP2_RootDSE($entry);
  70.         return $ret;
  71.     }
  72.  
  73.     /**
  74.     * Gets the requested attribute value
  75.     *
  76.     * Same usuage as {@link Net_LDAP2_Entry::getValue()}
  77.     *
  78.     * @param string $attr    Attribute name
  79.     * @param array  $options Array of options
  80.     *
  81.     * @access public
  82.     * @return mixed Net_LDAP2_Error object or attribute values
  83.     * @see Net_LDAP2_Entry::get_value()
  84.     */
  85.     public function getValue($attr ''$options '')
  86.     {
  87.         return $this->_entry->get_value($attr$options);
  88.     }
  89.  
  90.     /**
  91.     * Alias function of getValue() for perl-ldap interface
  92.     *
  93.     * @see getValue()
  94.     */
  95.     public function get_value()
  96.     {
  97.         $args func_get_args();
  98.         return call_user_func_array(array&$this'getValue' )$args);
  99.     }
  100.  
  101.     /**
  102.     * Determines if the extension is supported
  103.     *
  104.     * @param array $oids Array of oids to check
  105.     *
  106.     * @access public
  107.     * @return boolean 
  108.     */
  109.     public function supportedExtension($oids)
  110.     {
  111.         return $this->_checkAttr($oids'supportedExtension');
  112.     }
  113.  
  114.     /**
  115.     * Alias function of supportedExtension() for perl-ldap interface
  116.     *
  117.     * @see supportedExtension()
  118.     */
  119.     public function supported_extension()
  120.     {
  121.         $args func_get_args();
  122.         return call_user_func_array(array&$this'supportedExtension')$args);
  123.     }
  124.  
  125.     /**
  126.     * Determines if the version is supported
  127.     *
  128.     * @param array $versions Versions to check
  129.     *
  130.     * @access public
  131.     * @return boolean 
  132.     */
  133.     public function supportedVersion($versions)
  134.     {
  135.         return $this->_checkAttr($versions'supportedLDAPVersion');
  136.     }
  137.  
  138.     /**
  139.     * Alias function of supportedVersion() for perl-ldap interface
  140.     *
  141.     * @see supportedVersion()
  142.     */
  143.     public function supported_version()
  144.     {
  145.         $args func_get_args();
  146.         return call_user_func_array(array(&$this'supportedVersion')$args);
  147.     }
  148.  
  149.     /**
  150.     * Determines if the control is supported
  151.     *
  152.     * @param array $oids Control oids to check
  153.     *
  154.     * @access public
  155.     * @return boolean 
  156.     */
  157.     public function supportedControl($oids)
  158.     {
  159.         return $this->_checkAttr($oids'supportedControl');
  160.     }
  161.  
  162.     /**
  163.     * Alias function of supportedControl() for perl-ldap interface
  164.     *
  165.     * @see supportedControl()
  166.     */
  167.     public function supported_control()
  168.     {
  169.         $args func_get_args();
  170.         return call_user_func_array(array(&$this'supportedControl' )$args);
  171.     }
  172.  
  173.     /**
  174.     * Determines if the sasl mechanism is supported
  175.     *
  176.     * @param array $mechlist SASL mechanisms to check
  177.     *
  178.     * @access public
  179.     * @return boolean 
  180.     */
  181.     public function supportedSASLMechanism($mechlist)
  182.     {
  183.         return $this->_checkAttr($mechlist'supportedSASLMechanisms');
  184.     }
  185.  
  186.     /**
  187.     * Alias function of supportedSASLMechanism() for perl-ldap interface
  188.     *
  189.     * @see supportedSASLMechanism()
  190.     */
  191.     public function supported_sasl_mechanism()
  192.     {
  193.         $args func_get_args();
  194.         return call_user_func_array(array(&$this'supportedSASLMechanism')$args);
  195.     }
  196.  
  197.     /**
  198.     * Checks for existance of value in attribute
  199.     *
  200.     * @param array  $values values to check
  201.     * @param string $attr   attribute name
  202.     *
  203.     * @access protected
  204.     * @return boolean 
  205.     */
  206.     public function _checkAttr($values$attr)
  207.     {
  208.         if (!is_array($values)) $values = array($values);
  209.  
  210.         foreach ($values as $value{
  211.             if (!@in_array($value$this->get_value($attr'all'))) {
  212.                 return false;
  213.             }
  214.         }
  215.         return true;
  216.     }
  217. }
  218.  
  219. ?>

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