RocketChat / RocketChat/Rocket.Chat

LDAP - User Data Field Map - Email field does not allow templating despite implication

Open
#14,091 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

area: authentication
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

When performing LDAP user synchronisation, user data is mapped from the LDAP server according to the mapping set in the "User Data Field Map" configuration option.

The help text implies templating is available for both fields ("name" and "email"):

Configure how user account fields (like email) are populated from a record in LDAP (once found).
As an example, {"cn":"name", "mail":"email"} will choose a person's human readable name from the cn attribute, and their email from the mail attribute. Additionally it is possible to use variables, for example: { "#{givenName} #{sn}": "name", "mail": "email" } uses a combination of the user's first name and last name for the rocket chat name field.
Available fields in Rocket.Chat: name, email and customFields.

However, templating doesn't work on the "email" field.

Steps to reproduce:
  1. Set the "User Data Field Map" to the value { "#{cn}":"name", "#{givenName}.#{sn}@anotherdomain.com":"email" }
  2. Log in as a newly created (unsynchronised) LDAP user. E.g:
    User with an LDAP "cn" field name of "joe"
    "givenName" of "Joe"
    "sn" of "Bloggs"
  3. Attempt to log in as newly created "joe" user
  4. Login fails
  5. View the debug logs (see below)
Expected behavior:

A new user gets synchronised with the following values:
name -> joe
email -> Joe.Bloggs@anotherdomain.com

Actual behavior:

Login error occurs, because the LDAP user is not synchronised. See log below.

Server Setup Information:
  • Version of Rocket.Chat Server: 0.74.3
  • Operating System: Ubuntu 18.04.2 LTS
  • Deployment Method: Snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: v8.11.4
  • MongoDB Version:
Relevant code

https://github.com/RocketChat/Rocket.Chat/blob/ed092fbe490c21d64c071772ce1da66515837353/app/ldap/server/sync.js#L91-L149

Relevant logs:

[34mI20190411-00:22:55.084(0) LDAPHandler ➔ debug userQuery { username: 'joe' }
I20190411-00:22:55.090(0) LDAPHandler ➔ info User does not exist, creating joe
I20190411-00:22:55.101(0) TemplateVarHandler ➔ debug template found. replacing values
I20190411-00:22:55.104(0) TemplateVarHandler ➔ debug replacing template var: #{cn} with value: joe
I20190411-00:22:55.108(0) LDAPSync ➔ debug user.name changed to: joe
I20190411-00:22:55.111(0) LDAPSync ➔ debug user does not have attribute: #{givenName}.#{sn}@anotherdomain.com
I20190411-00:22:55.138(0) rocketchat:logger server.js:199 LDAPSync ➔ error...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.