lib

# Procedural File: schema.inc

Source Location: /lib/schema.inc

## Classes:

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

## Page Details:

Classes and functions for fetching and parsing schema from an LDAP server.

#### Tags:

author: | The phpLDAPadmin development team
author: | Roland Gruber

### SCHEMA_SESSION_CACHE_ENABLED [line 34]

`SCHEMA_SESSION_CACHE_ENABLED = 1`

To enable/disable session-based schema caching (1: enabled, 0: disabled).
[ Top ]

### add_aliases_to_attrs [line 1702]

`void add_aliases_to_attrs( &$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'.

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

#### Parameters

| &$attrs |

[ Top ]

### add_sup_to_attrs [line 1727]

`void add_sup_to_attrs( &$attrs, &$attrs_oid)`

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

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

#### Parameters

| &$attrs |
| &$attrs_oid |

[ Top ]

### cached_schema_available [line 1936]

`void cached_schema_available( $schema_type)`

Returns true if the schema for $schema_type has been cached and

is availble. $schema_type may be one of (lowercase) the following: objectclasses attributetypes ldapsyntaxes matchingrules matchingruleuse Note that _get_raw_schema() takes a similar parameter.

#### Parameters

| $schema_type |

[ Top ]

### get_cached_schema [line 1973]

`void get_cached_schema( $schema_type)`

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).

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

#### Parameters

| $schema_type |

[ Top ]

### get_schema_attribute [line 1589]

`AttributeType get_schema_attribute( $attr_name, [string $dn = null], [ $use_cache = true], string $oclass_name)`

Gets a single AttributeType object specified by name.

#### Tags:

return: | The specified AttributeType object or false on error.
see: | get_schema_attributes()
see: | AttributeType

#### Parameters

string | $oclass_name | The name of the AttributeType to fetch.
string | $dn | (optional) It is easier to fetch schema if a DN is provided which defines the subschemaSubEntry attribute (all entries should).
| $attr_name |
| $use_cache |

[ Top ]

### get_schema_attributes [line 1610]

`array get_schema_attributes( [string $dn = null], [ $use_cache = true])`

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.

#### Tags:

return: | An array of AttributeType objects.

#### Parameters

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

[ Top ]

### get_schema_matching_rules [line 1841]

`void get_schema_matching_rules( [ $dn = null], [ $use_cache = true])`

Returns an array of MatchingRule objects for the specified server.

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

#### Parameters

| $dn |
| $use_cache |

[ Top ]

### get_schema_objectclass [line 1565]

`ObjectClass get_schema_objectclass( string $oclass_name, [string $dn = null], [ $use_cache = true])`

Gets a single ObjectClass object specified by name.

#### Tags:

return: | The specified ObjectClass object or false on error.
see: | get_schema_objectclasses()
see: | ObjectClass

#### Parameters

string | $oclass_name | The name of the objectClass to fetch.
string | $dn | (optional) It is easier to fetch schema if a DN is provided which defines the subschemaSubEntry attribute (all entries should).
| $use_cache |

[ Top ]

### get_schema_objectclasses [line 1525]

`array get_schema_objectclasses( [string $dn = null], [ $use_cache = true])`

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.

#### Tags:

return: | An array of ObjectClass objects.
see: | get_schema_objectclass()
see: | ObjectClass

#### Parameters

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

[ Top ]

### get_schema_syntaxes [line 1895]

`void get_schema_syntaxes( [ $dn = null], [ $use_cache = true])`

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.

#### Parameters

| $dn |
| $use_cache |

[ Top ]

### set_cached_schema [line 2004]

`void set_cached_schema( $schema_type, $schema_items)`

Caches the specified $schema_type.

$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 |
| $schema_items |

[ Top ]

### set_schema_cache_unavailable [line 2033]

`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.
[ Top ]

### _get_raw_schema [line 1334]

`an _get_raw_schema( $schema_to_fetch $schema_to_fetch, [$dn $dn = ''])`

Fetches the raw schema array for the subschemaSubentry of the server. Note, this function has grown many hairs to accomodate 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".

#### Tags:

return: | 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.

#### Parameters

$schema_to_fetch | $schema_to_fetch | - A string indicating which type of schema to fetch. Five valid values: 'objectclasses', 'attributetypes', 'ldapsyntaxes', 'matchingruleuse', or 'matchingrules'. Case insensitive.

$dn

$dn

(optional) This paremeter 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)

[ Top ]

### _get_schema_dn [line 1267]

`string _get_schema_dn( string $dn, [bool $debug = 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.

#### Tags:

return: | The DN of the entry which houses this LDAP server's schema.

#### Parameters

string | $dn | The DN (may be null) which houses the subschemaSubEntry attribute which this function can use to determine the schema entry's DN.
bool | $debug | Switch to true to see some nice and copious output. :)

[ Top ]

Documentation generated on Wed, 05 Aug 2009 19:53:07 +0200 by phpDocumentor 1.4.1