Replies: 2 comments 8 replies
-
|
Thanks for reaching out @matejak. Subclassing of the generated modules is definitely something which should work. I'll have a look at this. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you again for your answer and for your tip about the config module. Let me though to share another issues that I have encountered: The top_dn = "dc=example,dc=com"
BaseUser = ldap3_orm.EntryType("uid={uid},{base_dn}", ["inetOrgPerson"], schema=conn)
class ColouredUser(BaseUser):
def __init__(self, color, * args, ** kwargs):
self.color = color
super().__init__(* args, ** kwargs)
@property
def base_dn(self):
ret = f"ou={self.color},ou=people,{top_dn}"
return ret
user = ColouredUser("grey", uid="johndoe", sn="doe", cn="john")The code would allow users to be stored in a location that is based on their attribute. However, there seem to be problems with this approach:
It looks to me that there are two issues: A - the derived class inherits the approach that considers all attributes LDAP attributes. I don't think that this is needed, as users are supposed to declare LDAP attributes using the Do you think that this is OK as it is, and perhaps should be documented in a section about subclassing, or do you see the current state more as a WIP? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I was thinking that maybe I could let the ORM generate a base class for me which I would then subclass, so the application logic could better integrate with the module.
However, I am starting to have doubts whether this is a good idea. Most notably, the following code doesn't work (lets' assume that we have a working
connobject:The code crashes with a traceback, where the ldap-orm part
seems to be wrong already -
schemais{'__module__': 'builtins', '__qualname__': 'get_x.<locals>.User', 'base_dn': 'ou=people,dc=example,dc=com'}and not theconnobject that I would expect.Do you think that this is a bug, or am I doing something stupid?
Beta Was this translation helpful? Give feedback.
All reactions