1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4: */
3/**
4* RootDSE.php
5*
6* PHP version 4, 5
7*
8* @category  Net
9* @package   Net_LDAP
10* @author    Tarjej Huse <tarjei@bergfald.no>
11* @author    Jan Wagner <wagner@netsols.de>
12* @author    Del <del@babel.com.au>
13* @author    Benedikt Hallinger <beni@php.net>
14* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger
15* @license   http://www.gnu.org/copyleft/lesser.html LGPL
16* @version   CVS: $Id: RootDSE.php,v 1.12 2008/10/26 15:31:06 clockwerx Exp $
17* @link      http://pear.php.net/package/Net_LDAP/
18*/
19require_once 'PEAR.php';
20
21/**
22* Getting the rootDSE entry of a LDAP server
23*
24* @category Net
25* @package  Net_LDAP
26* @author   Jan Wagner <wagner@netsols.de>
27* @license  http://www.gnu.org/copyleft/lesser.html LGPL
28* @link     http://pear.php.net/package/Net_LDAP/
29*/
30class Net_LDAP_RootDSE extends PEAR
31{
32    /**
33    * @access private
34    * @var object Net_LDAP_Entry
35    **/
36    var $_entry;
37
38    /**
39    * Class constructor
40    *
41    * @param Net_LDAP_Entry &$entry Net_LDAP_Entry object
42    */
43    function Net_LDAP_RootDSE(&$entry)
44    {
45        $this->_entry = $entry;
46    }
47
48    /**
49    * Gets the requested attribute value
50    *
51    * Same usuage as {@link Net_LDAP_Entry::getValue()}
52    *
53    * @param string $attr    Attribute name
54    * @param array  $options Array of options
55    *
56    * @access public
57    * @return mixed Net_LDAP_Error object or attribute values
58    * @see Net_LDAP_Entry::get_value()
59    */
60    function getValue($attr = '', $options = '')
61    {
62        return $this->_entry->get_value($attr, $options);
63    }
64
65    /**
66    * Alias function of getValue() for perl-ldap interface
67    *
68    * @see getValue()
69    */
70    function get_value()
71    {
72        $args = func_get_args();
73        return call_user_func_array(array( &$this, 'getValue' ), $args);
74    }
75
76    /**
77    * Determines if the extension is supported
78    *
79    * @param array $oids Array of oids to check
80    *
81    * @access public
82    * @return boolean
83    */
84    function supportedExtension($oids)
85    {
86        return $this->_checkAttr($oids, 'supportedExtension');
87    }
88
89    /**
90    * Alias function of supportedExtension() for perl-ldap interface
91    *
92    * @see supportedExtension()
93    */
94    function supported_extension()
95    {
96        $args = func_get_args();
97        return call_user_func_array(array( &$this, 'supportedExtension'), $args);
98    }
99
100    /**
101    * Determines if the version is supported
102    *
103    * @param array $versions Versions to check
104    *
105    * @access public
106    * @return boolean
107    */
108    function supportedVersion($versions)
109    {
110        return $this->_checkAttr($versions, 'supportedLDAPVersion');
111    }
112
113    /**
114    * Alias function of supportedVersion() for perl-ldap interface
115    *
116    * @see supportedVersion()
117    */
118    function supported_version()
119    {
120        $args = func_get_args();
121        return call_user_func_array(array(&$this, 'supportedVersion'), $args);
122    }
123
124    /**
125    * Determines if the control is supported
126    *
127    * @param array $oids Control oids to check
128    *
129    * @access public
130    * @return boolean
131    */
132    function supportedControl($oids)
133    {
134        return $this->_checkAttr($oids, 'supportedControl');
135    }
136
137    /**
138    * Alias function of supportedControl() for perl-ldap interface
139    *
140    * @see supportedControl()
141    */
142    function supported_control()
143    {
144        $args = func_get_args();
145        return call_user_func_array(array(&$this, 'supportedControl' ), $args);
146    }
147
148    /**
149    * Determines if the sasl mechanism is supported
150    *
151    * @param array $mechlist SASL mechanisms to check
152    *
153    * @access public
154    * @return boolean
155    */
156    function supportedSASLMechanism($mechlist)
157    {
158        return $this->_checkAttr($mechlist, 'supportedSASLMechanisms');
159    }
160
161    /**
162    * Alias function of supportedSASLMechanism() for perl-ldap interface
163    *
164    * @see supportedSASLMechanism()
165    */
166    function supported_sasl_mechanism()
167    {
168        $args = func_get_args();
169        return call_user_func_array(array(&$this, 'supportedSASLMechanism'), $args);
170    }
171
172    /**
173    * Checks for existance of value in attribute
174    *
175    * @param array  $values values to check
176    * @param string $attr   attribute name
177    *
178    * @access private
179    * @return boolean
180    */
181    function _checkAttr($values, $attr)
182    {
183        if (!is_array($values)) $values = array($values);
184
185        foreach ($values as $value) {
186            if (!@in_array($value, $this->get_value($attr, 'all'))) {
187                return false;
188            }
189        }
190        return true;
191    }
192}
193
194?>
195