diff --git a/.changeset/shiny-falcons-vanish.md b/.changeset/shiny-falcons-vanish.md new file mode 100644 index 000000000000..d4130fad5cfb --- /dev/null +++ b/.changeset/shiny-falcons-vanish.md @@ -0,0 +1,7 @@ +--- +'@rocket.chat/core-typings': minor +'@rocket.chat/i18n': minor +'@rocket.chat/meteor': minor +--- + +Added a new setting to allow mapping LDAP attributes to the user's extension diff --git a/apps/meteor/app/importer/server/classes/converters/UserConverter.ts b/apps/meteor/app/importer/server/classes/converters/UserConverter.ts index 7401aea7c234..2d2bb7bad80a 100644 --- a/apps/meteor/app/importer/server/classes/converters/UserConverter.ts +++ b/apps/meteor/app/importer/server/classes/converters/UserConverter.ts @@ -352,6 +352,7 @@ export class UserConverter extends RecordConverter 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('LDAP_Extension_Field'); + if (!extensionAttribute) { + return; + } + + return this.getLdapString(ldapUser, extensionAttribute); + } + private static getLdapEmails(ldapUser: ILDAPEntry, username?: string): string[] { const emailAttributes = getLDAPConditionalSetting('LDAP_Email_Field'); if (emailAttributes) { diff --git a/apps/meteor/server/settings/ldap.ts b/apps/meteor/server/settings/ldap.ts index cbc7e8f5db9d..d0d77d4ec345 100644 --- a/apps/meteor/server/settings/ldap.ts +++ b/apps/meteor/server/settings/ldap.ts @@ -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 () { diff --git a/packages/core-typings/src/import/IImportUser.ts b/packages/core-typings/src/import/IImportUser.ts index 317b6240bfe4..de3b7806a300 100644 --- a/packages/core-typings/src/import/IImportUser.ts +++ b/packages/core-typings/src/import/IImportUser.ts @@ -18,4 +18,5 @@ export interface IImportUser { customFields?: Record; password?: string; + voipExtension?: string; } diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index 4ea13ecaee16..387f261b8e0f 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -3057,6 +3057,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",