javascript convert distinguished name into domain

Need to change distinguished names to a domain

distinguished names: CN=Dan Adam,OU=testUsers,DC=KALK,DC=DTC convert to KALK.DTC

So whatever comes in "DC" part is joined using "." i.e., "KALK.DTC"

Need to convert DN to a domain CN=Dan Adam,OU=testUsers,DC=KALK,DC=DTC

into "KALK.DTC"

const dn='CN=Dan Adam,OU=testUsers,DC=KALK,DC=DTC'
   let element=[];
        const parts = dn.split(',');
                    for (let i = 0; i < parts.length; i++) {
                        let p = parts[i]
                         element = p.split('=');
                    const dom= element.join('.')

Also what do I do if given an array of DNs and need to convert them to an array of domains?

Read more here:

Content Attribution

This content was originally published by ddark13 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: