cit-jmu/rooibos — pull request #12 by hanleybrand (2012-07-18 20:26:52+00:00)
Title: Fix ldap for other implementations

(this is only for settings_local.template.py and auth/ldap_auth.py - please ignore the TU specific customizations in this branch)

summary: I added a few lines of code to ladapauth.py and an optional variable to settings_local to cover an ldap case where the workflow is
1. user submits username & pass via form
2. application performs unauthenticated ldap.search_s(uid=username)
3. application receives fully formed dn as result[0][0] (uniNIC=4324526343234,ou=people,dc=somewhere,dc=edu)
4. application: ldap.simple_bind_s( result[0][0], password )
5. on success, application finishes

Notes
I revisited why the code in ldapauth.py didn't work with Temple's system, and after meeting with our identity management lead who gave me a welcomed lesson on how LDAP works I have come up with the definitive answer and have concluded that our problem is not site-specific, but rather specific to the authentication systems we are using.

I'm not clear how wide-spread our implementation style is - the part I added is just a slightly modified version of the bind_user section, without a bind_user. I feel like there's a more elegant way to handle this, but after trying implement it more elegantly and ending up only more complicatedly*, I reverted back and went for simplicity so I could raise the issue with a concrete solution (that may apply to other sites that couldn't get ldap to work).

One thing I sort of envisioned but couldn't quite get going on was a way that the site could specify how their dn was constructed in settings_local.py:
```
dn_constructor = { 'dn=' , dn, base }
```

At any rate, if you're game we can try to hash this out via comments, email, etc. - but I wanted to get the code to you first

* see https://github.com/hanleybrand/rooibos/commit/176f6845627ef12139dd014362ed6955522f23ff and https://github.com/hanleybrand/rooibos/commit/6cef7bef461deba78dfa9ad4f60b6623ea3194c9 for what I mean