Re: Tracing user & permissions (triggers and stored p)



Please specify the version of SQL Server you are using. Assuming 2000,
there should be no difference in the Windows account used regardless of how
xp_cmdshell is run (proc vs. trigger executes proc). The process launched
from xp_cmdshell executes under the security context of the SQL Server
service account when run by a sysadmin role member. xp_cmdshell runs under
the configurable SQL Agent Proxy account for non-sysadmin users. The proxy
account can be configured from Enterprise Manager under Management-->SQL
Server Agent-->Properties-->Job System.

There are issues when running BCP from a trigger. A trigger always executes
in the context of a SQL Server transaction. Consequently, modified data
will be locked and cannot be accessed by the external BCP utility unless
NOLOCK is specified. Also, long-running transactions are bad for both
concurrency and performance.

I suggest you consider an alternative approach for your requirements. A
common practice is to insert the needed data into staging tables and
schedule a periodic SQL Agent job to generate the files.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Guillem Codina" <Guillem Codina@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9156ECAF-E52B-4044-859F-A693F08C6109@xxxxxxxxxxxxxxxx
> To whom might be able to help me:
>
> STORY:
> I work in a stevedor terminal in the Autonomous port of Barcelona.
> Every time operations on a vessel are closed (instruction from software)
> an
> sql Trigger executes a Stored Procedure passing it some variables.
> The Stored Procedure ends generating flat files which will then be
> captured
> by a Daemon who sends them by FTP to a client for later processing.
>
> The flat files are generated using the following command:
>
> Exec master.dbo.xp_cmdshell @cmd, no_output
>
> @cmd is a variable which will store a value like this:
>
> BCP "Select * From terminal.Temp_BCP" queryout
> "P:\\CONTXBUQ.A59562454.ESQ0817002I.20060120111821.X.EDIPLANO.N.msg.txt"-Sxxxxxxx
> -Usa -Pxxxxxxxxxx -c
>
> PROBLEM:
> The exec comand ends on error:
>
> SQLState = 08001, NativeError = 17
> Error = [Microsoft][ODBC SQL Server Driver][Shared Memory]No existe el
> servidor SQL Server o se ha denegado el acceso al mismo.
> SQLState = 01000, NativeError = 2
> Warning = [Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen
> (Connect()).
>
> I am certain that parameters -S -U and -P are correct as the whole exec
> command.
>
> I guess that the key to the problem is "permissions". When I execute
> from
> QueryAnalyzer the permissions are the ones from the user who has logged
> into
> SQL or WINDOWS (depending on the security system used).
> Stored Procedure' s permissions must work different, specially when its
> execution comes from a Trigger. I would like to know how to check for the
> chain of permissions to see what user is really executing the xp_cmdshell.
> SQL Server xp's must have very restrictive policies since many of them can
> access server resources. Do you believe that the user executing the
> cmdshell
> is by default LocalSystem? If so, how can I change this user? are there
> any
> parameters for this purpose? what user could perform with no problems
> this
> cmdshell?
>
>
> Thanks a lot in advance.
>


.



Relevant Pages

  • Re: call to xp_cmdshell from trigger problem
    ... The application user is a SQL Server account and not a Windows user account. ... try a test and see if the client gets the required info. ... >> database and causes a trigger to fire and starts a process to notify the ...
    (microsoft.public.sqlserver.server)
  • Re: errors calling linked oleDB server stored procedures
    ... within SQL server the same as we would elsewhere but i don't see anything. ... > workaround to cretae a dummy table in your database that executes the ... I think you could trigger your ... > procedures in your database. ...
    (microsoft.public.sqlserver.programming)
  • Re: When do selects execute for multiple resultsets
    ... SQL Server executes each query and stops when its ... When the first resultset is ... The CommandTimeout is measured from the time you execute the query until the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Tracing user & permissions (triggers and stored p)
    ... staging tables + sql agent job ... >> Please specify the version of SQL Server you are using. ... >> xp_cmdshell is run (proc vs. trigger executes proc). ... >> from xp_cmdshell executes under the security context of the SQL Server ...
    (microsoft.public.sqlserver.security)
  • Re: Execute SSIS Pkg From MSMQ Trigger??
    ... The account will need to have permissions to retrieve the package from its store wherever that may be and if using Windows Authentication in the package connection manager will need to be able to satisy those needs as well. ... Has anyone successfully executed an SSIS package from within an MSMQ ... Our trigger is written in C#. ... Our SSIS package is in Sql Server. ...
    (microsoft.public.sqlserver.dts)