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
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()  : an
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>
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
Gets a single ObjectClass object specified by name.
get_schema_attribute()  : AttributeType
Gets a single AttributeType object specified by name.
get_schema_attributes()  : array<string|int, mixed>
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()  : mixed
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()  : mixed
Adds inherited values to each attributeType specified by the SUP directive.
get_schema_matching_rules()  : mixed
Returns an array of MatchingRule objects for the specified server.
get_schema_syntaxes()  : mixed
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()  : mixed
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()  : mixed
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()  : mixed
Caches the specified $schema_type.
set_schema_cache_unavailable()  : mixed
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
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

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( $schema_to_fetch[,  $dn = '' ]) : an
Parameters
$schema_to_fetch :
  • A string indicating which type of schema to fetch. Five valid values: 'objectclasses', 'attributetypes', 'ldapsyntaxes', 'matchingruleuse', or 'matchingrules'. Case insensitive.
$dn : = ''

(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
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 ][, mixed $use_cache = true ]) : array<string|int, ObjectClass>
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 : mixed = true
Tags
see
ObjectClass
see
get_schema_objectclass
Return values
array<string|int, ObjectClass>

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 ][, mixed $use_cache = true ]) : ObjectClass
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 : mixed = true
Tags
see
ObjectClass
see
get_schema_objectclasses
Return values
ObjectClass

The specified ObjectClass object or false on error.

get_schema_attribute()

Gets a single AttributeType object specified by name.

get_schema_attribute(mixed $attr_name[, string $dn = null ][, mixed $use_cache = true ]) : AttributeType
Parameters
$attr_name : mixed
$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 : mixed = true
Tags
see
AttributeType
see
get_schema_attributes
Return values
AttributeType

The specified AttributeType 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 ][, mixed $use_cache = true ]) : array<string|int, mixed>
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 : mixed = true
Return values
array<string|int, mixed>

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(mixed &$attrs) : mixed

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

Parameters
$attrs : mixed
Return values
mixed

add_sup_to_attrs()

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

add_sup_to_attrs(mixed &$attrs, mixed &$attrs_oid) : mixed

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

Parameters
$attrs : mixed
$attrs_oid : mixed
Return values
mixed

get_schema_matching_rules()

Returns an array of MatchingRule objects for the specified server.

get_schema_matching_rules([mixed $dn = null ][, mixed $use_cache = true ]) : mixed

The key of each entry is the OID of the matching rule.

Parameters
$dn : mixed = null
$use_cache : mixed = true
Return values
mixed

get_schema_syntaxes()

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.

get_schema_syntaxes([mixed $dn = null ][, mixed $use_cache = true ]) : mixed
Parameters
$dn : mixed = null
$use_cache : mixed = true
Return values
mixed

cached_schema_available()

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.

cached_schema_available(mixed $schema_type) : mixed
Parameters
$schema_type : mixed
Return values
mixed

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(mixed $schema_type) : mixed

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

Parameters
$schema_type : mixed
Return values
mixed

set_cached_schema()

Caches the specified $schema_type.

set_cached_schema(mixed $schema_type, mixed $schema_items) : mixed

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

Returns true on success of false on failure.

Parameters
$schema_type : mixed
$schema_items : mixed
Return values
mixed

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() : mixed
Return values
mixed

Search results