1

I have tried to use the following code to retrieve the Lotus user detail by Node.js.

let ActiveDirectory = require('activedirectory');
let config = {
    attributes:{user: ["*"]},
    url: 'ldap://mylotusdominoserver',
    baseDN: 'OU=myOU,O=myOrg',    
}
let ad = new ActiveDirectory(config);

ad.authenticate(user, password, function (err, auth) {
    if (err) {
        console.log('ERROR0: ' + JSON.stringify(err));
        return;
    }

    if (auth) {
        console.log('Authenticated!');
        let query = "&(objectClass=*)(CN=Amy*)";
        ad.find(query, (err, results) => {
            if ((err) || (!results)) {
                console.log('ERROR1: ' + err);
                return;
            }
            console.log(results.other[0]);
        });
    }
    else {
        console.log('Authentication failed!');
    }
});

It returns:

Authenticated!
{
  dn: 'CN=Amy Tomson,OU=myOU,O=myOrg',
  mail: 'amyt@myOU.myOrg',
  sn: 'Amy',
  cn: 'Amy Tomson'
  objectclass: [Array],
  givenname: 'Amy',
  uid: 'amyt@myOU.myOrg',
  maildomain: 'myOrg'
}

However, the return attributes do not include the working title of the user, I have added the following attributes to force the server to return all attributes of the user.

attributes:{user: ["*"]},

However, it does not work. My Lotus Note Domino Server version is 9.0.

Is it possible to fix it?

The KNVB
  • 3,588
  • 3
  • 29
  • 54
  • 1
    The attributes you get are the default attributes for anonymous access... are you sure, that you are REALLY authenticated? can you mistype the password and check if anything changes? And: Why do you use "ActiveDirectory" and not any of the many ldap clients... I am not sure, that accessing a domino ldap with a specialized ActiveDirectory class works flawlessly – Tode Oct 18 '22 at 12:37
  • Which LDAP client should I use? – The KNVB Oct 18 '22 at 13:52
  • any that works for you... I did some node.js as my hobby and my profession is Domino Developer / Admin... but I never used both together... its just a suggestion as the ActiveDirectory npm could be specialist for active directory and deliver sub-par results for other ldap directories... – Tode Oct 18 '22 at 14:25
  • Thank you for your suggestion. What development tool have you used to talk with the domino server? – The KNVB Oct 18 '22 at 14:39
  • I develop ON Domino (with Domino Designer)... – Tode Oct 19 '22 at 06:25

1 Answers1

1

Finally, I use ldapjs library to fix the problem.

Here is the sample code:

const ldap = require('ldapjs');

var client = ldap.createClient({
    url: 'ldap://mylotusdominoserver'
});

client.bind(userName, password, function(err) {
  if (err) {
    console.log('ERROR0: ' + JSON.stringify(err));
    return;
  }
});
let opts = {
  attributes: ['givenname', 'sn', 'uid'],
  filter: '&(title=Manager)(uid=*myOU.myOrg)',
  scope: "sub",
}
client.search('OU=myOU,O=myOrg', opts, function(err, search) {
  if (err) {
    console.log('ERROR1: ' + JSON.stringify(err));
    return;
  }
  let results = [];
  search.on('searchEntry', function(entry) {
    results.push(entry.object);
  });
  search.on('end', function(entry) {
    console.log("End:" + entry.status);
    console.log(results);
    client.unbind(function(err) {
      console.log("Unbinded.");
      if (err) {
        console.log('ERROR3: ' + JSON.stringify(err));
        return;
      }
    });
  });
  search.on('error', error => {
    if (error) {
      console.log('ERROR2: ' + JSON.stringify(error));
      return;
    }
  });
});
The KNVB
  • 3,588
  • 3
  • 29
  • 54