Schema¶
Usage example¶
# Get the schema as an LDAP entry
schema = standalone.schema.get_entry()
# Get the schema as a python-ldap SubSchema object
subschema = standalone.schema.get_subschema()
# Get a list of the schema files in the instance schemadir
schema_files = standalone.schema.list_files()
# Convert the given schema file name to its python-ldap format suitable for passing to ldap.schema.SubSchema()
parsed = standalone.schema.file_to_ldap('/full/path/to/file.ldif')
# Convert the given schema file name to its python-ldap format ldap.schema.SubSchema object
parsed = standalone.schema.file_to_subschema('/full/path/to/file.ldif')
# Add a schema element to the schema
standalone.schema.add_schema(attr, val)
# Delete a schema element from the schema
standalone.schema.del_schema(attr, val)
# Add 'attributeTypes' definition to the schema
standalone.schema.add_attribute(attributes)
# Add 'objectClasses' definition to the schema
standalone.schema.add_objectclass(objectclasses)
# Get a schema nsSchemaCSN attribute
schema_csn = standalone.schema.get_schema_csn()
# Get a list of ldap.schema.models.ObjectClass objects for all objectClasses supported by this instance
objectclasses = standalone.schema.get_objectclasses()
# Get a list of ldap.schema.models.AttributeType objects for all attributeTypes supported by this instance
attributetypes = standalone.schema.get_attributetypes()
# Get a list of the server defined matching rules
matchingrules = standalone.schema.get_matchingrules()
# Get a single matching rule instance that matches the mr_name. Returns None if the matching rule doesn't exist
matchingrule = standalone.schema.query_matchingrule(matchingrule_name)
# Get a single ObjectClass instance that matches objectclassname. Returns None if the objectClass doesn't exist
objectclass = standalone.schema.query_objectclass(objectclass_name)
# Returns a tuple of the AttributeType, and what objectclasses may or must take this attributeType. Returns None if attributetype doesn't
(attributetype, may, must) = standalone.schema.query_attributetype(attributetype_name)
Module documentation¶
-
class
lib389.schema.
Schema
(instance)[source]¶ An object that represents the schema entry
- Parameters
instance (lib389.DirSrv) – An instance
-
add_attributetype
(parameters)[source]¶ Add an attribute type definition to the schema.
- Parameters
parameters (str) – an attribute type definition to add
-
add_objectclass
(parameters)[source]¶ Add an object class definition to the schema.
- Parameters
parameters (str) – an objectClass definition to add
-
file_to_ldap
(filename)[source]¶ Convert the given schema file name to its python-ldap format suitable for passing to ldap.schema.SubSchema()
- Parameters
filename (str) – the full path and filename of a schema file in ldif format
-
file_to_subschema
(filename)[source]¶ Convert the given schema file name to its python-ldap format ldap.schema.SubSchema object
- Parameters
filename (str) – the full path and filename of a schema file in ldif format
-
get_attributetypes
(json=False)[source]¶ Returns a list of ldap.schema.models.AttributeType objects for all attributeTypes supported by this instance.
- Parameters
json (bool) – return the result in JSON format
-
get_matchingrules
(json=False)[source]¶ Return a list of the server defined matching rules
- Parameters
json (bool) – return the result in JSON format
-
get_objectclasses
(json=False)[source]¶ Returns a list of ldap.schema.models.ObjectClass objects for all objectClasses supported by this instance.
- Parameters
json (bool) – return the result in JSON format
-
query_attributetype
(attributetypename, json=False)[source]¶ Returns a tuple of the AttributeType, and what objectclasses may or must take this attributeType. Returns None if attributetype doesn’t exist.
- Parameters
- Returns
(AttributeType, Must, May) or None
ex. query_attributetype(‘uid’) ( <ldap.schema.models.AttributeType instance>,
[<ldap.schema.models.ObjectClass instance>, …], [<ldap.schema.models.ObjectClass instance>, …] )
-
query_matchingrule
(mr_name, json=False)[source]¶ Returns a single matching rule instance that matches the mr_name. Returns None if the matching rule doesn’t exist.
- Parameters
- Returns
MatchingRule or None
<ldap.schema.models.MatchingRule instance>
-
query_objectclass
(objectclassname, json=False)[source]¶ Returns a single ObjectClass instance that matches objectclassname. Returns None if the objectClass doesn’t exist.
- Parameters
- Returns
ObjectClass or None
ex. query_objectclass(‘account’) <ldap.schema.models.ObjectClass instance>
-
remove_attributetype
(name)[source]¶ Remove the attribute type definition from the schema.
- Parameters
name (str) – the name of the attributeType you want to remove.