protected function SimpleLdapServerSchema::loadSchema in Simple LDAP 8
Load the schema.
Schema parsing can be slow, so only the attributes that are specified, and are not already cached, are loaded.
Parameters
array $attributes: A list of attributes to load. If not specified, all attributes are loaded.
Throws
1 call to SimpleLdapServerSchema::loadSchema()
- SimpleLdapServerSchema::schemaItemExists in src/
SimpleLdapServerSchema.php - Returns whether the given item exists.
File
- src/
SimpleLdapServerSchema.php, line 122 - Contains \Drupal\simple_ldap\SimpleLdapServerSchema
Class
Namespace
Drupal\simple_ldapCode
protected function loadSchema(array $attributes = array()) {
$this->server
->bind();
// If no attributes are specified, default to all attributes.
if (empty($attributes)) {
$attributes = $this
->getAllAttributeNames();
}
// Determine which attributes need to be loaded.
$load = array();
foreach ($attributes as $attribute) {
$attribute = mb_strtolower($attribute);
if (!isset($this->schema[$attribute])) {
$load[] = $attribute;
}
}
if (!empty($load)) {
$result = $this->server
->search($this->dn, 'objectclass=*', 'base', $load);
// Parse the schema.
foreach ($load as $attribute) {
$attribute = mb_strtolower($attribute);
$this->schema[$attribute] = array();
// Get the values for each attribute.
if (isset($result[$this->dn][$attribute])) {
foreach ($result[$this->dn][$attribute] as $value) {
$parsed = $this
->parseSchemaValue($value);
$this->schema[$attribute][mb_strtolower($parsed['name'])] = $parsed;
}
}
}
}
}