How do I pass Trusted credentials from MVC to a class library for connecting to SQL?

I have an MVC projects that references multiple sub projects (class libraries). The MVC project uses Trusted Authentication via Entity Framework to access a SQL Server on another server without a problem.

One of the referenced sub projects also connect to the SQL Server using LINQ. The authentication isn't being passed to the sub project and the server reports that the servername$ doesn't have permission.

How can I get the class library to use the trusted authentication obtained by the parent MVC project? I might be missing something glaringly obvious here. My research revealed possibly using impersonation or passing a cookie. The later is for two ASP.NET Projects, when only one project is ASP.NET.

This project works fine from my own computer, but once it is up on an intranet, things start breaking. I don't want to give permissions to the intranet login, directly if I can avoid it.

Can someone point me in a direction, hopefully the right one?

My web config file has:

<system.web> <authentication mode="Windows" /> <identity impersonate="true" /> 

Also, this is the first time looking at this project in a couple years, so, I only partially remember what's doing what where.

by woo545 via /r/csharp

Leave a Reply