Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I never used ldapjs, but based on what I just quickly read in its seemingly incomplete document, it can be used to implement an LDAP server or an LDAP client, which seems to be what you're trying to do (i.e., I'm assuming you want to authenticate users in your application against an existing LDAP server). Most of the examples in its document focus on creating an LDAP server that listens on a certain port and interacts with a back-end database. If you're not trying to put an LDAP-based interface between your back-end database or store of users and passwords, then you probably don't need the server API. If you already have an LDAP server running, then you will need to use its client API to do something like this:</p> <p>1.Bind anonymously to the LDAP server that provides the directory services including the authentication services. It looks like you can just do this with:</p> <pre><code>var ldap = require('ldapjs'); var client = ldap.createClient({ url: 'ldap://my.ldap.server' }); </code></pre> <p>2.Search by the username (e.g., e-mail address) for the corresponding entry's DN </p> <pre><code>var opts = { filter: '(mail=USERNAME)', scope: 'sub' }; client.search('ou=users,o=acme.com', opts, function(err, res) { assert.ifError(err); res.on('searchEntry', function(entry) { console.log('entry: ' + JSON.stringify(entry.object)); }); res.on('searchReference', function(referral) { console.log('referral: ' + referral.uris.join()); }); res.on('error', function(err) { console.error('error: ' + err.message); }); res.on('end', function(result) { console.log('status: ' + result.status); }); }); </code></pre> <p>3.Grab the DN of the returned entry ( entry.object ). The documentation of this library doesn't talk much about how these objects can be used (e.g., what their methods, properties, etc. are). So, you will have to figure out how to actually get the DN or string representation of the DN of the entry you just retrieved from the directory server. [<em>See the comment(s) below this answer</em>] </p> <p>4.Rebind to the server using that DN:</p> <pre><code>client.bind(DN_RETRIEVED, PASSWORD_USER_ENTERED, function(err) { assert.ifError(err); }); </code></pre> <p>5.The result of the bind above is what you will need to use to determine whether or not the authentication was successful.</p> <p>If you are trying to implement an LDAP server in front of your user/password data store for LDAP-based authentication, then you will need to follow their server examples. I personally think this is an overkill and could be problematic in terms of security. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload