To use ldap login with MS Active Directory:
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods.append(ldap_auth(
mode='ad', server='my.domain.controller',
base_dn='ou=Users,dc=domain,dc=com'))
To use ldap login with Notes Domino:
auth.settings.login_methods.append(ldap_auth(
mode='domino',server='my.domino.server'))
To use ldap login with OpenLDAP:
auth.settings.login_methods.append(ldap_auth(
server='my.ldap.server', base_dn='ou=Users,dc=domain,dc=com'))
To use ldap login with OpenLDAP and subtree search and (optionally) multiple DNs:
auth.settings.login_methods.append(ldap_auth(
mode='uid_r', server='my.ldap.server',
base_dn=['ou=Users,dc=domain,dc=com','ou=Staff,dc=domain,dc=com']))
or (if using CN):
auth.settings.login_methods.append(ldap_auth(
mode='cn', server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com'))
or you can full customize the search for user:
auth.settings.login_methods.append(ldap_auth(
mode='custom', server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com',
username_attrib='uid',
custom_scope='subtree'))
None db.py
First line imports ldap_auth and second line auth.settings.login_methods specifies parameters.
| from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods = [auth, ldap_auth(mode='ad',
bind_dn='USERNAME',
bind_pw='PASSWORD',
manage_groups=False,
manage_user=True,
user_firstname_attrib='cn:1',
user_lastname_attrib='cn:2',
server='SERVERNAME',
user_mail_attrib='mail',
base_dn='dc=DC,dc=DOMAIN',
logging_level='error',
db=db)]
|
Result
loading...
Sources / Reference
" GitHub"
" Web2py Book - Chapter 9: Access Control"