Created
January 10, 2026 01:38
-
-
Save aulisius/28b54fe83e4ce6ff50fd7a0ec4bd6847 to your computer and use it in GitHub Desktop.
simple-ldap-fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { authenticate } = require("ldap-authentication"); | |
| const LDAP_URL = "ldap://<LDAP_SERVER_IP>:<LDAP_SERVER_PORT>"; | |
| const LDAP_BIND_DN = "cn={0},OU=NotSynced...."; | |
| const LDAP_USER_DN = "cn=username,OU=NotSynced...."; | |
| const LDAP_USER_SEARCH_BASE = "OU=NotSynced...."; | |
| const LDAP_USERNAME_ATTRIBUTE = "name"; | |
| const LDAP_ATTRIBUTES = ["displayname"]; | |
| const LDAP_USERNAME = "username"; | |
| const LDAP_USER_PASSWORD = "password"; | |
| async function auth() { | |
| user = await authenticate({ | |
| ldapOpts: { | |
| url: LDAP_URL, | |
| bindDN: LDAP_BIND_DN, | |
| }, | |
| userDn: LDAP_USER_DN, | |
| userSearchBase: LDAP_USER_SEARCH_BASE, | |
| usernameAttribute: LDAP_USERNAME_ATTRIBUTE, | |
| attributes: LDAP_ATTRIBUTES, | |
| username: LDAP_USERNAME, | |
| userPassword: LDAP_USER_PASSWORD, | |
| }); | |
| console.log(user); | |
| } | |
| auth(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment