File indexing completed on 2024-12-22 05:36:48
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Ldap 0017 * @subpackage RootDSE 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Ldap_Node_Abstract 0025 */ 0026 // require_once 'Zend/Ldap/Node/Abstract.php'; 0027 0028 /** 0029 * Zend_Ldap_Node_RootDse provides a simple data-container for the RootDSE node. 0030 * 0031 * @category Zend 0032 * @package Zend_Ldap 0033 * @subpackage RootDSE 0034 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0035 * @license http://framework.zend.com/license/new-bsd New BSD License 0036 */ 0037 class Zend_Ldap_Node_RootDse extends Zend_Ldap_Node_Abstract 0038 { 0039 const SERVER_TYPE_GENERIC = 1; 0040 const SERVER_TYPE_OPENLDAP = 2; 0041 const SERVER_TYPE_ACTIVEDIRECTORY = 3; 0042 const SERVER_TYPE_EDIRECTORY = 4; 0043 0044 /** 0045 * Factory method to create the RootDSE. 0046 * 0047 * @param Zend_Ldap $ldap 0048 * @return Zend_Ldap_Node_RootDse 0049 * @throws Zend_Ldap_Exception 0050 */ 0051 public static function create(Zend_Ldap $ldap) 0052 { 0053 $dn = Zend_Ldap_Dn::fromString(''); 0054 $data = $ldap->getEntry($dn, array('*', '+'), true); 0055 if (isset($data['domainfunctionality'])) { 0056 /** 0057 * @see Zend_Ldap_Node_RootDse_ActiveDirectory 0058 */ 0059 // require_once 'Zend/Ldap/Node/RootDse/ActiveDirectory.php'; 0060 return new Zend_Ldap_Node_RootDse_ActiveDirectory($dn, $data); 0061 } else if (isset($data['dsaname'])) { 0062 /** 0063 * @see Zend_Ldap_Node_RootDse_ActiveDirectory 0064 */ 0065 // require_once 'Zend/Ldap/Node/RootDse/eDirectory.php'; 0066 return new Zend_Ldap_Node_RootDse_eDirectory($dn, $data); 0067 } else if (isset($data['structuralobjectclass']) && 0068 $data['structuralobjectclass'][0] === 'OpenLDAProotDSE') { 0069 /** 0070 * @see Zend_Ldap_Node_RootDse_OpenLdap 0071 */ 0072 // require_once 'Zend/Ldap/Node/RootDse/OpenLdap.php'; 0073 return new Zend_Ldap_Node_RootDse_OpenLdap($dn, $data); 0074 } else { 0075 return new self($dn, $data); 0076 } 0077 } 0078 0079 /** 0080 * Constructor. 0081 * 0082 * Constructor is protected to enforce the use of factory methods. 0083 * 0084 * @param Zend_Ldap_Dn $dn 0085 * @param array $data 0086 */ 0087 protected function __construct(Zend_Ldap_Dn $dn, array $data) 0088 { 0089 parent::__construct($dn, $data, true); 0090 } 0091 0092 /** 0093 * Gets the namingContexts. 0094 * 0095 * @return array 0096 */ 0097 public function getNamingContexts() 0098 { 0099 return $this->getAttribute('namingContexts', null); 0100 } 0101 0102 /** 0103 * Gets the subschemaSubentry. 0104 * 0105 * @return string|null 0106 */ 0107 public function getSubschemaSubentry() 0108 { 0109 return $this->getAttribute('subschemaSubentry', 0); 0110 } 0111 0112 /** 0113 * Determines if the version is supported 0114 * 0115 * @param string|int|array $versions version(s) to check 0116 * @return boolean 0117 */ 0118 public function supportsVersion($versions) 0119 { 0120 return $this->attributeHasValue('supportedLDAPVersion', $versions); 0121 } 0122 0123 /** 0124 * Determines if the sasl mechanism is supported 0125 * 0126 * @param string|array $mechlist SASL mechanisms to check 0127 * @return boolean 0128 */ 0129 public function supportsSaslMechanism($mechlist) 0130 { 0131 return $this->attributeHasValue('supportedSASLMechanisms', $mechlist); 0132 } 0133 0134 /** 0135 * Gets the server type 0136 * 0137 * @return int 0138 */ 0139 public function getServerType() 0140 { 0141 return self::SERVER_TYPE_GENERIC; 0142 } 0143 0144 /** 0145 * Returns the schema DN 0146 * 0147 * @return Zend_Ldap_Dn 0148 */ 0149 public function getSchemaDn() 0150 { 0151 $schemaDn = $this->getSubschemaSubentry(); 0152 /** 0153 * @see Zend_Ldap_Dn 0154 */ 0155 // require_once 'Zend/Ldap/Dn.php'; 0156 return Zend_Ldap_Dn::fromString($schemaDn); 0157 } 0158 }