Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

When exporting data via ldap from AD, using javascript how do i extract just part of the string returned?

I am currently exporting data from Active Directory via ldap into another database.

I want to extract the user's ldap.manager. But i only want the name not the full OU path.

The value returned is something like:
CN=Smith\, Mike,OU=Development Control,OU=Public Protection.

Using javascript I want to just extract the manager as 'Mike Smith' from the above.

Can anyone help?
0
TSG_Firstline
Asked:
TSG_Firstline
  • 2
  • 2
1 Solution
 
daveamourCommented:
Try something liek this:

<script language="javascript" type="text/javascript">
            var test = "CN=Smith\, Mike,OU=Development Control,OU=Public Protection";
            
            alert(test.split(',')[1] + " " + test.split(',')[0].split('=')[1]);
        </script>

Open in new window

0
 
TSG_FirstlineAuthor Commented:
Ahh nice thats pretty much it. Gives me "Mike Smith\" but removing the trailing "/" is no issue.

Many thanks.
0
 
TSG_FirstlineAuthor Commented:
Prompt response & spot on.
0
 
daveamourCommented:
Yes sorry about the \ - didn't show up in the alert!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now