Commit ddcc453c authored by Recteur LP's avatar Recteur LP

add user_displayname parameter

parent 71fbbde8
......@@ -13,6 +13,7 @@ ldapauth:
version: 3
authorize_non_ldap_user: False # Set to True to Accept non LDAP user in the Remote-User Header
user_id: sAMAccountName
user_displayname: displayName
user: 'CN=svc_account,DC=example,DC=com'
password: xxx
basedn: 'DC=example,DC=com'
......
......@@ -26,6 +26,8 @@ class auth():
"LDAP auth module"
def __init__(self, config):
self.config = config
if 'user_displayname' not in self.config:
self.config['user_displayname'] = 'displayName'
if 'server' not in self.config:
pyrmin.returnerror("No ldap server in config")
elif 'port' not in self.config:
......@@ -131,7 +133,7 @@ class auth():
hashlib.md5(mail.encode('utf-8')).hexdigest() + "?"
gravatar_url += urllib.parse.urlencode({'d': "identicon", 's': str(50)})
division = attrs.get('division', ['Guest'])[0]
displayname = attrs.get('displayName', ['Guest'])[0]
displayname = attrs.get(self.config['user_displayname'], ['Guest'])[0]
company = attrs.get('company', [''])[0]
isadmin = False
......@@ -163,7 +165,7 @@ class auth():
gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5(mail).hexdigest() + "?"
gravatar_url += urllib.urlencode({'d': "identicon", 's': str(50)})
division = attrs.get('division', ['Guest'])[0].decode("utf-8")
displayname = attrs.get('displayName', ['Guest'])[0].decode("utf-8")
displayname = attrs.get(self.config['user_displayname'], ['Guest'])[0].decode("utf-8")
company = attrs.get('company', [''])[0].decode("utf-8")
isadmin = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment