2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
2012-02-18 08:54:22 +00:00
|
|
|
var Logger = require('bunyan');
|
|
|
|
|
2012-04-27 03:23:43 +00:00
|
|
|
var client = require('./client');
|
2011-08-06 20:44:26 +00:00
|
|
|
var Attribute = require('./attribute');
|
|
|
|
var Change = require('./change');
|
|
|
|
var Protocol = require('./protocol');
|
|
|
|
var Server = require('./server');
|
|
|
|
|
2011-12-08 01:02:17 +00:00
|
|
|
var assert = require('assert');
|
2011-12-09 21:59:17 +00:00
|
|
|
var controls = require('./controls');
|
2012-02-23 23:21:17 +00:00
|
|
|
var persistentSearch = require('./persistent_search');
|
2011-08-04 20:32:01 +00:00
|
|
|
var dn = require('./dn');
|
|
|
|
var errors = require('./errors');
|
|
|
|
var filters = require('./filters');
|
2011-08-06 20:44:26 +00:00
|
|
|
var messages = require('./messages');
|
2011-08-04 20:32:01 +00:00
|
|
|
var url = require('./url');
|
|
|
|
|
2013-01-15 20:19:20 +00:00
|
|
|
// Guid formatting
|
|
|
|
|
2013-01-30 23:52:44 +00:00
|
|
|
// N specifier, 32 digits:
|
2013-01-15 20:19:20 +00:00
|
|
|
// 00000000000000000000000000000000
|
2013-01-30 23:52:44 +00:00
|
|
|
/* JSSTYLED */
|
2013-01-15 20:19:20 +00:00
|
|
|
var GUID_FORMAT_N = '{3}{2}{1}{0}{5}{4}{7}{6}{8}{9}{10}{11}{12}{13}{14}{15}';
|
2013-01-30 23:52:44 +00:00
|
|
|
|
2013-01-15 20:19:20 +00:00
|
|
|
// D specifier, 32 digits separated by hypens:
|
|
|
|
// 00000000-0000-0000-0000-000000000000
|
2013-01-30 23:52:44 +00:00
|
|
|
/* JSSTYLED */
|
2013-01-15 20:19:20 +00:00
|
|
|
var GUID_FORMAT_D = '{3}{2}{1}{0}-{5}{4}-{7}{6}-{8}{9}-{10}{11}{12}{13}{14}{15}';
|
2013-01-30 23:52:44 +00:00
|
|
|
|
2013-01-15 20:19:20 +00:00
|
|
|
// B specifier, 32 digits separated by hyphens, enclosed in braces:
|
|
|
|
// {00000000-0000-0000-0000-000000000000}
|
2013-01-30 23:52:44 +00:00
|
|
|
/* JSSTYLED */
|
2013-01-15 20:19:20 +00:00
|
|
|
var GUID_FORMAT_B = '{{3}{2}{1}{0}-{5}{4}-{7}{6}-{8}{9}-{10}{11}{12}{13}{14}{15}}';
|
2013-01-30 23:52:44 +00:00
|
|
|
|
2013-01-15 20:19:20 +00:00
|
|
|
// P specifier, 32 digits separated by hyphens, enclosed in parentheses:
|
|
|
|
// (00000000-0000-0000-0000-000000000000)
|
2013-01-30 23:52:44 +00:00
|
|
|
/* JSSTYLED */
|
2013-01-15 20:19:20 +00:00
|
|
|
var GUID_FORMAT_P = '({3}{2}{1}{0}-{5}{4}-{7}{6}-{8}{9}-{10}{11}{12}{13}{14}{15})';
|
2013-01-30 23:52:44 +00:00
|
|
|
|
|
|
|
// X specifier, Four hexadecimal values enclosed in braces,
|
|
|
|
// where the fourth value is a subset of eight hexadecimal values that is also
|
|
|
|
// enclosed in braces:
|
2013-01-15 20:19:20 +00:00
|
|
|
// {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
|
2013-01-30 23:52:44 +00:00
|
|
|
/* JSSTYLED */
|
2013-01-15 20:19:20 +00:00
|
|
|
var GUID_FORMAT_X = '{0x{3}{2}{1}{0},0x{5}{4},0x{7}{6},{0x{8},0x{9},0x{10},0x{11},0x{12},0x{13},0x{14},0x{15}}}';
|
2011-12-09 21:59:17 +00:00
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
/// Hack a few things we need (i.e., "monkey patch" the prototype)
|
|
|
|
|
|
|
|
if (!String.prototype.startsWith) {
|
2012-02-24 00:02:52 +00:00
|
|
|
String.prototype.startsWith = function (str) {
|
2011-08-04 20:32:01 +00:00
|
|
|
var re = new RegExp('^' + str);
|
|
|
|
return re.test(this);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!String.prototype.endsWith) {
|
2012-02-24 00:02:52 +00:00
|
|
|
String.prototype.endsWith = function (str) {
|
2011-08-04 20:32:01 +00:00
|
|
|
var re = new RegExp(str + '$');
|
|
|
|
return re.test(this);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///--- API
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
2012-04-27 03:23:43 +00:00
|
|
|
createClient: client.createClient,
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2011-08-06 20:44:26 +00:00
|
|
|
Server: Server,
|
2012-02-24 00:02:52 +00:00
|
|
|
createServer: function (options) {
|
2012-02-18 08:54:22 +00:00
|
|
|
if (options === undefined)
|
|
|
|
options = {};
|
|
|
|
|
|
|
|
if (typeof (options) !== 'object')
|
|
|
|
throw new TypeError('options (object) required');
|
|
|
|
|
|
|
|
if (!options.log) {
|
|
|
|
options.log = new Logger({
|
|
|
|
name: 'ldapjs',
|
|
|
|
component: 'client',
|
|
|
|
stream: process.stderr
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-08-06 20:44:26 +00:00
|
|
|
return new Server(options);
|
|
|
|
},
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2011-08-19 22:08:23 +00:00
|
|
|
Attribute: Attribute,
|
|
|
|
Change: Change,
|
2011-12-08 01:02:17 +00:00
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
DN: dn.DN,
|
2012-02-23 23:21:17 +00:00
|
|
|
PersistentSearchCache: persistentSearch.PersistentSearchCache,
|
2011-08-10 17:57:58 +00:00
|
|
|
RDN: dn.RDN,
|
2012-02-23 23:21:17 +00:00
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
parseDN: dn.parse,
|
2011-08-19 22:08:23 +00:00
|
|
|
dn: dn,
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-23 23:21:17 +00:00
|
|
|
persistentSearch: persistentSearch,
|
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
filters: filters,
|
|
|
|
parseFilter: filters.parseString,
|
|
|
|
|
2011-08-19 22:08:23 +00:00
|
|
|
parseURL: url.parse,
|
2012-02-21 01:21:53 +00:00
|
|
|
|
2013-01-15 20:19:20 +00:00
|
|
|
url: url,
|
|
|
|
|
|
|
|
GUID_FORMAT_N: GUID_FORMAT_N,
|
|
|
|
GUID_FORMAT_D: GUID_FORMAT_D,
|
|
|
|
GUID_FORMAT_B: GUID_FORMAT_B,
|
|
|
|
GUID_FORMAT_P: GUID_FORMAT_P,
|
|
|
|
GUID_FORMAT_X: GUID_FORMAT_X
|
2011-08-04 20:32:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-12-09 21:59:17 +00:00
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
///--- Export all the childrenz
|
|
|
|
|
|
|
|
var k;
|
|
|
|
|
|
|
|
for (k in Protocol) {
|
|
|
|
if (Protocol.hasOwnProperty(k))
|
|
|
|
module.exports[k] = Protocol[k];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k in messages) {
|
|
|
|
if (messages.hasOwnProperty(k))
|
|
|
|
module.exports[k] = messages[k];
|
|
|
|
}
|
|
|
|
|
2011-12-09 21:59:17 +00:00
|
|
|
for (k in controls) {
|
|
|
|
if (controls.hasOwnProperty(k))
|
|
|
|
module.exports[k] = controls[k];
|
|
|
|
}
|
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
for (k in filters) {
|
|
|
|
if (filters.hasOwnProperty(k)) {
|
|
|
|
if (k !== 'parse' && k !== 'parseString')
|
|
|
|
module.exports[k] = filters[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k in errors) {
|
|
|
|
if (errors.hasOwnProperty(k)) {
|
|
|
|
module.exports[k] = errors[k];
|
|
|
|
}
|
|
|
|
}
|