[GH-ISSUE #3208] LDAP auth #26841

Closed
opened 2026-04-17 17:33:30 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @fleetimee on GitHub (Jun 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3208

Is this suited for github?

  • Yes, this is suited for github

my office kinda using some kind of old auth like active directory i want to integrate into next js app, is that possible ?

Describe the solution you'd like

using like ldapjs

Describe alternatives you've considered

ldapjs

Additional context

No response

Originally created by @fleetimee on GitHub (Jun 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3208 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. my office kinda using some kind of old auth like active directory i want to integrate into next js app, is that possible ? ### Describe the solution you'd like using like ldapjs ### Describe alternatives you've considered ldapjs ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 17:33:30 -05:00
Author
Owner

@erickweil commented on GitHub (Jun 29, 2025):

I needed to do the same thing (integrate ldap login) and found very hard to do it using Better Auth.

Here what I did:

  1. Copied half the code from better auth project internals of how email & password and username login works, into a new plugin
  2. extracted the password checking logic to call the ldap server via ldap-authentication package
  3. after sucessfull login if the User and Account exists locally the flow is the same as the default (but with code duplicated)
  4. if the user don't exists locally, a new User and Account is created, if only the Account don't exists a new one is 'linked' (multiple login providers same user)

Altough I put it on npm better-auth-credentials-plugin hoping to help other people for now, I don't see this as the correct way to do it.

My view on this issue is that a generic 'Credentials' provider should be part of the native api, and implementing custom login logic (such as checking password on ldap) be easy as a callback with the custom logic, with all the better auth specifics handled already behind the scenes.

Just to be clear I'm not saying to copy auth.js Credentials, that isn't a complete solution, what I'm saying is that we should be able to override the password checking logic "Is this correct" true or false thing.

Also the existence of the username plugin shows how little the non-social login flow is customizable

<!-- gh-comment-id:3017149805 --> @erickweil commented on GitHub (Jun 29, 2025): I needed to do the same thing (integrate ldap login) and found very hard to do it using Better Auth. Here what I did: 1. Copied half the code from better auth project internals of how email & password and username login works, into a new plugin 2. extracted the password checking logic to call the ldap server via [ldap-authentication](https://www.npmjs.com/package/ldap-authentication) package 3. after sucessfull login if the User and Account exists locally the flow is the same as the default (but with code duplicated) 4. if the user don't exists locally, a new User and Account is created, if only the Account don't exists a new one is 'linked' (multiple login providers same user) Altough I put it on [npm better-auth-credentials-plugin](https://www.npmjs.com/package/better-auth-credentials-plugin) hoping to help other people for now, I don't see this as the correct way to do it. My view on this issue is that a generic 'Credentials' provider should be part of the native api, and implementing custom login logic (such as checking password on ldap) be easy as a callback with the custom logic, with all the better auth specifics handled already behind the scenes. Just to be clear I'm not saying to copy auth.js Credentials, that isn't a complete solution, what I'm saying is that we should be able to override the password checking logic "Is this correct" true or false thing. Also the existence of the username plugin shows how little the non-social login flow is customizable
Author
Owner

@dosubot[bot] commented on GitHub (Sep 28, 2025):

Hi, @fleetimee. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested LDAP (Active Directory) authentication support in a Next.js app, suggesting ldapjs as a potential solution.
  • A community member shared a workaround using a custom plugin with the ldap-authentication package, though it involves code duplication.
  • The suggestion was made to introduce a native "Credentials" provider to simplify custom password verification logic.
  • Several users appreciated the detailed workaround and the idea for native support.
  • The issue remains unresolved with no official LDAP integration yet.

Next Steps:

  • Please let me know if LDAP support is still relevant to your use case with the latest version of better-auth by commenting here.
  • If I don’t hear back within 7 days, I will automatically close this issue to keep the backlog manageable.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3343831001 --> @dosubot[bot] commented on GitHub (Sep 28, 2025): Hi, @fleetimee. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested LDAP (Active Directory) authentication support in a Next.js app, suggesting ldapjs as a potential solution. - A community member shared a workaround using a custom plugin with the ldap-authentication package, though it involves code duplication. - The suggestion was made to introduce a native "Credentials" provider to simplify custom password verification logic. - Several users appreciated the detailed workaround and the idea for native support. - The issue remains unresolved with no official LDAP integration yet. **Next Steps:** - Please let me know if LDAP support is still relevant to your use case with the latest version of better-auth by commenting here. - If I don’t hear back within 7 days, I will automatically close this issue to keep the backlog manageable. Thanks for your understanding and contribution!
Author
Owner

@mrctrifork commented on GitHub (Feb 6, 2026):

I find this issue relevant

<!-- gh-comment-id:3862291587 --> @mrctrifork commented on GitHub (Feb 6, 2026): I find this issue relevant
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26841