Getting displayName from AD with JScript

T

Tom G

I am trying to retrieve the user's Display Name from an Active Directory
using JScript. I've looked at the example in Lab15 referenced elsewhere in
this Discussion Group, but it doesn't contain a JScript example. I'm trying
to translate, but I can't figure out how to use DirectorySearcher In JScript,
(not even sure if I can). My code is below. I'd appreciate your help.
Thanks.

var projectManager =
XDocument.DOM.selectSingleNode("my:riskReport/my:projectManager");
if (projectManager.text == "") {
// get current user name
var WSHNetwork = new ActiveXObject('WScript.Network');
var strUserName = WSHNetwork.UserName;

// search for user whose mailNickname is the logon name
var ds = new DirectorySearcher("(mailNickname=" + strUserName + ")");
var result = ds.FindOne();

// get user's display name
if(result != null){
var employeeEntry = result.GetDirectoryEntry();
var strEmployeeName =
employeeEntry.Properties["displayName"].Value.ToString();
projectManager.text = strEmployeeName;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top