Re: Problem with bulk load security.



On Jan 28, 12:48 pm, RickB <rbiel...@xxxxxx> wrote:
I get a dozen or more files a day that must be loaded into our SQL
Server 2005 db.

A generic SP loads the data like this:

set @cmd = "insert ...
    From Openrowset (Bulk ''' + @fname + ''',
         FORMATFILE =''' + @ffile + ''') as raw;"
exec (@cmd)

The file being imported is specified as '\\server\dir\src\file.txt'

The files physically reside on another server in the same domain.

SQL Server runs under a service ID that has access to the other
server.

The command to import the data comes from an script on the server
where the data resides.  The ID that the script runs under has access
to the SQL Server and has bulk load rights.

I tried 3 scenerios.  One works but I don't like it.  Nothing else
does and I don't know why, or more importantly, what to do about it.

1) SQL Server authentication: Specifying an explicit SQL Server ID and
Password *WORKS*.
    On the app server the security log shows SQL Server using it's
service ID to get in and read the data.
    Obviously what I don't like about this is I must store a password
on the app server that has write access to the DB.

2)  Windows authentication:
    Cannot bulk load because the file "\\server\dir\src\file.txt"
could not be opened. Operating system error code 5(Access is denied.).
    On the app server the security log shows SQL Server trying to get
in as 'Anonomous'
     The question is, how do I get it to either use its service ID
like it does above or the ID I'm using to authenticate into SQL Server
(which also would work).

This sounds a little like the classic "double hop" issue.

Let's give the two servers names.
ServerA is the server with the file, and is originating the command.
ServerB is the SQL Server with the stored proc.

ServerA is passing a set of credentials to ServerB when it's
connecting. An important fact about those credentials is that
(normally), ServerB can't then use those credentials to authenticate
itself with other servers (including ServerA).

What you need to do is set up trusted delegation. This would typically
be a domain administration task. If there are dedicated separate
admins at your place, you'll need to talk to them. If you're a sole
admin, a google search for "trusted for delegation" should start
finding the right articles.

3) I also tried setting the SP to 'execute as' the SQL Server ID used
in scenerio 1 above.
    I get "You do not have permission to use the bulk load statement."
    I get that error whether I use Windows authentication or the ID
that the SP should execute as.

I'm guessing in this case that SQL Server is bypassing some checks.
What almost certainly isn't happening is that the associated windows
user account credentials are being generated, and those are what would
be required to make the hop back to ServerA

Damien
.



Relevant Pages

  • Re: Login failed for user (null).
    ... authenticated connection with SQL server. ... Whether or not the remote service accepts the authentication from client ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: server authentication & ASP authentication
    ... on to the client workstation with an authorized Windows account. ... SQL Server with Windows authentication. ...
    (microsoft.public.sqlserver.security)
  • Re: Enterprise Manager Server Registration General Network Error
    ... I can ping the server by name from the affected client. ... I can register the server by name using SQL Authentication (rules out name ... Verify that the instance of SQL Server is listening Correctly ... I use Active Directory Account on Windows 2000 machine. ...
    (microsoft.public.sqlserver.connect)
  • Re: Cannot open remote connection to Dql Server
    ... be guest logging in under windows authentication. ... The user is not associated with a trusted SQL Server ... Services And Connections. ...
    (microsoft.public.sqlserver.setup)
  • Re: SBS 2003 as web server
    ... Can I use the SQL Server component for Web-based business applications? ... AD required CALs. ... I was told many times that only Windows NT authentication requires CAL's ...
    (microsoft.public.windows.server.sbs)

Quantcast