Schema support
Hans Aschauer
Hans.Aschauer at Physik.uni-muenchen.de
Wed Apr 3 14:56:57 CEST 2002
I have finished a first version of schema support for python-ldap.
There are four simple wrapper for the functions str2objectclass(),
str2attributetype(), str2matchingrule(), and str2syntax() in the _ldap
module (and thus in the ldap module --- I guess it would be a good idea
to del() them from the ldap module in the ldap/__init__.py file...).
These functions should not be used directly, since they are (probably)
not thread safe.
There exists a new module ldap.schema, which proviedes the following
functions/classes:
* Thread safe wrappers for the four C functions (str2xyz), which return
lists of entries which correspond to the C data types (defined in
ldap_schema.h). For thread safety, they simply use the _ldap_call()
function (Michael, is this a good idea?).
* Four simple classes (attributeType, objectClass, ldapSyntax,
matchingRule). Their constructors take a string description
of the schema, pass it to the wrapper functions and fill in the
object attributes. See RFC2252 for details.
* The class rootDSESchema (looking for a better name...), which takes
an initialize()'d and simple_bind_s()'ed ldap object. The constructor
queries the rootDSE and fills the attributeTypes, objectClasses,
ldapSyntaxes, and matchingRules which are known by the ldap server
into 8 dictionaries: for each of the four classes, there is one
dictionary which takes the oid's as keys (these are those funny
"1.2.3.4" things, which are supposed to be unique), and one
dictionary takes the names as keys. The latter is necessary, since
for example, in objectClasses, the allowed or required attributes are
referred to by name rather than by oid. The names of the
dictionaries are:
objectClasses
objectClassesByName
attributeTypes
attributeTypesByName
ldapSyntaxes
ldapSyntaxesByName
matchingRules
matchingRulesByName
I've attached four files (a patch for setup.py, and the newly created
files Modules/schema.c, Modules/schema.h, Lib/ldap/schema.py).
Any comments? Does the user interface make sense? Could someone please
try it with a _server_ different from OpenLDAP 2? As long as untested,
I would say that it is only compatible with OpenLDAP --- there was some
try/error involved in the RootDSE search...
Hans
--
Hans.Aschauer at Physik.uni-muenchen.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setup.py.patch
Type: text/x-diff
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020403/42c4c13f/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: schema.h
Type: text/x-python
Size: 244 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020403/42c4c13f/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: schema.c
Type: text/x-python
Size: 8455 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020403/42c4c13f/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: schema.py
Type: text/x-python
Size: 4698 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020403/42c4c13f/attachment-0002.py>
More information about the python-ldap
mailing list