Hi,
As 'Entry' is not allowed to use now , In replace of Entry we are suggested
to use UserAccounts and UserAccount which is very limited to some object
classes .
(['account','posixaccount','inetOrgPerson','organizationalPerson'])
What if we need to create some entry with other object classes rather than
those fixed in UserAccounts and UserAccount like bellow :
---------------------------------------------
Role Entry:
topo.standalone.add_s(
Entry(('cn=new managed role,dc=example,dc=com', {
'objectclass': ['top', 'ldapsubentry', 'nsroledefinition',
'nssimpleroledefinition', 'nsmanagedroledefinition'],
'description': 'This is the new managed role configuration',
'cn': 'new managed role',
})))
--------------------------------------------------
Sub suffix:
topo.standalone.add_s(
Entry(('dc=subexample, dc=example, dc=com', {
'objectclass': ['top', 'dcobject'],
'dc': 'subexample',
})))
----------------------------------------------------------
Other Entry:
topo.standalone.add_s(
Entry(('cn=CCOS, ou=People, dc=example, dc=com', {
'objectclass': ['top', 'LDAPSubentry', 'cosSuperDefinition',
'cosClassicDefinition'],
'cosTemplateDn': ['ou=MailSchemeClasses, ou=COS, dc=example,
dc=com'],
'cosSpecifier': 'emailclass',
'cosAttribute': ['mailquota', 'multiLineDescription override'],
'cn': 'ccos'
})))
--------------------------------------
For above kind of entries there is no way we can create them without using
"Entry" or using
UserAccounts and UserAccount.
To deal with this problem i have created one universal class that can be
used to create any kind of entry which may be a user , role, or sub suffix.
Take a look bellow .
class UniversalEntry(DSLdapObject):
def __init__(self, instance, objectclasses, rdn, dn):
super(UniversalEntry, self).__init__(instance, dn)
self._rdn_attribute = rdn
self._create_objectclasses = objectclasses
and this one can be used for above examples:
-----------------------------------------
properties = {
'description': 'This is the new managed role configuration',
'cn': 'new managed role',
}
user = UniversalEntry(topo.standalone, ['top', 'ldapsubentry',
'nsroledefinition', 'nssimpleroledefinition','nsmanagedroledefinition'],
'cn','cn=new managed role,dc=example,dc=com')
user.create(properties=properties)
---------------------------------------------------
properties = {'dc': 'subexample'}
user = UniversalEntry(topo.standalone, ['top', 'dcobject'], 'dc',
'dc=subexample, dc=example, dc=com')
user.create(properties=properties)
---------------------------------------------
properties = {
'cosTemplateDn': ['ou=MailSchemeClasses, ou=COS, dc=example,
dc=com'],
'cosSpecifier': 'emailclass',
'cosAttribute': ['mailquota', 'multiLineDescription override'],
'cn': 'ccos'
}
user = UniversalEntry(topo.standalone, ['top', 'LDAPSubentry',
'cosSuperDefinition', 'cosClassicDefinition'], 'cn', 'cn=CCOS, ou=People,
dc=example, dc=com')
------------------------------------------------
This way we will be able to create any kind of entry whether it may be
user/role/sub suffix or anything .
Please let me know what other changes i have to do to make more
sophisticated.
Regards
Anuj Borah