LDAP Account Manager

schema.inc

Interfaces, Classes, Traits and Enums

SchemaItem
Generic parent class for all schema items. A schema item is an ObjectClass, an AttributeBype, a MatchingRule, or a Syntax.
ObjectClass
Represents an LDAP objectClass
ObjectClassAttribute
A simple class for representing AttributeTypes used only by the ObjectClass class.
AttributeType
Represents an LDAP AttributeType
Syntax
Represents an LDAP Syntax
MatchingRule
Represents an LDAP MatchingRule
MatchingRuleUse
Represents an LDAP schema matchingRuleUse entry

Table of Contents

_get_schema_dn()  : string|false
Helper for _get_raw_schema() which fetches the DN of the schema object in an LDAP server based on a DN. Entries should set the subSchemaSubEntry attribute pointing to the DN of the server schema. You can specify the DN whose subSchemaSubEntry you wish to retrieve of specify an empty string to fetch the subScehamSubEntry from the Root DSE.
_get_raw_schema()  : array<string|int, string>|false
Fetches the raw schema array for the subschemaSubentry of the server. Note, this function has grown many hairs to accommodate more LDAP servers. It is needfully complicated as it now supports many popular LDAP servers that don't necessarily expose their schema "the right way".
get_schema_objectclasses()  : array<string|int, ObjectClass>|false
Gets an associative array of ObjectClass objects for the specified server. Each array entry's key is the name of the objectClass in lower-case and the value is an ObjectClass object.
get_schema_objectclass()  : ObjectClass|false
Gets a single ObjectClass object specified by name.
get_schema_attributes()  : array<string|int, AttributeType>|false
Gets an associative array of AttributeType objects for the specified server. Each array entry's key is the name of the attributeType in lower-case and the value is an AttributeType object.
add_aliases_to_attrs()  : void
For each attribute that has multiple names, this function adds unique entries to the attrs array for those names. Ie, attributeType has name 'gn' and 'givenName'.
add_sup_to_attrs()  : void
Adds inherited values to each attributeType specified by the SUP directive.
get_schema_matching_rules()  : array<string|int, MatchingRule>|false
get_schema_syntaxes()  : array<string|int, Syntax>|false
cached_schema_available()  : bool
get_cached_schema()  : array<string|int, SchemaItem>|false
Returns the cached array of schemaitem objects for the specified $schema_type. For list of valid $schema_type values, see above schema_cache_available(). Note that internally, this function utilizes a two-layer cache, one in memory using a static variable for multiple calls within the same page load, and one in a session for multiple calls within the same user session (spanning multiple page loads).
set_cached_schema()  : void
Caches the specified $schema_type.
set_schema_cache_unavailable()  : void
Sets the schema entry for the server_id to be "unavailable" so that we realize that we tried to get the schema but could not, so quit trying next time to fetch it from the server.

Functions

_get_schema_dn()

Helper for _get_raw_schema() which fetches the DN of the schema object in an LDAP server based on a DN. Entries should set the subSchemaSubEntry attribute pointing to the DN of the server schema. You can specify the DN whose subSchemaSubEntry you wish to retrieve of specify an empty string to fetch the subScehamSubEntry from the Root DSE.

_get_schema_dn(string $dn[, bool $debug = false ]) : string|false
Parameters
$dn : string

the DN (may be null) which houses the subschemaSubEntry attribute which this function can use to determine the schema entry's DN.

$debug : bool = false

switch to true to see some nice and copious output. :)

Return values
string|false

the DN of the entry which houses this LDAP server's schema.

_get_raw_schema()

Fetches the raw schema array for the subschemaSubentry of the server. Note, this function has grown many hairs to accommodate more LDAP servers. It is needfully complicated as it now supports many popular LDAP servers that don't necessarily expose their schema "the right way".

_get_raw_schema(string $schema_to_fetch[, string $dn = '' ]) : array<string|int, string>|false
Parameters
$schema_to_fetch : string
  • A string indicating which type of schema to fetch. Five valid values: 'objectclasses', 'attributetypes', 'ldapsyntaxes', 'matchingruleuse', or 'matchingrules'. Case insensitive.
$dn : string = ''

(optional) This parameter is the DN of the entry whose schema you would like to fetch. Entries have the option of specifying their own subschemaSubentry that points to the DN of the system schema entry which applies to this attribute. If unspecified, this will try to retrieve the schema from the RootDSE subschemaSubentry. Failing that, we use some commonly known schema DNs. Default value is the Root DSE DN (zero-length string)

Return values
array<string|int, string>|false

