It should be easy to include LDAP support in web2py. If you are familiar with Auth in tools, something like this should work:
""" based on http://www.packtpub.com/article/installing-and-configuring-the-python-ldap-library-and-binding-to-an-ldap-directory """ import ldap, ldap.sasl import sys, getpass from gluon.tools import Auth class AuthLDAP(Auth): def login(self): form=SQLFORM('username:',INPUT(_name='username'), 'password:',INPUT (_name='password',_type='password'), INPUT(_type='submit',_value='login')) if form.accepts(request.vars,session): try: con = ldap.initialize("ldap://localhost") auth_tokens = ldap.sasl.digest_md5(form.vars.username, reqest.vars.password) con.sasl_interactive_bind_s( "", auth_tokens ) con.unbind() user = self.setings.table_user users = self.db (user.username==form.vars.username).select(): if not users: user_id = user.insert(username=form.vars.username, password=form.vars.username) group_id = self.add_group('user_%i' % user_id) self.add_membership(group_id, user_id) user = user.filter_fields(user[user_id],id=True) else: user = user.filter_fields(users[0],id=True) self.user = user session.auth = Storage(user=user, last_visit=request.now, expiration=self.settings.expiration) # ... do onaccept and session.flash and redirect as in Auth.login except ldap.LDAPError, e:: pass return dict(form=form) Can you help me test it and fill the blanks? Massimo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---