0

We want to host the application in IIS. Our application will be used by the Intranet users.

Our main requiremnet is that the windows prompt should not come for intranet users.So we have not used windows authentication. We have used forms authentication with active directory authorization. But then we are not getting logged in username.(Windows username who has logged in the machine)

First approach - Several codes like - "System.Security.Principal.WindowsIdentity.GetCurrent().Name" - does not give username when hosted in IIS.

Second approach - The below code is giving me username through Visual studio

 RegistryKey processor_key = Registry.CurrentUser.OpenSubKey(@"Volatile Environment"); if (processor_key != null) { if (processor_key.GetValue("USERNAME") != null) { Console.WriteLine("Language: {0}", processor_key.GetValue("USERNAME").ToString()); string username = processor_key.GetValue("USERNAME").ToString(); txtUsername.Text = username; } } 

But when I am hosting this site in IIS. I am not getting the user name.

With out using windows authentication is there any way to get machine username in IIS?

Please guide.

1 Answer 1

1

From within an MVC controller (that actually inherits from the System.Web.Mvc.Controller class), you can access the User object that is defined in the base Controller:

string username = this.User.Identity.Name; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.