我可以使用ExternalInterface调用来调用Javascript;但是,在JS实例化ActiveX对象时,代码中断并无法继续。据说,Flex正在使用我的浏览器(IE)ActiveX设置。当我在IE中测试代码时,代码可以工作,但不能通过Flex 4.6。代码一直工作到第5行,这是调用AcitveXObject函数的地方。有任何想法吗? JS代码如下。
function getAD(type) {
alert("blah");
var wshNetwork = new ActiveXObject("WScript.Network");
var uName= wshNetwork.UserName;
var userName = uName;
alert(userName);
objConnection = new ActiveXObject("ADODB.Connection");
objConnection.Provider="ADsDSOObject";
objConnection.Open("ADs Provider");
objCommand = new ActiveXObject("ADODB.Command");
objCommand.ActiveConnection = objConnection;
objCommand.CommandText = "SELECT sAMAccountName, givenName, SN, mail, displayName, title, department, department, telephoneNumber FROM 'LDAP://xxxx.net/OU=_Users,DC=xxxx,DC=net' WHERE sAMAccountName = '"+userName+"'";
var objRecordSet = objCommand.Execute();
var userMail,lastName,firstName;
if (objRecordSet.RecordCount == 1) {
objRecordSet.Movefirst;
userMail = objRecordSet.Fields("mail").value;
firstName = objRecordSet.Fields("givenName").value;
lastName = objRecordSet.Fields("SN").value;
displayName = objRecordSet.Fields("displayName").value;
title = objRecordSet.Fields("title").value;
dept = objRecordSet.Fields("department").value;
phone = objRecordSet.Fields("telephoneNumber").value;
test = objRecordSet.Fields("department").value;
}
else
{
userMail = "";
firstName = "";
lastName = "";
displayName = "";
title = "";
phone = "";
dept = "";
test = "";
}
objConnection.Close;
//return userMail+";"+firstName+";"+lastName+";"+displayName+";"+title+";"+dept+";"+phone+";"+test;
if(type=="email"){
return userMail;
}else if(type=="title"){
return document.write(" "+title); //return title;
}else if(type=="displayName"){
return document.write(" "+displayName); //return displayName;
}else if(type=="phone"){
return document.write(" "+phone); //return phone;
}else if(type=="dept"){
return document.write(" "+dept); //return dept;
}else{
return document.write("not found");
}
}