You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 14, 2024. It is now read-only.
While implementing ldap authentication against AD with ldapjs, I have noticed the following :
When searching for a user with non-ascii characters, I noticed AD returns the DN encoded.
example :
Search for user "kürt"
returned :
CN=K\c3\bcrt, ... (\c3\bc => hex for ü)
I then need to send the DN again to ldap to authenticate with it. However AD required the non-decoded DN.
CN=Kürt ...
function unescapeLdapResult(ldapResult) {
// Regular expression to match the escaped sequences
const regex = /\\([0-9a-fA-F]{2})\\([0-9a-fA-F]{2})/g;
// Replace each escaped sequence with its Unicode character
return ldapResult.replace(regex, (match, p1, p2) => {
// Convert the hex codes to a Buffer
const bytes = Buffer.from([parseInt(p1, 16), parseInt(p2, 16)]);
// Convert the Buffer to a UTF-8 String
return bytes.toString('utf8');
});
}
I have created this function to acquire this, it would nice to have it as a helper method
The text was updated successfully, but these errors were encountered:
While implementing ldap authentication against AD with ldapjs, I have noticed the following :
When searching for a user with non-ascii characters, I noticed AD returns the DN encoded.
example :
Search for user "kürt"
returned :
CN=K\c3\bcrt, ... (\c3\bc => hex for ü)
I then need to send the DN again to ldap to authenticate with it. However AD required the non-decoded DN.
CN=Kürt ...
I have created this function to acquire this, it would nice to have it as a helper method
The text was updated successfully, but these errors were encountered: