Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Missing LDAP reconnect setting #8414

Merged
merged 1 commit into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,8 @@
"LDAP_Merge_Existing_Users_Description": "*Caution!* When importing an user from LDAP and an user with same username already exists the LDAP info and password will be set into the existing user.",
"LDAP_Port": "Port",
"LDAP_Port_Description": "Port to access LDAP. eg: `389` or `636` for LDAPS",
"LDAP_Reconnect": "Reconnect",
"LDAP_Reconnect_Description": "Try to reconnect automatically when connection is interrupted by some reason while executing operations",
"LDAP_Reject_Unauthorized": "Reject Unauthorized",
"LDAP_Reject_Unauthorized_Description": "Disable this option to allow certificates that can not be verified. Usually Self Signed Certificates will require this option disabled to work",
"LDAP_Sync_User_Avatar": "Sync User Avatar",
Expand Down
14 changes: 3 additions & 11 deletions packages/rocketchat-ldap/server/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class LDAP {
this.options = {
host: RocketChat.settings.get('LDAP_Host'),
port: RocketChat.settings.get('LDAP_Port'),
Reconnect: RocketChat.settings.get('LDAP_Reconnect'),
timeout: RocketChat.settings.get('LDAP_Timeout'),
connect_timeout: RocketChat.settings.get('LDAP_Connect_Timeout'),
idle_timeout: RocketChat.settings.get('LDAP_Idle_Timeout'),
Expand Down Expand Up @@ -68,7 +69,7 @@ export default class LDAP {
timeout: this.options.timeout,
connectTimeout: this.options.connect_timeout,
idleTimeout: this.options.idle_timeout,
reconnect: true
reconnect: this.options.Reconnect
};

const tlsOptions = {
Expand Down Expand Up @@ -363,22 +364,13 @@ export default class LDAP {
logger.search.debug('Page');
// Force LDAP idle to wait the record processing
this.client._updateIdle(true);
page(null, entries, {end: false, next: () => {
page(null, entries, {end: !next, next: () => {
// Reset idle timer
this.client._updateIdle();
next && next();
}});
entries = [];
});

res.on('end', () => {
logger.search.info('Search result count', entries.length);
page(null, [], {end: true, next: () => {
// Reset idle timer
this.client._updateIdle();
}});
// logger.search.debug('Search result', JSON.stringify(jsonEntries, null, 2));
});
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ldap/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RocketChat.settings.addGroup('LDAP', function() {
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery });
this.add('LDAP_Host', '', { type: 'string', enableQuery });
this.add('LDAP_Port', '389', { type: 'string', enableQuery });
this.add('LDAP_Reconnect', false, { type: 'boolean', enableQuery });
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], enableQuery });
this.add('LDAP_CA_Cert', '', { type: 'string', multiline: true, enableQuery: enableTLSQuery });
this.add('LDAP_Reject_Unauthorized', true, { type: 'boolean', enableQuery: enableTLSQuery });
Expand Down
15 changes: 9 additions & 6 deletions packages/rocketchat-ldap/server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function importNewUsers(ldap) {
}

let count = 0;
ldap.searchUsersSync('*', Meteor.bindEnvironment((error, ldapUsers, {next} = {}) => {
ldap.searchUsersSync('*', Meteor.bindEnvironment((error, ldapUsers, {next, end} = {}) => {
if (error) {
throw error;
}
Expand Down Expand Up @@ -275,14 +275,17 @@ export function importNewUsers(ldap) {
}
}

if (count % 1000 === 0) {
logger.info('Imported:', count);
if (count % 100 === 0) {
logger.info('Import running. Users imported until now:', count);
}
});
next && next();
}));

logger.info('Imported:', count);
if (end) {
logger.info('Import finished. Users imported:', count);
}

next(count);
}));
}

function sync() {
Expand Down