DotNet Blogs

Articles of ASP.NET, C# & SQL Server

Finding Client Machine name, User name or Domain name in asp.net

Posted by Sujit Kumar on August 14, 2008

Find Client Machine Name, User Name or Domain Name in Asp.net using Java Script

function GetClientInfo()
{
var net = new ActiveXObject(“wscript.network”);

document.write(“Computer Name : “+net.ComputerName +”‘\n User Name : “+net.UserName+”\n Domain Name : ” +net.UserDomain);

}

4 Responses to “Finding Client Machine name, User name or Domain name in asp.net”

  1. Josh said

    When i use this I get a script error that the object could not be created. Any advice?

  2. Sujit Kumar said

    It is working fine with asp.net and html both , you have to allow activex control on your web browser.
    ex:

    function GetClientInfo()
    {
    var net = new ActiveXObject(“wscript.network”);

    alert(“Computer Name : “+net.ComputerName +”\n User Name : “+net.UserName+”\n Domain Name :”

    +net.UserDomain);

    }

  3. sekhar said

    function GetClientInfo() for getting clients machine domain name ,username,.. it is not working

  4. Sujit Kumar said

    could you please give me the error details so I can solve the issues. I have implented in asp.net 2.0 with IE-7 and it is working fine.
    code is below;

    Untitled Page

    function create()
    {
    var net = new ActiveXObject(“wscript.network”);
    //alert(net.UserDomain+’: ‘+net.ComputerName);
    document.write(“Computer Name : “+net.ComputerName +”‘\n User Name : “+net.UserName+”\n Domain Name : ” +net.UserDomain);

    }

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>