/** * Constructor. * * Fetches the Schema from an LDAP connection. * * @param Horde_Ldap $ldap LDAP connection. * @param string $dn Subschema entry DN. * * @throws Horde_Ldap_Exception */ public function __construct(Horde_Ldap $ldap, $dn = null) { if (is_null($dn)) { // Get the subschema entry via rootDSE. $dse = $ldap->rootDSE(array('subschemaSubentry')); $base = $dse->getValue('subschemaSubentry', 'single'); $dn = $base; } // Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that // incorrectly call this entry subSchemaSubentry instead of // subschemaSubentry. Note the correct case/spelling as per RFC 2251. if (is_null($dn)) { // Get the subschema entry via rootDSE. $dse = $ldap->rootDSE(array('subSchemaSubentry')); $base = $dse->getValue('subSchemaSubentry', 'single'); $dn = $base; } // Final fallback in case there is no subschemaSubentry attribute in // the root DSE (this is a bug for an LDAPv3 server so report this to // your LDAP vendor if you get this far). if (is_null($dn)) { $dn = 'cn=Subschema'; } // Fetch the subschema entry. $result = $ldap->search($dn, '(objectClass=*)', array('attributes' => array_values($this->types), 'scope' => 'base')); $entry = $result->shiftEntry(); if (!$entry instanceof Horde_Ldap_Entry) { throw new Horde_Ldap_Exception('Could not fetch Subschema entry'); } $this->parse($entry); }
/** * Tests retrieval of root DSE object. */ public function testRootDSE() { $ldap = new Horde_Ldap(self::$ldapcfg['server']); $this->assertInstanceOf('Horde_Ldap_RootDse', $ldap->rootDSE()); }