Re: Problem with bulk load security.



On Feb 2, 4:57 pm, Erland Sommarskog <esq...@xxxxxxxxxxxxx> wrote:
 (rbiel...@xxxxxxxxx) writes:
Thanks for pointing me to that 'trustworthy' setting.

Unfortunately it only changed the error I'm getting.

It fixed the error saying I don't have bulk load access but didn't
provide access.  It just switched to the error saying the file can't
be opened.  On the app server I see the SQL Server trying to get in as
anonymous -- similar to when I use Windows authentication.

So it seems that setting a function to 'execute as' some other user
(even with the trustworthy option on) doesn't give that function
entirely the same abilities as executing the function while actually
logged on as that same user.

It seems our only choice is to hard-code passwords to an SQL Server
account.  Very dissappointing.

I think it's too early to give up. Try this:

   EXECUTE AS LOGIN = '<service account>'
   go
   BULK INSERT ....
   go
   REVERT

If this works, go back read my previous post about using EXECUTE AS
LOGIN as a statement in the stored procedure and signing it with a
procedure.

It is quite obvious why it did not help to set the database to TRUSTWORTHY:
you are only impersonating a *database user*. To be able to do this,
you need to impersonate a *server login*. I don't know for sure whether
that is a sufficient condition, but it's definitely required.

--
Erland Sommarskog, SQL Server MVP, esq...@xxxxxxxxxxxxx

Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx- Hide quoted text -

- Show quoted text -

I was trying to impersonate a user that worked.
But I tried what you suggested and as expected got a syntax error.

create PROCEDURE Import_File
( @param ...
) with execute as login = 'dom\svc_id'
as
begin ...
..Net SqlClient Data Provider: Msg 102, Level 15, State 1, Procedure
Import_File, Line 10
Incorrect syntax near 'login'.

So I tried this too.

create PROCEDURE Import_File
( @param ...
) with execute as 'dom\svc_id'
as
begin ...

The create worked but execution got the same error as all the others.

Cannot bulk load because the file "\\sys\dir\file.txt" could not be
opened. Operating system error code 5(Access is denied.).

Like other times, the app system showed an anonomous login being
attempted.

From all this testing I'm more and more surprised that it actually
works when I hard-code a password and I'm guessing that it must be a
legacy feature from before integrated security was supported. It
certainly seems that what I want is impossible without either hard-
coding a password or being trusted in the domain (which is not likely
to happen since Oracle is the standard here).
.



Relevant Pages

  • Re: Permission question - another one
    ... If I add an Sql Login it does add the TRAVAC\ in front of the names, ... seems to be users that were setup to use SQL Server Authentication. ... RAPTOR is the Server that has SQL Server running on it. ... > " I could think I am taking permissions away from someone, ...
    (microsoft.public.sqlserver.programming)
  • Re: Renamed Windows login not found in SQL Server 2000
    ... It's almost like SQL tuck some knowledge away in an area ... of memory that only gets released on Windows stop. ... > I am running SQL Server 2000 SP2 with Windows ... > login gets corrupted) I am unable to add the new login to ...
    (microsoft.public.sqlserver.security)
  • Re: dsn-less connection
    ... It worked pretty much as I was hoping in prompting the user for a SQL ... Server login and was able to remove the specific dsn that's in the odbc ... straight to the SQL Server login prompt? ... with the login prompt but the Use Trusted Connection is checked on. ...
    (microsoft.public.access.security)
  • Re: Logging in irrespective of database access
    ... My problem is that in the Login section of Enterprise Manger I have to ... like there used to be in SQL 6.5. ... What's the point in having the Database Access section if the System Admin ... SQL Server MVP ...
    (microsoft.public.sqlserver.server)
  • Logging in irrespective of the database access settings
    ... My problem is that in the Login section of Enterprise Manger I have to ... like there used to be in SQL 6.5. ... What's the point in having the Database Access section if the System Admin ... SQL Server MVP ...
    (microsoft.public.sqlserver.server)