So I’ve been trying to find a good way to discover the schema path in LDAP that would work across Netscape style ldap servers as well as Active Directory. See the problem is each one hides their schema path in a different place. Netscap style servers (Redhat-DS, Project 389, iPlanet, Sun One, etc) use ‘cn=schema’, while openldap has been known to use ‘cn=subschema’ and Active Directory uses 'CN=Schema, CN= Configuration, DC=forest_root_domain' this makes it really difficult to create a universal tool that can find any schema path. In the past I would lift code from the PhpLDAPAdmin tool, but even they changed their methods. Usually you get stuck using several case statements. Recently I discovered a way to do a query to the Root DSE and have it just tell you where it has stored it’s schema data. Use the subschemaSubentry to tell you exactly where the schema path is.
Here is an example of how to get it in PHP
$checkDN = @ldap_read($this->database, ”, ‘objectClass=*’);
$schemaEntry = ldap_get_entries($this->database, $checkDN);
$SchemaDN = $schemaEntry[‘subschemaSubentry’];