Ldap (AD) authentication with MoinMoin doesn't work

718 Views Asked by At

I'm trying to connect MoinMoin with my AD server, however it doesn't work. I mean, that I try to login with my domain account, I don't get any error (and if I try to login with previously created superuser account I get an error that username or password is wrong), but I'm not still logged in. If I follow code from MoinMoin/auth/ldap_login.py I've got a right credentials. Am I doing the setting in a proper way? I'm using MoinMoin 1.9.6 on FreeBSD 9.1 with python 2.7 without installation of MoinMoin (i.e. I only extracted files from archive and run wikiserver.py).

Here I show you my wikiconfig_local.py:

from wikiconfig import LocalConfig
from MoinMoin.auth.ldap_login import LDAPAuth

class Config(LocalConfig):
    superuser=[u"IshayahuLastov",]
    page_front_page=u"MyWiki"
    ldap_authenticator1 = LDAPAuth(
        server_uri='ldap://192.168.1.9',
        bind_dn='[email protected]',
        bind_pw = 'mypassword',
        base_dn='dc=meoc,dc=mjcc,dc=local',
        scope=2, # scope of the search we do (2 == ldap.SCOPE_SUBTREE)
        referrals=0, # LDAP REFERRALS (0 needed for AD)
        search_filter='(sAMAccountName=%(username)s)'
        givenname_attribute=None,
        surname_attribute=None,
        aliasname_attribute=None, 
        email_attribute=None, 
        email_callback=None, 
        coding='utf-8',
        timeout=10, 
        start_tls=0, 
        tls_cacertdir='',
        tls_cacertfile='',
        tls_certfile='',
        tls_keyfile='',
        tls_require_cert=0, 
        bind_once=False,
        )
    auth = [ldap_authenticator1, ] 
    cookie_lifetime = 1 # 1 hour after last access ldap login is required again
    user_autocreate = True
2

There are 2 best solutions below

0
On

If you use A.D, use '(uid=%(username)s)' instead of search_filter='(sAMAccountName=%(username)s)' and tell

0
On

there is likely something wrong with the values you give to LDAPAuth().

to debug this, it is helpful to enable debug logging for MoinMoin.auth (see the logging configuration examples contained in the moin download archive).

you could also try using ldapsearch commandline tool with similar params, just to check how you can get it working.