Skip to content

Commit

Permalink
userPrincipalName should be mail attribute
Browse files Browse the repository at this point in the history
Our userprincipalnames do not match with mail attribute. TODO: Fix auth with other applications
  • Loading branch information
rinkp committed Dec 20, 2020
1 parent dc4de3a commit 6a46642
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def sync():

ldap_results = ldap_connector.search_s(config['LDAP_BASE_DN'], ldap.SCOPE_SUBTREE,
config['LDAP_FILTER'],
['userPrincipalName', 'cn', 'userAccountControl'])
['mail', 'cn', 'userAccountControl'])

ldap_results = map(lambda x: (
x[1]['userPrincipalName'][0].decode(),
x[1]['mail'][0].decode(),
x[1]['cn'][0].decode(),
False if int(x[1]['userAccountControl'][0].decode()) & 0b10 else True), ldap_results)

Expand Down Expand Up @@ -123,6 +123,7 @@ def apply_config(config_file, config_data):
def read_config():
required_config_keys = [
'LDAP-MAILCOW_LDAP_URI',
'LDAP-MAILCOW_LDAP_DOMAIN',
'LDAP-MAILCOW_LDAP_BASE_DN',
'LDAP-MAILCOW_LDAP_BIND_DN',
'LDAP-MAILCOW_LDAP_BIND_DN_PASSWORD',
Expand Down Expand Up @@ -156,6 +157,7 @@ def read_dovecot_passdb_conf_template():

return data.substitute(
ldap_uri=config['LDAP_URI'],
ldap_domain=config['LDAP_DOMAIN'],
ldap_base_dn=config['LDAP_BASE_DN']
)

Expand Down
1 change: 1 addition & 0 deletions templates/dovecot/ldap/passdb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ldap_version = 3
base = $ldap_base_dn
auth_bind = yes
auth_bind_userdn = %u
auth_default_realm = $ldap_domain
4 changes: 2 additions & 2 deletions templates/sogo/plist_ldap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<key>IDFieldName</key>
<string>cn</string>
<key>UIDFieldName</key>
<string>userPrincipalName</string>
<string>mail</string>

<key>baseDN</key>
<string>$ldap_base_dn</string>
Expand All @@ -21,7 +21,7 @@
<string>$ldap_bind_dn_password</string>
<key>bindFields</key>
<array>
<string>userPrincipalName</string>
<string>mail</string>
</array>

<key>bindAsCurrentUser</key>
Expand Down

0 comments on commit 6a46642

Please sign in to comment.