SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an assembly with linq to sql mappings and I'd like to utilize it in my webpart. But when I try following:

DataList dataList = new DataList();
            dataList.DataSource = DB.Foo;

in CreateChildControls, I'm getting sql exception that user IUSR could not log into database. I wonder why it tries to connect with IUSR while I have set another identity for my application pool and that user has access to database. How can I make it connect to database with application pool identity?

share|improve this question
SPSecurity.RunWithElevatedPrivileges runs code under application pool account. – Alexander Jan 30 '12 at 14:54
@Alexander: I'd be happy to accept you comment as an answer to my question, so please post it as answer if don't mind. – jjczopek Jan 31 '12 at 18:09
it doesn't matter :) – Alexander Jan 31 '12 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.