1

So I've been working on an MVC app that pulls data from an existing database. I designed this as an 'Intranet Application' so that users would automatically be logged on to the app using their Windows credentials. This works, since the property @User.Identity.Name returns my Windows login name. (as well as other users), and they have access to the application itself. HOWEVER, when trying to access the database the information is on, I get the following error:

[SqlException (0x80131904): Login failed for user '**My computer name**'.]

It would appear that it's recognizing my windows login, but for some reason trying to use my machine name to access the database instead. At the company, this particular database is also accessed using employees' windows usernames, so I'd rather people be able to automatically access it using the built-in windows authentication in the MVC app.

In my web.config, I have identity impersonate set to false, authentication mode equal to Windows and the following keys in appSettings:

<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false" />

The connection strings were auto-generated for me, and the information IS retrievable when running the app from Visual Studio, so I can only assume it's an issue with IIS settings. (I've never deployed an MVC app before)

On the application's IIS settings I have every authentication disabled except for Windows Authentication. Any ideas what I'm doing wrong? Let me know if there's any additional information you need as well.

1
  • What does your sql connection string look like? Commented Aug 7, 2012 at 20:32

1 Answer 1

2

Turn on the impersonation in your authentication configuration. Otherwise, the application pool's identity is used to connect to your Sql Server.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, I swear I tried that, but that indeed does the trick. Thank you sir!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.