<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>HelpOnAuthentication/LDAP</title></articleinfo><section><title>LDAP based user authentication</title><section><title>How it works</title><para>The LDAP auth module of <ulink url="http://www.ninux.org/HelpOnAuthentication/LDAP/MoinMoin#">MoinMoin</ulink> enables single-sign-on (SSO) - assuming you already have a LDAP directory with your users, passwords, email adresses. On Linux this could be some OpenLDAP server, on a Windows server (usually the domain controller) this is called &quot;Active Directory&quot; (short: AD). </para><para>It works like this: </para><itemizedlist><listitem><para>User enters his name and password via moin's login action and clicks on the login button. </para></listitem><listitem><para>On login, ldap_login auth module checks username/password against LDAP. </para><itemizedlist><listitem><para>If username/password is ok for LDAP, it creates or updates a user profile with values from ldap (name, alias, email) and creates a user object in the MoinMoin process, then it hands over to the next auth module... </para></listitem><listitem><para>If username/password is not ok for LDAP, it vetoes the login and aborts the chain of login modules. </para></listitem></itemizedlist></listitem><listitem><para>Usually, you want to use moin_session as the final auth module to establish the session with the user. It uses a cookie to keep the session and create the user object on all subsequent non-login requests. </para></listitem></itemizedlist></section><section><title>Installing</title><para>You need to install python-ldap module (and everything it depends on, see its documentation). </para><para>You need an LDAP or AD server. <inlinemediaobject><imageobject><imagedata depth="16" fileref="http://www.ninux.org//moin_static197/ninuxtheme02/img/smile.png" width="16"/></imageobject><textobject><phrase>:)</phrase></textobject></inlinemediaobject> </para></section><section><title>Configuring LDAP authentication</title><para>Put this into your wiki config (indented in the same way as the other settings there): </para><screen><![CDATA[    from MoinMoin.auth.ldap_login import ldap_login
    from MoinMoin.auth import moin_session
    auth = [ldap_login, moin_session]
]]><![CDATA[
    import ldap
    ldap_uri = 'ldap://ad.example.org' # ldap / active directory server URI
]]><![CDATA[
    # We can either use some fixed user and password for binding to LDAP.
    # Be careful if you need a % char in those strings - as they are used as
    # a format string, you have to write %% to get a single % in the end.
    #ldap_binddn = 'binduser@example.org'
    #ldap_bindpw = 'secret'
]]><![CDATA[
    # Also, if your OpenLDAP is for samba 3 or another model of domain controller 
    # auth backend, you need add as binddn and bindpw your rootdn chain (Manager
    # or any other) and respective password.
    #ldap_binddn = 'cn=Manager,dc=example,dc=org'
    #ldap_bindpw = 'secret'
]]><![CDATA[
    # or we can use the username and password we got from the user:
    ldap_binddn = '%(username)s@example.org' # DN we use for first bind (AD)
    #ldap_binddn = 'cn=admin,dc=example,dc=org' # DN we use for first bind (OpenLDAP)
    ldap_bindpw = '%(password)s' # password we use for first bind
]]><![CDATA[
    ldap_base = 'ou=SOMEUNIT,dc=example,dc=org' # base DN we use for searching
    ldap_scope = ldap.SCOPE_SUBTREE # scope of the search we do
    ldap_filter = '(sAMAccountName=%(username)s)' # ldap filter used for searching
    # for openLDAP in domain controller, the ldap_filter need a change:
    #ldap_filter = '(uid=%(username)s)' # ldap filter used for ldap in samba domain controller
    # you can also do more complex filtering like:
    # "(&(cn=%(username)s)(memberOf=CN=WikiUsers,OU=Groups,DC=example,DC=org))"
]]><![CDATA[
    ldap_givenname_attribute = 'givenName' # ldap attribute we get the first name from
    ldap_surname_attribute = 'sn' # ldap attribute we get the family name from
    ldap_aliasname_attribute = 'displayName' # ldap attribute we get the aliasname from
    ldap_email_attribute = 'mail' # ldap attribute we get the email address from
    ldap_email_callback = None # the function that is called with a dict as the first argument that provides LDAP data. the function has to return the e-mail address that was generated from the dict input
]]><![CDATA[
    ldap_coding = 'utf-8' # coding used for ldap queries and result values
    ldap_timeout = 10 # how long we wait for the ldap server [s]
    ldap_verbose = True # if True, put lots of LDAP debug info into the log
]]><![CDATA[
    cookie_lifetime = 1 # 1 hour after last access ldap login is required again
    user_autocreate = True
]]><![CDATA[
    # we don't allow the user to change those values on UserPreferences page
    user_form_disable = ['name', 'aliasname', 'email', ]
    # we remove those fields as they are not used for ldap based logins
    user_form_remove = ['password', 'password2', ]]]></screen></section><section><title>Problems?</title><para>MoinMoin support does not know your LDAP server setup, so please follow these steps before asking for help: </para><itemizedlist><listitem><para>Use ldap_verbose and look into your log file<footnote><para>this file is into your wiki data dir</para></footnote>. </para></listitem><listitem><para>Verify your settings and your user/password by e.g. using ldapsearch to query your LDAP server. </para><itemizedlist><listitem><para><inlinemediaobject><imageobject><imagedata depth="15" fileref="http://www.ninux.org//moin_static197/ninuxtheme02/img/alert.png" width="15"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> As long as you don't manage talking to your LDAP server with such a tool, you don't need to try with MoinMoin. </para></listitem></itemizedlist></listitem><listitem><para>Ask the administrator of your LDAP/AD server for help / for correct settings. </para></listitem><listitem><para>Maybe look into <code>MoinMoin/auth/ldap_login.py</code>, if you can debug or fix your problem there. </para></listitem></itemizedlist><para><inlinemediaobject><imageobject><imagedata depth="15" fileref="http://www.ninux.org//moin_static197/ninuxtheme02/img/alert.png" width="15"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> Only ask MoinMoin support if you successfully used ldapsearch (or some similar tool) and you double checked your wiki config and it does still not work with moin. </para></section></section></article>