I need to track which user account on the same pc is using my software which is an web application. Is this possible? I can only get computer name but not user account name. I need to find out whether it is administrator or guest.
I think the only way to achieve this is by using Windows Authentication in you web application. Then you can check all claims available to this user.
Note : For this to work the server and the client must be on either the same domain, or domains with trust between them.
I tried this code and it worked perfectly.
public static string GetIP4Address()
{
string IP4Address = String.Empty;
foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
if (IP4Address != String.Empty)
{
return IP4Address;
}
foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
return IP4Address;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.