I use ths script in Default.aspx page.
<script id="clientEventHandlersJS" type="text/javascript">
function Button1_onclick() {
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
document.write("<table border=1>");
dispHeading();
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
document.write("<td>" + p.IPXAddress + "</td>");
document.write("<td>" + p.IPXEnabled + "</td>");
document.write("<td>" + p.IPXNetworkNumber + "</td>");
document.write("<td>" + p.MACAddress + "</td>");
document.write("<td>" + p.WINSPrimaryServer + "</td>");
document.write("<td>" + p.WINSSecondaryServer + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function dispHeading()
{
document.write("<thead>");
document.write("<td>Caption</td>");
document.write("<td>IPFilterSecurityEnabled</td>");
document.write("<td>IPPortSecurityEnabled</td>");
document.write("<td>IPXAddress</td>");
document.write("<td>IPXEnabled</td>");
document.write("<td>IPXNetworkNumber</td>");
document.write("<td>MACAddress</td>");
document.write("<td>WINSPrimaryServer</td>");
document.write("<td>WINSSecondaryServer</td>");
document.write("</thead>");
}
</script>
in above code I am trying to fetch MAC address of client. But i am getting error at first line `var locator = new ActiveXObject ("WbemScripting.SWbemLocator");'
that activeX object cant be created, please help me.
I use ths script in Default.aspx page.
<script id="clientEventHandlersJS" type="text/javascript">
function Button1_onclick() {
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
document.write("<table border=1>");
dispHeading();
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
document.write("<td>" + p.IPXAddress + "</td>");
document.write("<td>" + p.IPXEnabled + "</td>");
document.write("<td>" + p.IPXNetworkNumber + "</td>");
document.write("<td>" + p.MACAddress + "</td>");
document.write("<td>" + p.WINSPrimaryServer + "</td>");
document.write("<td>" + p.WINSSecondaryServer + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function dispHeading()
{
document.write("<thead>");
document.write("<td>Caption</td>");
document.write("<td>IPFilterSecurityEnabled</td>");
document.write("<td>IPPortSecurityEnabled</td>");
document.write("<td>IPXAddress</td>");
document.write("<td>IPXEnabled</td>");
document.write("<td>IPXNetworkNumber</td>");
document.write("<td>MACAddress</td>");
document.write("<td>WINSPrimaryServer</td>");
document.write("<td>WINSSecondaryServer</td>");
document.write("</thead>");
}
</script>
in above code I am trying to fetch MAC address of client. But i am getting error at first line `var locator = new ActiveXObject ("WbemScripting.SWbemLocator");'
that activeX object cant be created, please help me.
Share Improve this question asked Mar 27, 2009 at 5:49 VikasVikas 24.4k37 gold badges119 silver badges159 bronze badges2 Answers
Reset to default 4The WbemScripting objects are not marked as "Safe for scripting", and rightly so! If they were, any web page could figure out what processes you are running, terminate them, and even launch new applications! Talk about a security breach...
The WbemScripting objects are made for use in Windows Scripting, not for use in a web page.
If you have access to the client machine, try running your code from a .js file using WScript.exe or CScript.exe. If the client machine is within your network and you know its name, you could also try running the script remotely; just replace the "." period in the line
locator.ConnectServer(".");
by the machine's name. So if the remote machine's name is MACHINE, you should change the line to
locator.ConnectServer("MACHINE");
Again, this would require you to run the script from a .js file using WScript or CScript.
Lastly, you could try to lower Internet Explorer's security settings on the client machine. But only do this if you never surf the big bad internet with that machine, since it'll open up your browser, your entire PC and all of the network connected to it to all kinds of unsavoury stuff...
Check to make certain that the COM object you are trying to create is installed, and marked as safe for scripting. Confirm your security settings in IE. Beyond this, ActiveXObject is only available via IE, not other browsers. Most likely is it either isn't "safe for scripting", or your security settings for the security domain forbid it.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745665107a4639073.html
评论列表(0条)