Skip to content
Snippets Groups Projects
Unverified Commit e2c0fc95 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento Committed by GitHub
Browse files

Merge pull request #8691 from RocketChat/hotfix/ldap-utf8

[FIX] LDAP not respecting UTF8 characters & Sync Interval not working
parents ed355073 fa034c23
No related branches found
No related tags found
No related merge requests found
......@@ -349,11 +349,19 @@ export default class LDAP {
}
extractLdapEntryData(entry) {
const values = entry.raw;
Object.keys(values).forEach((key) => {
const value = values[key];
if (!['thumbnailPhoto', 'jpegPhoto'].includes(key) && value instanceof Buffer) {
values[key] = value.toString('binary');
const values = {
_raw: entry.raw
};
Object.keys(values._raw).forEach((key) => {
const value = values._raw[key];
if (!['thumbnailPhoto', 'jpegPhoto'].includes(key)) {
if (value instanceof Buffer) {
values[key] = value.toString();
} else {
values[key] = value;
}
}
});
......
......@@ -47,12 +47,12 @@ export function getLdapUserUniqueID(ldapUser) {
if (Unique_Identifier_Field.length > 0) {
Unique_Identifier_Field = Unique_Identifier_Field.find((field) => {
return !_.isEmpty(ldapUser[field]);
return !_.isEmpty(ldapUser._raw[field]);
});
if (Unique_Identifier_Field) {
Unique_Identifier_Field = {
attribute: Unique_Identifier_Field,
value: new Buffer(ldapUser[Unique_Identifier_Field], 'binary').toString('hex')
value: ldapUser._raw[Unique_Identifier_Field].toString('hex')
};
}
return Unique_Identifier_Field;
......@@ -151,7 +151,7 @@ export function syncUserData(user, ldapUser) {
}
if (user && user._id && RocketChat.settings.get('LDAP_Sync_User_Avatar') === true) {
const avatar = ldapUser.thumbnailPhoto || ldapUser.jpegPhoto;
const avatar = ldapUser._raw.thumbnailPhoto || ldapUser._raw.jpegPhoto;
if (avatar) {
logger.info('Syncing user avatar');
......@@ -343,15 +343,16 @@ const addCronJob = _.debounce(Meteor.bindEnvironment(function addCronJobDebounce
return;
}
if (RocketChat.settings.get('LDAP_Sync_Interval')) {
if (RocketChat.settings.get('LDAP_Background_Sync_Interval')) {
logger.info('Enabling LDAP Background Sync');
SyncedCron.add({
name: jobName,
schedule: (parser) => parser.text(RocketChat.settings.get('LDAP_Sync_Interval')),
schedule: (parser) => parser.text(RocketChat.settings.get('LDAP_Background_Sync_Interval')),
job() {
sync();
}
});
SyncedCron.start();
}
}), 500);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment