Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Unable to match DN in ldapjs@3.0.0 version #947

Open
reena-obc opened this issue Oct 11, 2023 · 4 comments
Open

Unable to match DN in ldapjs@3.0.0 version #947

reena-obc opened this issue Oct 11, 2023 · 4 comments

Comments

@reena-obc
Copy link

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 reena-obc changed the title Unable to match DN in 3.0.0 version Unable to match DN in ldapjs@3.0.0 version Oct 11, 2023
@reena-obc
Copy link
Author

How to Extract RDNs

@jsumners
Copy link
Member

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).

@axkibe
Copy link

axkibe commented Nov 24, 2023

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.

@craigify
Copy link

craigify commented Dec 3, 2023

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants