Security – 403 FORBIDDEN Error in SharePoint with SQL Server datasource

iispermissionsSecuritysharepointsql server

I have created some custom WebParts on my SharePoint site through the use of SmartParts. My custom web parts look at 2 diff. SQL Server Datasources.

  • When i run my code from Visual Studio 2008 is works 100%
  • When i deploy my code on the SharePoint Page it works 100% when i run it from the server

But when i access the SharePoint site from my local PC and i hit that custom Webpart i get the error that say "403 FORBIDDEN". Now i know its a security problem but where and why? And why does it work on the SERVER and not from another PC??

Any help would be great!!

Edit:

MY ConnectionString in my Web.config

<add name="DSN" connectionString="Data Source=TCP:us-support.a1.mydomain.com;
   Initial Catalog=myDB;Integrated Security=false;User ID=myID;Password=myPassword"
   providerName="System.Data.SqlClient" />

Best Answer

There are two main reasons I can think of:

NTLM double-hop issue

This is probably the problem. Are you:

  • Using Windows authentication (NTLM) in your network and not Kerberos?
  • Using impersonation to connect to the databases? (True if your database connection string contains Integrated Security=SSPI or Trusted_Connection=True)

Then you are probably facing the double hop problem. This occurs because ASP.NET passes your Windows credentials to only one server, not two. So it will go from your local PC to the SharePoint server, but not be passed on to the database server.

The only way I know of to avoid this (unless you want to configure Kerberos) is set up a SQL account and use that in your connection string to the database.

Permissions to resources

The web part is accessing resources that your local PC account does not have permission to access.

Perform some sort of logging around the parts of your web part that you believe are causing the problem and narrow this down to a particular line of code. Note that while this may be a database authentication problem, it could also be that the web part is accessing some CSS file or other resource that your local account doesn't have permission to access.

Related Topic