I have a website that uses an app pool with a service ID to connect to a database. I want to be able to populate a textbox on the web page that shows their actual windows log in name and not the service ID that is associated with the app pool. I want this so I can use this information to do some filtering on a gridview that shows some data from the database based on their username. Currently I have tried a couple different ways.
Environment.UserName
This gets me the service ID that is being used to access the database.
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
This also gets me the service ID that is being used to access the database.
//Both of these return the same results described below.
HttpContext.Current.User.Identity.Name;
//and
System.Threading.Thread.CurrentPrincipal.Identity.Name;
These two are kind of weird. They get my username when I debug through vs2010 but when I copy the files to the server this will run on and have it using the app pool it gets me nothing. I have it set up to show in a textbox on the home.aspx page.
Any help on this would be greatly appreciated as I have looked everywhere and cant find any information that is specific to my situation.
Thanks in advance!!
Actual code currently being used: (returns nothing when run from server)
if (!IsPostBack)
{
string filterName = HttpContext.Current.User.Identity.Name;
IDFilterTextBox.Text = filterName;
}
Edited: to include a new method I tried.