Operating system error code 5(Access is denied.) when bulk insert

I have an ASP.NET application on Server A and a SQL Server on Server B.
When running the appliction it calls a stored procedure. This procedure try to bulk insert from a file from a shared folder on Server A, but the following error occured:

Cannot bulk load because the file “\serverA_address\sharedFolder\test.txt” could not be opened. Operating system error code 5(Access is denied.).

  • Prevent Caching in SQL Server
  • Division by zero error when trying to divide data
  • To Multi-Tenant, or Not To Multi-tenant
  • Simplest solution for high availability of SQL server 2008?
  • Database does not exist error
  • How do I select top 10 rows in a table without sorting?
  • The strange is that when I execute the bulk insert from the sql management studio directly, it runs without any exeptions.

    Another observation: if I change the shared folder address to a local folder where the sql server runs (Server B) without shareing, no access denied error…

    I tried to set bulkadmin permission to all the users, including the technical users: sql_serviceusr who runs the sql service, another technical user who runs the application and make the call to sql server and to the user who logged in to the application. All users are domain accounts and all servers using Kerberos authentication.

    Server A: Windows Server 2008R2

    Server B: Windows Server 2008R2, SQL Server 2008R2

    Appreciate any help or guidance.

  • Warning: An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll.
  • LINQ query slow, creates Timeout; generated SQL is fine?
  • Does 'Model' reads all the rows from the table when initialized? (performance)
  • Convert TextBox value to DateTime SQL Server
  • Column does not allow nulls
  • How to change the table name in visual studio 2013 in design mode?
  • 3 Solutions collect form web for “Operating system error code 5(Access is denied.) when bulk insert”

    You are doing a double hop, so you need to enable Kerberos delegation.

    You could create a connect account and use SQL authentication.

    In my experience, getting our network folks to properly set up Kerberos is like pulling teeth. We had it working for one glorious week once and then it suddenly stopped working. It just wasn’t worth the hassle after that.

    This might not be the exact answer you’re looking for, but could be an interim solution for you.

    By your description of the error, I assume the problem is in sharing the folder.
    When sharing a folder, you should give access to the user who will be accessing the folder from remote computer in two places in folder’s properties: under the Share tab and under Security tab.
    Did you give access in both of them?

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.