Accessing user information from client  
Author Message
Josep Oncins





PostPosted: JScript for the .NET Framework, Accessing user information from client Top

Hi,

I want to acces to user information from my client code, in concret I want to acces to the USER_LOGON value.

Supose I have the WhoAmI.aspx page:

<%Response.Write(Request.ServerVariables["LOGON_USER"]);%>

It will return my domain and user name, for instance:

AD/JONCINS

The question is:

How could I do that using only Javascript and doing nothing with c# and ServerVariables

Is there a way to obtain the "LOGON_USER" only from client side

Thanks in advance




.NET Development20  
 
 
Dennis Stone - MSFT





PostPosted: JScript for the .NET Framework, Accessing user information from client Top

This will work with the drawback that the user has to have security settings set to either enable or prompt for ActiveX controls and that they allow it to run but it is probably the best you can do with only client side script.

<html>
<body>

<script type="text/javascript">
var WshNetwork = new ActiveXObject("WScript.Network");

var u = WshNetwork.UserName;
var d = WshNetwork.UserDomain;
alert(d.toString() + "\\" + u.toString());

</script>

</body>
</html>



 
 
Josep Oncins





PostPosted: JScript for the .NET Framework, Accessing user information from client Top

That works fine.

Thank you very much