Bonjour,

J'essaie d'utiliser le package ldap-authentication dans une appli React.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
import { authenticate } from 'ldap-authentication';
...
let authenticated = await authenticate({
        ldapOpts: { url: ldapConfig.url },
        userDn: `uid=${login},${ldapConfig.userSearchBase}`,
        userPassword: password,
        userSearchBase: ldapConfig.userSearchBase,
        usernameAttribute: 'uid',
        username: login,
        //starttls: true,
        attributes: ['dn', 'sn', 'cn'],
      })
Quand je lance, j'ai un message d'erreur (sous FireFox) :
Error.captureStackTrace is not a function
Sous Chrome, le message d'erreur est différent :
TypeError: ldapts.Client is not a constructor
Qu'est ce qui cloche ?

Ma config :
React 19.1.0
ldap-authentication 3.3.4
node-polyfill-webpack-plugin 4.1.0,

obligé d'installer node-polyfill-webpack-plugin, sinon message d'erreur :
Module not found: Error: Can't resolve 'assert' in '<mypath>\<myproject>\node_modules\ldap-authentication'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }

Merci,
Nico