The second one is a little more complicated. One problem is that it relies on _meta, which is a private and undocumented property. I have occasionally used it in my own code, but distributing a package that relies on it is a different matter. A better approach might be to have the configuration indicate which fields are foreign keys and how to locate the associated records. That said, this is sounding like an awful lot of configuration that ought to be code. Once the save signals are sorted out, is there any reason you can't populate your profile in post_save? Then you can make it as complex as you like without worrying about generalizing.
Thanks
To get the username from the attributes, the expectation is that you will subclass LDAPBackend and override get_or_create_user. That's more or less what you're doing now, so you should be all set. A feature to pull the username from an LDAP attribute might be a reasonable addition, although overloading AUTH_LDAP_USER_ATTR_MAP may not be the best way. It bears some thought, but since it's purely a convenience feature, there's no need to rush into it.
The issues you had with populating users are valid and I think your suggestion of a custom signal makes a lot of sense. I would propose two signals: populate_ldap_user and populate_ldap_user_profile. These would be sent after the built-in user/profile population is done but before the user/profile has been saved (respectively), thus minimizing DB access. Combined with the new order of operations, I think this should give you everything you need for your cases.
Thanks
On Thu, Mar 24, 2011 at 1:54 PM, Jeff Schroeder
<jeffsc...@computer.org> wrote:
> Paul,
>
> If the code is cleaned up, and suitable to your standards, would you
> merge a subclass which worked for Active Directory things out of the
> box, or will you make that work in the existing LDAPBackend?
> --
> Jeff Schroeder
>
> Don't drink and derive, alcohol and analysis don't mix.
> http://www.digitalprognosis.com
>
--
Jeff Schroeder
Don't drink and derive, alcohol and analysis don't mix.
http://www.digitalprognosis.com
If the code is cleaned up, and suitable to your standards, would you
merge a subclass which worked for Active Directory things out of the
box, or will you make that work in the existing LDAPBackend?
On Thu, Mar 24, 2011 at 1:35 PM, Felipe Prenholato <phili...@gmail.com> wrote:
--
1. Fork django_auth_ldap and customize it for AD. This is obviously the sledgehammer approach and not ideal.
2. Create a separate project (django_auth_ldap_ad?) that extends django_auth_ldap by implementing all of the hooks and signals necessary to give it AD-specific functionality. If some enterprising soul wanted to take that on, I would be happy to support the effort by exposing additional hooks and customization points as necessary.
3. The same as #2, but ship the derived classes and support code somewhere in the django_auth_ldap distribution. This could be interesting logistically, as someone else would still have to maintain it.
4. Somehow integrate an AD "mode" into the existing django_auth_ldap. At that point, we're talking about creating a new level of abstraction whereby django_auth_ldap has pre-defined configurations to support--in principle--a variety of common servers and configurations, starting with AD. One could imagine building up a set of configurations that correspond to the default installations of various platforms and distributions. An intriguing idea, but one that would definitely require some careful research and design work.
My instinct would be to start with #2. If there's interest in a strategy for providing push-button configurations for common server designs, doing an AD implementation and letting it bake for a while would probably provide some very useful insights into the right way to go about that. It may be that django_auth_ldap would just evolve a more powerful plugin API of some kind and server-specific configurations would be expected to live as separate modules.
Thanks
Hopefully there's no barrier to using the post_save handler as Django recommends?
[1] http://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users