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
549 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Know what services you can and cannot, should and should not combine on your server.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now