an array of strings of this form: Array ( [0] => "( 1.3.6.1.4.1.7165.1.2.2.4 NAME 'gidPool' DESC 'Pool ... [1] => "( 1.3.6.1.4.1.7165.2.2.3 NAME 'sambaAccount' DESC 'Sa ... etc.

get_schema_objectclasses()

Gets an associative array of ObjectClass objects for the specified server. Each array entry's key is the name of the objectClass in lower-case and the value is an ObjectClass object.

get_schema_objectclasses([string $dn = null ][, bool $use_cache = true ]) : array<string|int, ObjectClass>|false
Parameters
$dn : string = null

(optional) It is easier to fetch schema if a DN is provided which defines the subschemaSubEntry attribute (all entries should).

$use_cache : bool = true

use cache

Tags
see
ObjectClass
see
get_schema_objectclass
Return values
array<string|int, ObjectClass>|false

An array of ObjectClass objects.

get_schema_objectclass()

Gets a single ObjectClass object specified by name.

get_schema_objectclass(string $oclass_name[, string $dn = null ][, bool $use_cache = true ]) : ObjectClass|false
Parameters
$oclass_name : string

The name of the objectClass to fetch.

$dn : string = null

(optional) It is easier to fetch schema if a DN is provided which defines the subschemaSubEntry attribute (all entries should).

$use_cache : bool = true

use cache

Tags
see
ObjectClass
see
get_schema_objectclasses
Return values
ObjectClass|false

The specified ObjectClass object or false on error.

get_schema_attributes()

Gets an associative array of AttributeType objects for the specified server. Each array entry's key is the name of the attributeType in lower-case and the value is an AttributeType object.

get_schema_attributes([string $dn = null ][, bool $use_cache = true ]) : array<string|int, AttributeType>|false
Parameters
$dn : string = null

(optional) It is easier to fetch schema if a DN is provided which defines the subschemaSubEntry attribute (all entries should).

$use_cache : bool = true

use cache

Return values
array<string|int, AttributeType>|false

an array of AttributeType objects.

add_aliases_to_attrs()

For each attribute that has multiple names, this function adds unique entries to the attrs array for those names. Ie, attributeType has name 'gn' and 'givenName'.

add_aliases_to_attrs(array<string|int, AttributeType&$attrs) : void

This function will create a unique entry for 'gn' and 'givenName'.

Parameters
$attrs : array<string|int, AttributeType>

attributes

Return values
void

add_sup_to_attrs()

Adds inherited values to each attributeType specified by the SUP directive.

add_sup_to_attrs(array<string, AttributeType&$attrs, array<string, AttributeType&$attrs_oid) : void

Supports infinite levels of inheritance. Bug 856832: require a second parameter that has all attributes indexed by OID

Parameters
$attrs : array<string, AttributeType>

attributes

$attrs_oid : array<string, AttributeType>

attributes by OIDs

Return values
void

get_schema_matching_rules()

get_schema_matching_rules([string $dn = null ][, bool $use_cache = true ]) : array<string|int, MatchingRule>|false
Parameters
$dn : string = null

DN

$use_cache : bool = true

use cache

Return values
array<string|int, MatchingRule>|false

Returns an array of MatchingRule objects for the specified server. The key of each entry is the OID of the matching rule.

get_schema_syntaxes()

get_schema_syntaxes([string $dn = null ][, bool $use_cache = true ]) : array<string|int, Syntax>|false
Parameters
$dn : string = null

DN

$use_cache : bool = true

use cache

Return values
array<string|int, Syntax>|false

returns an array of Syntax objects that this LDAP server uses mapped to their descriptions. The key of each entry is the OID of the Syntax.

cached_schema_available()

cached_schema_available(string $schema_type) : bool
Parameters
$schema_type : string

type

Return values
bool

returns true if the schema for $schema_type has been cached and is available. $schema_type may be one of (lowercase) the following: objectclasses attributetypes ldapsyntaxes matchingrules matchingruleuse Note that _get_raw_schema() takes a similar parameter.

get_cached_schema()

Returns the cached array of schemaitem objects for the specified $schema_type. For list of valid $schema_type values, see above schema_cache_available(). Note that internally, this function utilizes a two-layer cache, one in memory using a static variable for multiple calls within the same page load, and one in a session for multiple calls within the same user session (spanning multiple page loads).

get_cached_schema(string $schema_type) : array<string|int, SchemaItem>|false
Parameters
$schema_type : string

type

Return values
array<string|int, SchemaItem>|false

returns an array of SchemaItem objects on success or false on failure.

set_cached_schema()

Caches the specified $schema_type.

set_cached_schema(string $schema_type, array<string|int, SchemaItem$schema_items) : void

$schema_items should be an array of SchemaItem instances (ie, an array of ObjectClass, AttributeType, LDAPSyntax, MatchingRuleUse, or MatchingRule objects.

Parameters
$schema_type : string

type

$schema_items : array<string|int, SchemaItem>

items

Return values
void

set_schema_cache_unavailable()

Sets the schema entry for the server_id to be "unavailable" so that we realize that we tried to get the schema but could not, so quit trying next time to fetch it from the server.

set_schema_cache_unavailable() : void
Return values
void

Search results