Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Benoit,

I've added experimental LDAP support, however I've only tested in on a "mock" ldap object.

Basically if you go to "settings"->"External keys", check "Use LDAP for password login" and fill out all ldap related fields.

You might need to adjust a function askbot.deps.django_authopenid.util.ldap_check_password as some parameters may need to be changed. If you make this function work on a real LDAP directory, you'll be able to log in via ldap.

def ldap_check_password(username, password):
    import ldap
        ldap_session = ldap.initialize(askbot_settings.LDAP_URL)
        ldap_session.simple_bind_s(username, password)
        return True
    except ldap.LDAPError, e:
        return False

If you want to disable other login methods and change looks of the login form, for now you'll have to hack a template askbot/skins/default/templates/authopenid/signin.html

Here is the mock ldap object that I've used to test the LDAP method:

class LDAPError(Exception):

class LDAP(object):

    def simple_bind_s(self, username, password):
        if username == 'test' and password == 'test':
            return True
            raise LDAPError('try again')

    def unbind_s(self):

def initialize(*args):
    return LDAP()