3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Ldap\Node
;
15 * Zend\Ldap\Node\RootDse provides a simple data-container for the RootDse node.
17 class RootDse
extends AbstractNode
19 const SERVER_TYPE_GENERIC
= 1;
20 const SERVER_TYPE_OPENLDAP
= 2;
21 const SERVER_TYPE_ACTIVEDIRECTORY
= 3;
22 const SERVER_TYPE_EDIRECTORY
= 4;
25 * Factory method to create the RootDse.
27 * @param \Zend\Ldap\Ldap $ldap
30 public static function create(Ldap\Ldap
$ldap)
32 $dn = Ldap\Dn
::fromString('');
33 $data = $ldap->getEntry($dn, array('*', '+'), true);
34 if (isset($data['domainfunctionality'])) {
35 return new RootDse\
ActiveDirectory($dn, $data);
36 } elseif (isset($data['dsaname'])) {
37 return new RootDse\
eDirectory($dn, $data);
38 } elseif (isset($data['structuralobjectclass'])
39 && $data['structuralobjectclass'][0] === 'OpenLDAProotDSE'
41 return new RootDse\
OpenLdap($dn, $data);
44 return new static($dn, $data);
50 * Constructor is protected to enforce the use of factory methods.
52 * @param \Zend\Ldap\Dn $dn
55 protected function __construct(Ldap\Dn
$dn, array $data)
57 parent
::__construct($dn, $data, true);
61 * Gets the namingContexts.
65 public function getNamingContexts()
67 return $this->getAttribute('namingContexts', null);
71 * Gets the subschemaSubentry.
75 public function getSubschemaSubentry()
77 return $this->getAttribute('subschemaSubentry', 0);
81 * Determines if the version is supported
83 * @param string|int|array $versions version(s) to check
86 public function supportsVersion($versions)
88 return $this->attributeHasValue('supportedLDAPVersion', $versions);
92 * Determines if the sasl mechanism is supported
94 * @param string|array $mechlist SASL mechanisms to check
97 public function supportsSaslMechanism($mechlist)
99 return $this->attributeHasValue('supportedSASLMechanisms', $mechlist);
103 * Gets the server type
107 public function getServerType()
109 return self
::SERVER_TYPE_GENERIC
;
113 * Returns the schema DN
115 * @return \Zend\Ldap\Dn
117 public function getSchemaDn()
119 $schemaDn = $this->getSubschemaSubentry();
120 return Ldap\Dn
::fromString($schemaDn);