How to use the ldapjs.parseDN function in ldapjs

To help you get started, we’ve selected a few ldapjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PhilWaldmann / openrecord / lib / stores / ldap / includes.js View on Github external
this.afterInclude(function(Model, result, records, include, cache){
      var relation = include.relation
      if(!relation || !relation.ldap) return
      if(!result) return

      var type = include.relation.ldap

      if(!Array.isArray(result)) result = [result]

      for(var i = 0; i < result.length; i++){
        var dn = result[i].dn


        if(type === 'children'){
          dn = parseDN(dn).parent()

          if(relation.recursive){
            var found = false
            do{
              if(cache.dn_mapping[Utils.normalizeDn(dn)]){
                found = true
                break
              }
              if(!dn.parent()){
                found = true // actually not, but we stop the loop here...
              }else{
                dn = dn.parent()
              }
            }while(!found)
          }
github PhilWaldmann / openrecord / test / ldap / __server.js View on Github external
scopeCheck = function(k) {
          if (req.dn.equals(k)) {
            return true
          }

          var parent = ldap.parseDN(k).parent()
          return parent ? parent.equals(req.dn) : false
        }
        break
github thelounge / thelounge / test / plugins / auth / ldap.js View on Github external
function normalizeDN(dn) {
	return ldap.parseDN(dn).toString();
}
github accordproject / concerto / packages / composer-tests-integration / scripts / ldap.js View on Github external
users.forEach((user) => {
    const { cn, name, credentials } = user;
    db[user.cn] = {
        dn: ldap.parseDN(`cn=${cn}, ${suffix}`),
        attributes: {
            uid: cn,
            name,
            mail: `${cn}@${domain}`
        },
        credentials
    };
});
github flamencist / ldap4net / .test_config / index.js View on Github external
scopeCheck = function(k) {
      if(k === "rootDse")
        return false;
      if (req.dn.equals(k))
        return true;

      var parent = ldap.parseDN(k).parent();
      return (parent ? parent.equals(req.dn) : false);
    };
    break;
github trueaccord / FallingRock / server.js View on Github external
oktaDirectory.users.forEach(function(user) {
            user.shortName = user.profile.email.split('@')[0];
            var dn = interpolateObject(config.okta.userDN, user);
            user.dn = ldap.parseDN(dn).toString();
        });
github PhilWaldmann / openrecord / lib / stores / ldap / includes.js View on Github external
this.beforeInclude(function(Chains, records, include, cache){
      var relation = include.relation
      if(!relation || !relation.ldap) return

      cache.dn_mapping = {}

      var type = relation.ldap
      var dns = []

      for(var i = 0; i < records.length; i++){
        var dn = records[i].dn

        if(type === 'parent'){
          dn = Utils.normalizeDn(parseDN(records[i].dn).parent().toString())
        }else{
          if(type !== 'children' && records[i][type] && relation.type === 'belongs_to_many'){
            dn = Utils.normalizeDn(records[i][type])
          }
        }

        if(!dn) dn = []
        if(!Array.isArray(dn)) dn = [dn]

        for(var d = 0; d < dn.length; d++){
          cache.dn_mapping[dn[d]] = cache.dn_mapping[dn[d]] || []
          cache.dn_mapping[dn[d]].push(records[i])

          if(dns.indexOf(dn[d]) === -1){
            dns.push(dn[d])
github PhilWaldmann / openrecord / lib / stores / ldap / utils.js View on Github external
normalizeDn: function(dn, lowercased) {
    if (Array.isArray(dn)) {
      for (var i = 0; i < dn.length; i++) {
        dn[i] = this.normalizeDn(dn[i])
      }

      return dn
    }
    try {
      dn = parseDN(dn.toString())
        .toString()
        .replace(/, /g, ',')
      if (lowercased !== false) dn = dn.toLowerCase()
      return dn
    } catch (e) {
      return null
    }
  },