So here’s an example string:
CN=John Doe,OU=IT,OU=Management Support Services,OU=Divisions,OU=Accounts,DC=company,DC=com
I only need to get the first name out of this string. In this case the name being John Doe. I can’t hard code a number of characters in as the names there can vary in length.
Basically I need to select the string after CN= and then end it at the first comma.
The first number can always be 3 characters since the CN= is always there. Is there anyway for me to use the first comma as the end point?
I’m trying to do something like this.
let name = reports[i].mgrdn;
let result = name.split(3, ",")
Any help would be appreciated. Even just a suggestion about what method to use.
This will give you what you need.
result = name.split(',').split('=');
Of course you should probably validate the format is what is expected too.