You are here

public function SimpleLdapSchema::get in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 SimpleLdapSchema.class.php \SimpleLdapSchema::get()

Fetches entries of the given type.

@throw SimpleLdapException

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.

5 calls to SimpleLdapSchema::get()
SimpleLdapSchema::auxiliary in ./SimpleLdapSchema.class.php
Return a list of auxiliary object classes.
SimpleLdapSchema::may in ./SimpleLdapSchema.class.php
Return a list of attributes specified as MAY for the objectclass.
SimpleLdapSchema::must in ./SimpleLdapSchema.class.php
Return a list of attributes specified as MUST for the objectclass.
SimpleLdapSchema::structural in ./SimpleLdapSchema.class.php
Return a list of structural object classes.
SimpleLdapSchema::superclass in ./SimpleLdapSchema.class.php
Returns the objectclass's superclass.

File

./SimpleLdapSchema.class.php, line 140
Class to represent an LDAP server schema.

Class

SimpleLdapSchema
Simple LDAP Schema class.

Code

public function get($attribute, $name = NULL) {
  if ($this
    ->exists($attribute, $name)) {
    $attribute = drupal_strtolower($attribute);
    if ($name === NULL) {
      return $this->schema[$attribute];
    }
    else {
      $name = drupal_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 (drupal_strtolower($alias) == drupal_strtolower($name)) {
              return $attr;
            }
          }
          if ($attr['oid'] == $name) {
            return $attr;
          }
        }
      }
    }
  }
  watchdog('Simple LDAP', 'The requested entry %attribute (@name) does not exist.', array(
    '%attribute' => $attribute,
    '@name' => $name,
  ), WATCHDOG_ERROR);
  if (user_access('administer site configuration')) {
    drupal_set_message(t('The requested entry %attribute (@name) does not exist.', array(
      '%attribute' => $attribute,
      '@name' => $name,
    )), 'error');
  }

  //throw new SimpleLdapException('The requested entry does not exist: ' . $attribute . ', ' . $name);
}