Created a WCF service that is hosted in SharePoint and interacts with a SQL database. The site that I'm accessing the service from has kerberos enabled.

When I use the service, it is passing my credentials to SQL. How do I setup the web.config to pass the app pool account credentials to SQL?

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <binding name="customBasicHttpBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm"/>
    <behavior name="customBasicBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
  <service behaviorConfiguration="customBasicBehavior" name="blah.Services.s1">
    <endpoint address="" binding="basicHttpBinding"
        <dns value="localhost" />

1 Answer 1


You can try calling SQL using SPSecurity.RunWithElevatedPrivileges. It should execute as app pool account.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.