feat: add setting to map an ldap attribute to the user's voice extension (#33598)

pull/33645/head
Pierre Lehnen 1 year ago committed by GitHub
parent 7726d68374
commit e3629e065b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      .changeset/shiny-falcons-vanish.md
  2. 1
      apps/meteor/app/importer/server/classes/converters/UserConverter.ts
  3. 11
      apps/meteor/server/lib/ldap/Manager.ts
  4. 5
      apps/meteor/server/settings/ldap.ts
  5. 1
      packages/core-typings/src/import/IImportUser.ts
  6. 1
      packages/i18n/src/locales/en.i18n.json

@ -0,0 +1,7 @@
---
'@rocket.chat/core-typings': minor
'@rocket.chat/i18n': minor
'@rocket.chat/meteor': minor
---
Adds a new setting to allow mapping LDAP attributes to the user's extension

@ -352,6 +352,7 @@ export class UserConverter extends RecordConverter<IImportUserRecord, UserConver
...(userData.importIds?.length && { importIds: userData.importIds }),
...(!!userData.customFields && { customFields: userData.customFields }),
...(userData.deleted !== undefined && { active: !userData.deleted }),
...(userData.voipExtension !== undefined && { freeSwitchExtension: userData.voipExtension }),
};
}

@ -167,6 +167,7 @@ export class LDAPManager {
const username = this.slugifyUsername(ldapUser, usedUsername || id || '') || undefined;
const emails = this.getLdapEmails(ldapUser, username).map((email) => email.trim());
const name = this.getLdapName(ldapUser) || undefined;
const voipExtension = this.getLdapExtension(ldapUser);
const userData: IImportUser = {
type: 'user',
@ -174,6 +175,7 @@ export class LDAPManager {
importIds: [ldapUser.dn],
username,
name,
voipExtension,
services: {
ldap: {
idAttribute,
@ -438,6 +440,15 @@ export class LDAPManager {
return this.getLdapDynamicValue(ldapUser, nameAttributes);
}
private static getLdapExtension(ldapUser: ILDAPEntry): string | undefined {
const extensionAttribute = settings.get<string>('LDAP_Extension_Field');
if (!extensionAttribute) {
return;
}
return this.getLdapString(ldapUser, extensionAttribute);
}
private static getLdapEmails(ldapUser: ILDAPEntry, username?: string): string[] {
const emailAttributes = getLDAPConditionalSetting<string>('LDAP_Email_Field');
if (emailAttributes) {

@ -209,6 +209,11 @@ export const createLdapSettings = () =>
enableQuery,
displayQuery: ldapOnly,
});
await this.add('LDAP_Extension_Field', '', {
type: 'string',
enableQuery,
});
});
await this.section('LDAP_DataSync_Avatar', async function () {

@ -18,4 +18,5 @@ export interface IImportUser {
customFields?: Record<string, any>;
password?: string;
voipExtension?: string;
}

@ -3063,6 +3063,7 @@
"LDAP_Server_Type_Other": "Other",
"LDAP_Name_Field": "Name Field",
"LDAP_Email_Field": "Email Field",
"LDAP_Extension_Field": "Extension Field",
"LDAP_Update_Data_On_Login": "Update User Data on Login",
"LDAP_Update_Data_On_OAuth_Login": "Update User Data on Login with OAuth services",
"LDAP_Advanced_Sync": "Advanced Sync",

Loading…
Cancel
Save