You are here

protected function SimpleLdapServer::type in Simple LDAP 7

Same name and namespace in other branches
  1. 7.2 SimpleLdapServer.class.php \SimpleLdapServer::type()

Attempts to detect the directory type using the rootDSE.

1 call to SimpleLdapServer::type()
SimpleLdapServer::__get in ./SimpleLdapServer.class.php
Magic __get() function.

File

./SimpleLdapServer.class.php, line 766
Class to handle LDAP server connections and related operations.

Class

SimpleLdapServer
Simple LDAP server class.

Code

protected function type() {

  // If the type has already been determined, return it.
  if (isset($this->type)) {
    return $this->type;
  }
  try {

    // Load the rootDSE.
    $this
      ->rootdse();

    // Check for OpenLDAP.
    if (isset($this->rootdse['objectclass']) && is_array($this->rootdse['objectclass'])) {
      if (in_array('OpenLDAProotDSE', $this->rootdse['objectclass'])) {
        $this->type = 'OpenLDAP';
        return $this->type;
      }
    }

    // Check for Active Directory.
    if (isset($this->rootdse['rootdomainnamingcontext'])) {
      $this->type = 'Active Directory';
      return $this->type;
    }
  } catch (SimpleLdapException $e) {
  }

  // Default to generic LDAPv3.
  $this->type = 'LDAP';
  return $this->type;
}