RocketChat / RocketChat/Rocket.Chat
Problem changing username on LDAP
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
Hello,
I have been using rocket.chat with ldap connection since 3 years. Every thing is working great.
The user name is about to change fot all users in our LDAP directory.
But if I change the username of one user in LDAP, and try to connect to RocketChat, the user is not found and I am getting this error in the logs :
{"level":50,"time":"2025-05-05T14:33:22.175Z","pid":93659,"hostname":"CDLC-CHAT","name":"Data Importer - LDAPUserConverter","err":{"type":"errorClass","message":"Email already exists. [403]","stack":"Error: Email already exists. [403]
at AccountsServer.insertUserDoc (packages/accounts-base/accounts_server.js:1223:15)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at AccountsServer.Accounts.insertUserDoc (app/authentication/server/startup/index.js:323:14)
at LDAPUserConverter.insertOrUpdateUser (app/importer/server/classes/converters/UserConverter.ts:241:19)
at LDAPUserConverter.convertRecord (app/importer/server/classes/converters/UserConverter.ts:53:3)
at LDAPUserConverter.iterateRecords (app/importer/server/classes/converters/RecordConverter.ts:219:19)
at LDAPUserConverter.convertData (app/importer/server/classes/converters/UserConverter.ts:64:4)
at Function.convertSingleUser (server/lib/ldap/UserConverter.ts:51:3)
at Function.syncUserForLogin (server/lib/ldap/Manager.ts:365:3)
at Function.addLdapUser (server/lib/ldap/Manager.ts:284:16)
at Function.login (server/lib/ldap/Manager.ts:53:11)
at packages/accounts-base/accounts_server.js:593:9
at tryLoginMethod (packages/accounts-base/accounts_server.js:1560:14)
at AccountsServer._runLoginHandlers (packages/accounts-base/accounts_server.js:592:22)
at AccountsServer.Accounts._runLoginHandlers (app/lib/server/lib/loginErrorMessageOverride.ts:9:17)
at MethodInvocation.methods.login (packages/accounts-base/accounts_server.js:654:22)","isClientSafe":true,"error":403,"reason":"Email already exists.","errorType":"Meteor.Error"},"msg":"Email already exists. [403]"}
It looks like RC is trying to create a new user but it fails because of the email beeing the same of the prévious user (prévious username).
What can I do to handle that problem ?
Steps to reproduce:
- Connect RC to LDAP
- Sync or connect with one of the user to create the RC user
- Modify the username in LDAP directory
- Try to connect with the new username
Server Setup Information:
- Version of Rocket.Chat Server: 7.5.1
- License Type: Community
- Operating System: Debian
Client Setup Information
- Desktop App : 4.3.3
- Operating System: Windows 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with server/lib/ldap/Manager.ts, especially the login, addLdapUser, and syncUserForLogin entries, then follow server/lib/ldap/UserConverter.ts and app/importer/server/classes/converters/UserConverter.ts. Reproduce the username-change steps and trace the existing email handling; done means the renamed LDAP user is handled without creating a conflicting account or producing “Email already exists.”
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100