seafile-admin-docs/manual/deploy_pro/ldap_role_sync.md
2020-12-01 10:33:47 +08:00

46 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
```
[LDAP_SYNC]
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 roleCreate `custom_functions.py` under conf/ and edit it like:
```
#coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
def ldap_role_mapping(role):
if 'staff' in role:
return 'Staff'
if 'guest' in role:
return 'Guest'
if 'manager' in role:
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.
Note: If you are using 7.1 version or later, and with Python 3, you should remove the following code from \`custom_functions.py\`:
```
import sys
reload(sys)
sys.setdefaultencoding('utf8')
```