Importing Roles from LDAP/AD

Since version 6.1.5, the Pro Edition supports syncing roles from LDAP or Active Directory.

To enable this feature, add config option ROLE_NAME_ATTR to ccnet.conf

  1. [LDAP_SYNC]
  2. ROLE_NAME_ATTR = title

ROLE_NAME_ATTR is the attribute field to configure roles in LDAP .
We provide a user-defined function to map the role:Create custom_functions.py under conf/ and edit it like:

  1. #coding=utf-8
  2. import sys
  3. reload(sys)
  4. sys.setdefaultencoding('utf8')
  5. def ldap_role_mapping(role):
  6. if 'staff' in role:
  7. return 'Staff'
  8. if 'guest' in role:
  9. return 'Guest'
  10. if 'manager' in role:
  11. return 'Manager'

you can rewrite this function (in python) to make your own mapping rules. If the file or function doesn’t exist, all roles in ROLE_NAME_ATTR will be synced.

NOTE: Make sure that ccnet-server keeps running while doing LDAP role sync.