npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ldap-sj

v0.0.4

Published

LDAP Binding for node.js

Downloads

4

Readme

node-ldap

OpenLDAP client bindings for Node.js. Requires libraries from http://www.openldap.org installed.

Contributing

Any and all patches and pull requests are certainly welcome.

Thanks to:

  • Petr Běhan
  • YANG Xudong
  • Victor Powell

Dependencies

Node >= 0.6

For < 0.6 compaibility, check out v0.4

Installation

To build, ensure the OpenLDAP client libraries are installed, and

npm install https://github.com/jeremycx/node-LDAP/tarball/master -g

Connection.open(uri, version)

Opens a new connection to the LDAP server or servers. Does not make a connection attept (that is saved until the first command is issued).

Basically, this call will always succeeds, but may throw an error in the case of improper parameters. Will not return an error unless no memory is available.

Open Example

    var LDAPConnection = require("../LDAP").Connection;
    var LDAP = new LDAPConnection();
    
    if (LDAP.open("ldap://server1.domain.com ldap://server2.domain.com", 3) < 0) {
       throw new Error("Unable to connect to server");
    }                                                

Connection.simpleBind([dn, password,] callback(msgid, err));

Authenticates to the server. When the response is ready, or the timeout occurs, will execute the callback with the error value set.

dn and password must be omited, when doing anonymous bind.

Connection.search(base, scope, filter, attrs, function(msgid, err, data))

Searches LDAP within the given base for entries matching the given filter, and returns all attrs for matching entries. To get all available attrs, use "*".

Scopes are specified as one of the following integers:

  • Connection.BASE = 0;
  • Connection.ONELEVEL = 1;
  • Connection.SUBTREE = 2;
  • Connection.SUBORDINATE = 3;
  • Connection.DEFAULT = -1;

If a disconnect or other server error occurs, the backing library will attempt to reconnect automatically, and if this reconnection fails, Connection.open() will return -1.

See also "man 3 ldap" for details.

Connection.searchPaged(base, scope, filter, attrs, pageSize, function(msgid, err, data) [, cookie])

LDAP servers are usually limited in how many items they are willing to return - 1024 or 4096 are some typical values. For larger LDAP directories, you need to either partition your results with filter, or use paged search.

Note that it's only extension to the protocol, server doesn't have to support it. In such case, callback will be called with nonzero err (actually, it would be nice if someone could verify this, the server it was tested on had this feature).

Cookie parameter is only for internal use, leave it undefined in your calls.

Results are passed to callback function as they arrive in the same format as for simple search. Request for next page is sent only after the callback returns. After all data has arrived, callback is called once more, with data equal to null.

Search Example

    var LDAPConnection = require("../LDAP").Connection;
    var LDAP = new LDAPConnection();
    
    // Open a connection.
    LDAP.open("ldap://ldap1.example.com");
    LDAP.search("o=company", LDAP.SUBTREE, "(uid=alice)", "*", function(msgid, error, data) {
        switch(error) {
        case -2:
             console.log("Timeout");
             break;
        case -1:
             console.log("Server gone away");
             break;
        default:
            console.log(data[0].uid[0]);
            break;
        }                
    });

TODO:

  • Document Modify, Add and Rename
  • Testing against Microsoft Active Directory is welcomed, as I don't have a server to test against.