Catch AD user Asp net mvc

Asked

Viewed 817 times

1

Guys I have a question: how do I get the user logged into windows on the client machine? It’s getting the server user and not the client machine. Could you help me?

1 answer

2


When creating the project, Visual Studio offers this option.

When creating a project, click Change Authentication as in the screen below:

Novo Projeto

On the next screen, click Windows Authentication:

Windows Authentication

If the project already exists, modify the following in your web.config:

<configuration>
  ...
<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Windows" />
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
  ...
</configuration>

The user name will be both in Controllers how much in Views, inside User.Identity.Name.

  • Is it not necessary to make any changes in iis? , the application being started returns me a 404 error, asking for a login.aspx pages I do not have this file in my project, where I could redirect to go straight where I wish?

  • @Jeffsilva Well, if you set up the project for Windows authentication, it doesn’t make sense to have login screen. Is there any internal permissions control within your system?

  • I already solved this problem, it was a redirect badly pasted, I put the correct redirect, but the following error arises: "Unauthorized: Logon failed due to server Configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the Authentication methods enabled on the Web server. Contact the Web server’s Administrator for Additional Assistance." I believe it is about the directory where the project is, but it is located locally on my machine and I am administrator, so what is the reason for this error?

  • 1

    It has already been solved, I needed to change windows authentication in iis to enable and give authorization to the group of users in directory, thanks gypsy!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.