<commit_before>
/**
 * Module dependencies
 */

var config    = require('./config.js');
var ldapjs    = require('ldapjs');
var log       = require('logule').init(module, "ldap");
var util      = require('util');

/**
 * Initialize ldap
 *
 * @constructor
 */

function ldap() {
  var self = this;

  this.connected = false;

  /**
   * ldap client
   */

  this.client = ldapjs.createClient({
    url: util.format('ldap://%s/', config.ldap.host),
    connectTimeout: 5000
  });

  /**
   * ldap event handlers
   */

  this.client.on('connect', self._handleConnect.bind(self));
  this.client.on('connectTimeout', self._handleConnectTimeout.bind(self));
  this.client.on('connectError', self._handleConnectError.bind(self));

  // ..

  log.info('init');
}

/**
 *
 * @param socket
 * @private
 */

ldap.prototype._handleConnect = function(socket) {
  this.connected = true;
};

/**
 *
 * @private
 */

ldap.prototype._handleConnectTimeout = function() {
  log.error('connection timed out');
};

/**
 *
 * @private
 */

ldap.prototype._handleConnectError = function(error) {
  log.error('error connecting');
};

/**
 * Find user for usbSerial `id` or nfcID `id`
 *
 * @param device
 * @param fn
 */

ldap.prototype.findUserForDevice = function(id, fn) {
  this._query(util.format('(|(usbSerial=%s)(nfcID=%s))', id, id), fn);
};

/**
 * Find user for usbSerial `device`
 *
 * @param device
 * @param fn
 */

ldap.prototype.findUserForUSBSerial = function(serial, fn) {
  this._query(util.format('usbSerial=%s', serial), fn);
};<commit_msg>higher connection timeout<commit_after>
/**
 * Module dependencies
 */

var config    = require('./config.js');
var ldapjs    = require('ldapjs');
var log       = require('logule').init(module, "ldap");
var util      = require('util');

/**
 * Initialize ldap
 *
 * @constructor
 */

function ldap() {
  var self = this;

  this.connected = false;

  /**
   * ldap client
   */

  this.client = ldapjs.createClient({
    url: util.format('ldap://%s/', config.ldap.host),
    connectTimeout: 10000
  });

  /**
   * ldap event handlers
   */

  this.client.on('connect', self._handleConnect.bind(self));
  this.client.on('connectTimeout', self._handleConnectTimeout.bind(self));
  this.client.on('connectError', self._handleConnectError.bind(self));

  // ..

  log.info('init');
}

/**
 * connect success, set connected true
 *
 * @param socket
 * @private
 */

ldap.prototype._handleConnect = function(socket) {
  this.connected = true;
};

/**
 * connect timed out
 *
 * @private
 */

ldap.prototype._handleConnectTimeout = function() {
  log.error('connection timed out');
};

/**
 * connect failed
 *
 * @private
 */

ldap.prototype._handleConnectError = function(error) {
  log.error('error connecting');
};

/**
 * Find user for usbSerial `id` or nfcID `id`
 *
 * @param device
 * @param fn
 */

ldap.prototype.findUserForDevice = function(id, fn) {
  this._query(util.format('(|(usbSerial=%s)(nfcID=%s))', id, id), fn);
};

/**
 * Find user for usbSerial `device`
 *
 * @param device
 * @param fn
 */

ldap.prototype.findUserForUSBSerial = function(serial, fn) {
  this._query(util.format('usbSerial=%s', serial), fn);
};
{'fraction_non_alphanumeric': 0.18388625592417063, 'fraction_numerical': 0.002843601895734597, 'mean_word_length': 3.4907801418439717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '558656', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1059, 'n_words': 206}