LDAP Storage for Archetypes
Project description
Description
This product features an Archetypes storage that stores field values in
an LDAP directory.
Usage
See directory 'examples/' for some examples of content types using
LDAPStorage.
There are some issues regarding LDAPStorage and Archetypes:
- the storage initialization requires the following parameters:
- the LDAP RDN attribute. For example, in the folowing LDAP
entry, the RDN attribute is 'cn':
dn: cn=johndoe,dc=localhost,dc=localdomain
objectClass: inetOrgPerson
uid: johndoe
cn: johndoe
sn: John Doe
- the attribute that should be used to get the RDN value. It can
be a method, archetypes field or instance variable from which
the value will be retrieved to construct the entry DN.
NOTES:
1) If an archetypes field is used, it must be using
LDAPStorage and you must ensure that the field is the RDN
field that you defined and its attribute is the RDN attribute.
2) If you want to use a field that is not in LDAP,
you should use its accessor, but note that LDAPStorage won't be
able to know when its value changes. So, be sure that methods or
variables used as RDN mapping are not mutable.
- the LDAP attribute to store the value from this field;
The following example is correct:
...
StringField(
'name',
storage = LDAPStorage(
'cn',
'name',
'cn',
default_attrs = {
'objectClass': ['inetOrgPerson'],
},
required_attrs = ['sn', 'cn'],
),
),
...
The following example would raise the exception
'InvalidRDNError':
...
StringField(
'name',
storage = LDAPStorage(
'cn',
'organization',
'cn',
default_attrs = {
'objectClass': ['inetOrgPerson'],
},
required_attrs = ['sn', 'cn'],
),
),
...
- it has also some additional parameters:
- a dictionary of common attributes. This dictionary will be
used to set default values in certain LDAP attributes, at the
creation of new entries. For example, this dictionary could be:
>>> default_attrs = {'objectClass': 'inetOrgPerson'}
- list of required attributes in LDAP schema. It will tell the
storage what fields are required in LDAP, so it knows they must
be included in initialization. For example, the list, assuming
that the only object class used is 'inetOrgPerson', would be:
>>> required_attrs = ['sn', 'cn']
- the usage of this storage assumes that the defined schemas
(LDAP and Archetypes) are compatible. Attributes that are required
in LDAP schema, should be also required in Archetypes schema.
Tests
To run unit tests you need to have a configured LDAP server, and fill
the settings in tests/config file.
Requirements
- CMFPlone 3.0
- Archetypes 1.4
- python-ldap
- LDAPConnection 0.1a1 or newer
Todo
Read file todo.txt for details.
Copyright
Ricardo Alves <rsa at eurotux dot com>
Eurotux Development Team <udp at eurotux dot com>
License
This software is released under GPL v2. Read LICENSE.txt
Changelog
=========
0.1 - Unreleased
----------------
* Initial release
This product features an Archetypes storage that stores field values in
an LDAP directory.
Usage
See directory 'examples/' for some examples of content types using
LDAPStorage.
There are some issues regarding LDAPStorage and Archetypes:
- the storage initialization requires the following parameters:
- the LDAP RDN attribute. For example, in the folowing LDAP
entry, the RDN attribute is 'cn':
dn: cn=johndoe,dc=localhost,dc=localdomain
objectClass: inetOrgPerson
uid: johndoe
cn: johndoe
sn: John Doe
- the attribute that should be used to get the RDN value. It can
be a method, archetypes field or instance variable from which
the value will be retrieved to construct the entry DN.
NOTES:
1) If an archetypes field is used, it must be using
LDAPStorage and you must ensure that the field is the RDN
field that you defined and its attribute is the RDN attribute.
2) If you want to use a field that is not in LDAP,
you should use its accessor, but note that LDAPStorage won't be
able to know when its value changes. So, be sure that methods or
variables used as RDN mapping are not mutable.
- the LDAP attribute to store the value from this field;
The following example is correct:
...
StringField(
'name',
storage = LDAPStorage(
'cn',
'name',
'cn',
default_attrs = {
'objectClass': ['inetOrgPerson'],
},
required_attrs = ['sn', 'cn'],
),
),
...
The following example would raise the exception
'InvalidRDNError':
...
StringField(
'name',
storage = LDAPStorage(
'cn',
'organization',
'cn',
default_attrs = {
'objectClass': ['inetOrgPerson'],
},
required_attrs = ['sn', 'cn'],
),
),
...
- it has also some additional parameters:
- a dictionary of common attributes. This dictionary will be
used to set default values in certain LDAP attributes, at the
creation of new entries. For example, this dictionary could be:
>>> default_attrs = {'objectClass': 'inetOrgPerson'}
- list of required attributes in LDAP schema. It will tell the
storage what fields are required in LDAP, so it knows they must
be included in initialization. For example, the list, assuming
that the only object class used is 'inetOrgPerson', would be:
>>> required_attrs = ['sn', 'cn']
- the usage of this storage assumes that the defined schemas
(LDAP and Archetypes) are compatible. Attributes that are required
in LDAP schema, should be also required in Archetypes schema.
Tests
To run unit tests you need to have a configured LDAP server, and fill
the settings in tests/config file.
Requirements
- CMFPlone 3.0
- Archetypes 1.4
- python-ldap
- LDAPConnection 0.1a1 or newer
Todo
Read file todo.txt for details.
Copyright
Ricardo Alves <rsa at eurotux dot com>
Eurotux Development Team <udp at eurotux dot com>
License
This software is released under GPL v2. Read LICENSE.txt
Changelog
=========
0.1 - Unreleased
----------------
* Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file archetypes.ldapstorage-0.1a1.tar.gz
.
File metadata
- Download URL: archetypes.ldapstorage-0.1a1.tar.gz
- Upload date:
- Size: 70.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93f21d678010b5b52af39af680c40fd468a3d8a9474c2620c9689b01f297fc59 |
|
MD5 | 3619e352071ee58fb6bc0e8cd46bf17e |
|
BLAKE2b-256 | 8c762f748579c5e2802c40cf822900a4e53f4a242acb0fae4d9918d78a9221a7 |