How To Get The User's Username In My Intranet Web Application In A Windows Network
I have a simple HTML page internally which just displays a form and asks the user to fill it out. I want to automatically capture the windows domain username and machine name to su
Solution 1:
Using only javascript on a none IIS server then it isn't possible.
However:
If you are using IIS then you can use the following JS:
<scriptlanguage="javascript">var username = '<%HttpContext.Current.User.Identity.Name %>';
</script>
Assuming you have turned Windows Authentication on in IIS for your site, then C# side:
C#
publicstring user_Name
{
get
{
string x = Page.User.Identity.Name;
x = x.Replace("YOURDOMAIN\\", "");
return x;
}
}
The x = x.Replace("DOMAIN\\", "");
strips out the DOMAIN sectionof the user acccount e.g NISSAN\rmcdonough
Solution 2:
capturing the windows domain username and machine name, I think we can't
Post a Comment for "How To Get The User's Username In My Intranet Web Application In A Windows Network"