1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Getting DisplayName out of Active Directory using JScript

Discussion in 'Programming & Webmastering' started by cjoyce1980, Nov 30, 2007.

  1. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    Does anyone know how to get DisplayName out of Active Directory using JScript

    Would like to intergrate this is into a html page, so the user currently in session would have there DisplayName on show.
     
  2. Solaris17

    Solaris17 Creator Solaris Utility DVD

    Joined:
    Aug 16, 2005
    Messages:
    17,263 (5.14/day)
    Thanks Received:
    3,600
    Location:
    Florida
  3. Namslas90 New Member

    Joined:
    Aug 27, 2006
    Messages:
    4,851 (1.63/day)
    Thanks Received:
    555
    Location:
    Earth
  4. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    thanks guys but i hit both of those sources early and i'm still having no luck, i guess i'll still have to keep googling!
     
  5. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.92/day)
    Thanks Received:
    5,616
    Location:
    Cheeseland (Wisconsin, USA)
    This Link seems to be more complete than the others.

    It is in VBS, but the port to JScript should not be to hard.

    Hope it helps :)
     
  6. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    its a little above and beyond what i need to do, but it's still not returning me the display. I'm getting the FQ user name (i.e. cn=user, ou=users, dn=domain, dn=com)
     
  7. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.92/day)
    Thanks Received:
    5,616
    Location:
    Cheeseland (Wisconsin, USA)
    Why don't you paste your code here so we can take a look at it.
    We love to help people with code problems (or at least I do).
     
  8. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    i wish i could give you my code, but i left work about 2 hours ago and silly me the code is on my pc's HDD and i can't remote wake it up :cry:
     
  9. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.92/day)
    Thanks Received:
    5,616
    Location:
    Cheeseland (Wisconsin, USA)
    Lol ... I've been in that situation before.

    Oh well, it's the weekend and you should be planning on doing something entertaining, not worrying about code that will certainly wait until Monday. :toast:
     
  10. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    i know but i've not been able to switch off yet, never mind i'll annoy you guys on monday then
     
  11. cjoyce1980 New Member

    Joined:
    Apr 8, 2006
    Messages:
    715 (0.23/day)
    Thanks Received:
    11
    Right, here is my code currently.

    What i'm trying to do it is to make a small javascript within a html signature, so that my exhange email clients (outlook) all have the same disclaimer apart from there AD display name and email address.

    so the output should look something like this:

    Joe Brown
    joe@mydomain.com

    I can do the email address part (which is simply the users name and the domain name), but i'm not able to get the displayname out of AD.

    Code:
    <HTML>
    	<HEAD>
    		<script language=javascript>
    		<!--
    		var wshshell = new ActiveXObject("wscript.shell");
    		var username = wshshell.ExpandEnvironmentStrings("%username%");
    		var hostname = "domainame";
    		var linktext = username + "@" + hostname;
    		document.write(displayname + "<br>")
    		document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + ">" + linktext + "</a>") 
    		-->
    		</script>
    	</HEAD>
    </HTML>
    
     
    Last edited: Dec 3, 2007

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page