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.
Arguments
Name
Type
Description
Default
$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
Switch to true to see some nice and copious output. :)
false
Return value
Type
Description
string
The DN of the entry which houses this LDAP server's schema.
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".
Arguments
Name
Type
Description
Default
$schema_to_fetch
n/a
A string indicating which type of schema to
fetch. Five valid values: 'objectclasses', 'attributetypes',
'ldapsyntaxes', 'matchingruleuse', or 'matchingrules'.
Case insensitive.
$dn
n/a
(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)
''
Return value
Type
Description
\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.
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.
Arguments
Name
Type
Description
Default
$dn
string
(optional) It is easier to fetch schema if a DN is provided
which defines the subschemaSubEntry attribute (all entries should).
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.
Arguments
Name
Type
Description
Default
$dn
string
(optional) It is easier to fetch schema if a DN is provided
which defines the subschemaSubEntry attribute (all entries should).
null
$use_cache
n/a
true
Return value
Type
Description
array
An array of AttributeType objects.
add_aliases_to_attrs(
$attrs,
)
:
n/a
Description
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'.
Arguments
Name
Type
Description
Default
$attrs
n/a
Return value
Type
Description
n/a
n/a
add_sup_to_attrs(
$attrs,
$attrs_oid,
)
:
n/a
Description
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
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.
Arguments
Name
Type
Description
Default
$dn
n/a
null
$use_cache
n/a
true
Return value
Type
Description
n/a
n/a
cached_schema_available(
$schema_type,
)
:
n/a
Description
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.
Arguments
Name
Type
Description
Default
$schema_type
n/a
Return value
Type
Description
n/a
n/a
get_cached_schema(
$schema_type,
)
:
n/a
Description
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.
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.
Arguments
Name
Type
Description
Default
$schema_type
n/a
$schema_items
n/a
Return value
Type
Description
n/a
n/a
set_schema_cache_unavailable(
)
:
n/a
Description
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.
Generic parent class for all schema items. A schema item is
an ObjectClass, an AttributeBype, a MatchingRule, or a Syntax. All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.
Represents an LDAP objectClass All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.
Adds an objectClass to the list of objectClasses that inherit
from this objectClass.
Arguments
Name
Type
Description
Default
$object_class_name
String
The name of the objectClass to add
Return value
Type
Description
bool
Returns true on success or false on failure (objectclass already existed for example)
addMayAttrs(
array
$new_may_attrs,
)
:
n/a
Description
Behaves identically to addMustAttrs, but it operates on the MAY
attributes of this objectClass.
Arguments
Name
Type
Description
Default
$new_may_attrs
array
An array of attribute names (strings) to add.
Return value
Type
Description
n/a
n/a
addMustAttrs(
array
$new_must_attrs,
)
:
n/a
Description
Adds the specified array of attributes to this objectClass' list of
MUST attributes. The resulting array of must attributes will contain
unique members.
Arguments
Name
Type
Description
Default
$new_must_attrs
array
An array of attribute names (strings) to add.
Return value
Type
Description
n/a
n/a
getChildObjectClasses(
)
:
Array
Description
Returns the array of objectClass names which inherit from this objectClass.
Return value
Type
Description
Array
Names of objectClasses which inherit from this objectClass.
getIsObsolete(
)
:
n/a
Description
Gets whether this objectClass is flagged as obsolete by the LDAP server.
Gets an array of attribute names (strings) that entries of this ObjectClass must define. This differs from getMayAttrs in that it returns an array of strings rather than
array of AttributeType objects
Arguments
Name
Type
Description
Default
$oclasses
array
An array of ObjectClass objects to use when traversing
the inheritance tree. This presents some what of a bootstrapping problem
as we must fetch all objectClasses to determine through inheritance which
attributes this objectClass provides.
null
Return value
Type
Description
array
The array of allowed attribute names (strings).
Tags
Name
Description
see
see
see
getMayAttrs(
array
$oclasses
= NULL,
)
:
array
Description
Gets an array of AttributeType objects that entries of this ObjectClass may define. This differs from getMayAttrNames in that it returns an array of AttributeType objects
Arguments
Name
Type
Description
Default
$oclasses
array
An array of ObjectClass objects to use when traversing
the inheritance tree. This presents some what of a bootstrapping problem
as we must fetch all objectClasses to determine through inheritance which
attributes this objectClass provides.
Gets an array of attribute names (strings) that entries of this ObjectClass must define. This differs from getMustAttrs in that it returns an array of strings rather than
array of AttributeType objects
Arguments
Name
Type
Description
Default
$oclasses
array
An array of ObjectClass objects to use when traversing
the inheritance tree. This presents some what of a bootstrapping problem
as we must fetch all objectClasses to determine through inheritance which
attributes this objectClass provides.
null
Return value
Type
Description
array
The array of allowed attribute names (strings).
Tags
Name
Description
see
see
see
getMustAttrs(
array
$oclasses
= NULL,
)
:
array
Description
Gets an array of AttributeType objects that entries of this ObjectClass must define. This differs from getMustAttrNames in that it returns an array of AttributeType objects
Arguments
Name
Type
Description
Default
$oclasses
array
An array of ObjectClass objects to use when traversing
the inheritance tree. This presents some what of a bootstrapping problem
as we must fetch all objectClasses to determine through inheritance which
attributes this objectClass requires.
NULL
Return value
Type
Description
array
The array of required AttributeType objects.
Tags
Name
Description
see
see
see
getName(
)
:
string
Description
Gets the name of this objectClass (ie, "inetOrgPerson")
Return value
Type
Description
string
The name of the objectClass
getSupClasses(
)
:
array
Description
Gets the objectClass names from which this objectClass inherits.
Return value
Type
Description
array
An array of objectClass names (strings)
getType(
)
:
n/a
Description
Gets the type of this objectClass: STRUCTURAL, ABSTRACT, or AUXILIARY.
A simple class for representing AttributeTypes used only by the ObjectClass class. Users should never instantiate this class. It represents an attribute internal to
an ObjectClass. If PHP supported inner-classes and variable permissions, this would
be interior to class ObjectClass and flagged private. The reason this class is used
and not the "real" class AttributeType is because this class supports the notion of
a "source" objectClass, meaning that it keeps track of which objectClass originally
specified it. This class is therefore used by the class ObjectClass to determine
inheritance.
Represents an LDAP AttributeType All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.
Adds an objectClass name to this attribute's list of "used in" objectClasses,
that is the list of objectClasses which provide this attribute.
Arguments
Name
Type
Description
Default
$object_class_name
string
The name of the objectClass to add.
Return value
Type
Description
n/a
n/a
getAliases(
)
:
array
Description
Gets the names of attributes that are an alias for this attribute (if any).
Return value
Type
Description
array
An array of names of attributes which alias this attribute or
an empty array if no attribute aliases this object.
getEquality(
)
:
string
Description
Gets this attribute's equality string
Return value
Type
Description
string
getIsCollective(
)
:
bool
Description
Gets whether this attribute is collective.
Return value
Type
Description
bool
Returns true if this attribute is collective and false otherwise.
getIsNoUserModification(
)
:
bool
Description
Gets whether this attribute is not modifiable by users.
Return value
Type
Description
bool
Returns true if this attribute is not modifiable by users.
getIsObsolete(
)
:
bool
Description
Gets whether this attribute has been flagged as obsolete by the LDAP server
Return value
Type
Description
bool
getIsSingleValue(
)
:
bool
Description
Gets whether this attribute is single-valued. If this attribute only supports single values, true
is returned. If this attribute supports multiple values, false is returned.
Return value
Type
Description
bool
Returns true if this attribute is single-valued or false otherwise.
getMaxLength(
)
:
int
Description
Gets this attribute's the maximum length. If no maximum is defined by the LDAP server, null is returned.
Return value
Type
Description
int
The maximum length (in characters) of this attribute or null if no maximum is specified.
getName(
)
:
string
Description
Gets this attribute's name
Return value
Type
Description
string
getOrdering(
)
:
string
Description
Gets this attribute's ordering specification.
Return value
Type
Description
string
getRequiredByObjectClasses(
)
:
array
Description
Gets the list of "required by" objectClasses, that is the list of objectClasses
which provide must have attribute.
Return value
Type
Description
array
An array of names of objectclasses (strings) which provide this attribute
getSubstr(
)
:
string
Description
Gets this attribute's substring matching specification
Return value
Type
Description
string
getSupAttribute(
)
:
string
Description
Gets this attribute's parent attribute (if any). If this attribute does not
inherit from another attribute, null is returned.
Return value
Type
Description
string
getSyntaxOID(
)
:
string
Description
Gets this attribute's syntax OID. Differs from getSyntaxString() in that this
function only returns the actual OID with any length specification removed. Ie, if the syntax string is "1.2.3.4{16}", this function only retruns
"1.2.3.4".
Return value
Type
Description
string
The syntax OID string.
getSyntaxString(
)
:
string
Description
Gets this attribute's raw syntax string (ie: "1.2.3.4{16}").
Return value
Type
Description
string
The raw syntax string
getType(
)
:
string
Description
Gets this attribute's type
Return value
Type
Description
string
The attribute's type.
getUsage(
)
:
string
Description
Gets this attribute's usage string as defined by the LDAP server
Return value
Type
Description
string
getUsedInObjectClasses(
)
:
array
Description
Gets the list of "used in" objectClasses, that is the list of objectClasses
which provide this attribute.
Return value
Type
Description
array
An array of names of objectclasses (strings) which provide this attribute
initVars(
)
:
n/a
Description
Initialize the class' member variables
Return value
Type
Description
n/a
n/a
isAliasFor(
string
$attr_name,
)
:
bool
Description
Returns whether the specified attribute is an alias for this one (based on this attribute's alias list).
Arguments
Name
Type
Description
Default
$attr_name
string
The name of the attribute to check.
Return value
Type
Description
bool
True if the specified attribute is an alias for this one, or false otherwise.
removeAlias(
string
$remove_alias_name,
)
:
bool
Description
Removes an attribute name from this attribute's alias array.
Arguments
Name
Type
Description
Default
$remove_alias_name
string
The name of the attribute to remove.
Return value
Type
Description
bool
true on success or false on failure (ie, if the specified
attribute name is not found in this attribute's list of aliases)
setAliases(
array
$new_aliases,
)
:
n/a
Description
Sets this attribute's list of aliases.
Arguments
Name
Type
Description
Default
$new_aliases
array
The array of alias names (strings)
Return value
Type
Description
n/a
n/a
setIsSingleValue(
bool
$is_single_value,
)
:
n/a
Description
Sets whether this attribute is single-valued.
Arguments
Name
Type
Description
Default
$is_single_value
bool
Return value
Type
Description
n/a
n/a
setName(
string
$new_name,
)
:
n/a
Description
Sets this attriute's name.
Arguments
Name
Type
Description
Default
$new_name
string
The new name to give this attribute.
Return value
Type
Description
n/a
n/a
setSupAttribute(
string
$new_sup_attr,
)
:
n/a
Description
Sets this attriute's SUP attribute (ie, the attribute from which this attribute inherits).
Represents an LDAP Syntax All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.
Represents an LDAP MatchingRule All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.
Represents an LDAP schema matchingRuleUse entry All schema items have at least two things in common: An OID
and a description. This class provides an implementation for
these two data.