Skip to content

Commit

Permalink
add config to convert email to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
hubermat committed Jun 29, 2018
1 parent f3c7fa4 commit 00456a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions ctldap.example.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
; Add debug infos to log
debug=false

; This is required for clients using lowercase DNs, e.g. ownCloud/nextCloud
dn_lower_case=true
; This is required for clients that need lowercase email addresses, e.g. Seafile
email_lower_case=true

; LDAP admin user, can be a "virtual" root user or a ChurchTools user name (virtual root is recommended!)
ldap_user=root
Expand Down Expand Up @@ -37,12 +40,14 @@ cache_lifetime=10000
; Define the sites here. For each site please enter one section.
; The section title has to be in the format sites.<ldap_base_dn>, e.g. "sites.foobar",
; where foobar is the organisation, as in the instance foobar.church.tools .
; dn_lower_case is optional.
; dn_lower_case is optional, if not specified, the default value will be taken from the config above
; email_lower_case is optional, if not specified, the default value will be taken from the config above
; If ldap_base_dn is set above, the setting above are treated as an additional site.

;[sites.XXXXXXXXXXXXXXXXXXXX]
;ldap_password=XXXXXXXXXXXXXXXXXXXX
;ct_uri=https://XXXXXXXXXXXXXXXXXXXX.church.tools/
;api_user=XXXXXXXXXXXXXXXXXXXX
;api_password=XXXXXXXXXXXXXXXXXXXX
;dn_lower_case=true
;dn_lower_case=true
;email_lower_case=true
14 changes: 11 additions & 3 deletions ctldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var path = require('path');
var config = ini.parse(fs.readFileSync(path.resolve(__dirname, 'ctldap.config'), 'utf-8'));
if (config.debug) {
console.log("Debug mode enabled, expect lots of output!");
console.dir(config);
}

if (config.ldap_base_dn) {
Expand Down Expand Up @@ -48,6 +47,15 @@ Object.keys(config.sites).map(function(sitename, index) {
return s;
}
}
if (site.email_lower_case || ((site.email_lower_case === undefined) && config.email_lower_case)) {
site.compatTransformEmail = function (s) {
return s ? s.toLowerCase() : s;
}
} else {
site.compatTransformEmail = function (s) {
return s;
}
}
if (site.ct_uri.slice(-1) !== "/") {
site.ct_uri += "/";
}
Expand Down Expand Up @@ -204,8 +212,8 @@ function requestUsers (req, res, next) {
postalCode: v.plz,
l: v.ort,
sn: v.name,
email: v.email,
mail: v.email,
email: site.compatTransformEmail(v.email),
mail: site.compatTransformEmail(v.email),
objectclass: ['CTPerson'],
memberof: (results.userGroups[v.id] || []).map(function (cn) {
return site.compatTransform(site.fnGroupDn({ cn: cn }));
Expand Down

0 comments on commit 00456a2

Please sign in to comment.