Skip to content

Instantly share code, notes, and snippets.

@traxanos
Created October 19, 2017 10:33
Show Gist options
  • Save traxanos/e4134f46dc6c525e3b102dcfcaf62813 to your computer and use it in GitHub Desktop.
Save traxanos/e4134f46dc6c525e3b102dcfcaf62813 to your computer and use it in GitHub Desktop.
Fix LDAP Support for Rocket.Chat - 0.59.0
--- a/programs/server/packages/rocketchat_ldap.js 2017-10-19 03:11:23.000000000 +0200
+++ b/programs/server/packages/rocketchat_ldap.js 2017-10-19 12:27:24.233291935 +0200
@@ -1065,11 +1065,11 @@
//
if (usernameField.indexOf('#{') > -1) { // 19
return usernameField.replace(/#{(.+?)}/g, function (match, field) { // 20
- return ldapUser[field]; // 21
+ return ldapUser.object[field]; // 21
}); // 22
} // 23
//
- return ldapUser[usernameField]; // 25
+ return ldapUser.object[usernameField]; // 25
} // 26
//
function getLdapUserUniqueID(ldapUser) { // 29
@@ -1093,13 +1093,13 @@
//
if (Unique_Identifier_Field.length > 0) { // 48
Unique_Identifier_Field = Unique_Identifier_Field.find(function (field) { // 49
- return !_.isEmpty(ldapUser[field]); // 50
+ return !_.isEmpty(ldapUser.object[field]); // 50
}); // 51
//
if (Unique_Identifier_Field) { // 52
Unique_Identifier_Field = { // 53
attribute: Unique_Identifier_Field, // 54
- value: new Buffer(ldapUser[Unique_Identifier_Field]).toString('hex') // 55
+ value: new Buffer(ldapUser.object[Unique_Identifier_Field]).toString('hex') // 55
}; // 53
} // 57
//
@@ -1125,8 +1125,8 @@
return; // 77
} // 78
//
- if (_.isObject(ldapUser[ldapField])) { // 80
- _.map(ldapUser[ldapField], function (item) { // 81
+ if (_.isObject(ldapUser.object[ldapField])) { // 80
+ _.map(ldapUser.object[ldapField], function (item) { // 81
emailList.push({ // 82
address: item, // 82
verified: true // 82
@@ -1134,7 +1134,7 @@
}); // 83
} else { // 84
emailList.push({ // 85
- address: ldapUser[ldapField], // 85
+ address: ldapUser.object[ldapField], // 85
verified: true // 85
}); // 85
} // 86
@@ -1223,7 +1223,7 @@
} // 151
//
if (user && user._id && RocketChat.settings.get('LDAP_Sync_User_Avatar') === true) { // 153
- var avatar = ldapUser.thumbnailPhoto || ldapUser.jpegPhoto; // 154
+ var avatar = ldapUser.object['thumbnailPhoto'] || ldapUser.object['jpegPhoto']; // 154
//
if (avatar) { // 155
logger.info('Syncing user avatar'); // 156
@@ -1264,8 +1264,8 @@
} else { // 193
userObject.email = userData.emails[0].address; // 194
} // 195
- } else if (ldapUser.mail && ldapUser.mail.indexOf('@') > -1) { // 196
- userObject.email = ldapUser.mail; // 197
+ } else if (ldapUser.object['mail'] && ldapUser.object['mail'].indexOf('@') > -1) { // 196
+ userObject.email = ldapUser.object['mail']; // 197
} else if (RocketChat.settings.get('LDAP_Default_Domain') !== '') { // 198
userObject.email = (username || uniqueId.value) + "@" + RocketChat.settings.get('LDAP_Default_Domain'); // 199
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment