node-ldapjs icon indicating copy to clipboard operation
node-ldapjs copied to clipboard

Unable to match DN in [email protected] version

Open reena-obc opened this issue 2 years ago • 4 comments

I want to match subject and get output "true" but getting "false" in ldapjs version 3.0.0, it was "true" in ldapjs version 2.3.3. import ldapjs from 'ldapjs';

function subjectMatches(actual, expected) { try { const actualDN = ldapjs.parseDN(actual); const expectedDN = ldapjs.parseDN(expected); const actualRDNs = actualDN.rdns.map(rdn => rdn.toString()); const expectedRDNs = expectedDN.rdns.map(rdn => rdn.toString()); const checker = (arr, target) => target.every(v => arr.includes(v)); if (actualRDNs.length != expectedRDNs.length || !checker(expectedRDNs, actualRDNs)) { throw new Error('invalid tls_client_auth_subject_dn claim'); } } catch (err) { return false; } return true; } // Certificate, eidas, subject DN, RDNs console.log( subjectMatches( 'CN=875HGJHJHJ,organizationIdentifier=xyz-abc-123,O=ABC,C=GB', 'CN=875HGJHJHJ,organizationIdentifier=xyz-abc-123,O=ABC,C=GB', ), );

reena-obc avatar Oct 11 '23 05:10 reena-obc

How to Extract RDNs

reena-obc avatar Oct 11 '23 08:10 reena-obc

Please provide a minimal reproducible example (MRE). Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code. Please review the integration tests, e.g. issue-940.test.js, for examples of good MREs.

You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).

jsumners avatar Oct 11 '23 13:10 jsumners

They did provide a MRE, albeit terribly formated and obviously a coding error, a catch all that returns false and an error before.

rdns is now considered private and you cannot call map on it.

I suggest to look at https://github.com/ldapjs/node-ldapjs/blob/master/docs/dn.md how to compare DNs

Note that dns a few more public function than mentioned in the docs (but I think not needed here) https://github.com/ldapjs/dn/blob/master/lib/dn.js

IMO with this this can be closed.

axkibe avatar Nov 24 '23 16:11 axkibe

if rdns is an array of rdn objects, why make rdns private? There are useful functions in the rdn object to use, but you can't get at them...

I'm not following now to use a dn object, similar to this guy's question. And, the docs say to reference the rdns object in dn.rdns, so.....I'm guessing it's just outdated docs.

craigify avatar Dec 03 '23 02:12 craigify