You are here

public function SimpleLdapServerSchema::getSchemaItem in Simple LDAP 8

Fetches entries of the given type.

Parameters

string $attribute: Name of the schema attribute type to return.

string $name: If specified, a single entry with this name or OID is returned.

Return value

array The requested attribute list or entry.

Throws

SimpleLdapException

2 calls to SimpleLdapServerSchema::getSchemaItem()
SimpleLdapServerSchema::getMayAttributes in src/SimpleLdapServerSchema.php
Return a list of attributes specified as MAY for the objectclass.
SimpleLdapServerSchema::getMustAttributes in src/SimpleLdapServerSchema.php
Return a list of attributes specified as MUST for the objectclass.

File

src/SimpleLdapServerSchema.php, line 79
Contains \Drupal\simple_ldap\SimpleLdapServerSchema

Class

SimpleLdapServerSchema

Namespace

Drupal\simple_ldap

Code

public function getSchemaItem($attribute, $name = NULL) {
  if ($this
    ->schemaItemExists($attribute, $name)) {
    $attribute = mb_strtolower($attribute);
    if ($name === NULL) {
      return $this->schema[$attribute];
    }
    else {
      $name = mb_strtolower($name);
      if (isset($this->schema[$attribute][$name])) {

        // Return a named attribute.
        return $this->schema[$attribute][$name];
      }
      else {

        // Search for an alias or OID.
        foreach ($this->schema[$attribute] as $attr) {
          foreach ($attr['aliases'] as $alias) {
            if (mb_strtolower($alias) == mb_strtolower($name)) {
              return $attr;
            }
          }
          if ($attr['oid'] == $name) {
            return $attr;
          }
        }
      }
    }
  }
  throw new SimpleLdapException('The requested entry does not exist: ' . $attribute . ', ' . $name, '');
}