Solved

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

Posted on 2011-03-01
4
564 Views
Last Modified: 2013-11-21
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
Comment
Question by:TSG_Firstline
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
daveamour earned 250 total points
ID: 35008907
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
 

Author Comment

by:TSG_Firstline
ID: 35009043
Ahh nice thats pretty much it. Gives me "Mike Smith\" but removing the trailing "/" is no issue.

Many thanks.
0
 

Author Closing Comment

by:TSG_Firstline
ID: 35009053
Prompt response & spot on.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 35009731
Yes sorry about the \ - didn't show up in the alert!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question