If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

After searching everywhere I could not find a solution. After finally going to the code I discoved that it needed to be fixed for Active directory.


I have submitted a pull request, but until then replace






(It is now in web2py upstream dev, and should be included in the next stable release)


Here is my authentication settings in my model.

Credit for most of it goes to the mentioned slice:


# Authentication - http://www.web2pyslices.com/slice/show/1468/how-to-set-up-web2py-ldap-with-windows-active-directory
from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())
# all we need is login
# you don't have to remember me
auth.settings.remember_me_form = False
# ldap authentication and not save password on web2py
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods = [ldap_auth(mode='ad',
    allowed_groups = ['Domain Group1','Domain Group2'],
    bind_dn = 'CN=Admin User,OU=baseou,DC=example,DC=com',
    bind_pw = 'pass',
    group_dn = 'OU=Domain Groups,OU=baseou,DC=example,DC=com',
    group_name_attrib = 'cn',
    group_member_attrib = 'member',
    group_filterstr = 'objectClass=Group',

Note that the bind_dn and bind_pw are required unless your setup allows anonymous bind.

Good Luck!


Related slices

Comments (0)

Hosting graciously provided by:
Python Anywhere