Showing posts with label calls. Show all posts
Showing posts with label calls. Show all posts

Friday, March 30, 2012

Internal Activation - calls stored procs in other DBs

Hi all

I am using internal activation on a queue to process the messages, should an error be encountered I call stored procedure A in the same database to log the error. Part of the processing in stored procedure A is a call to stored procedure B in another database (on the same server), however I have not been able to get this call to B to work. Currently I get the error "The server principal XXXXXX is not able to access the database YYYYYYY under the current security context".

I have tried various combinations (too many to remember) of database owners, roles and permissions as well as EXECUTE AS on both A and B and the Queue but none seem to work. Can anyone give me simple example of a setup which would allow this cross database call to work?

Thanks

Ian

You are hitting the 'Extending database impersonation under EXECUTE AS context' issue. I have a series of posts in my blog tackling this problem:

http://blogs.msdn.com/remusrusanu/archive/2006/03/07/545508.aspx
http://blogs.msdn.com/remusrusanu/archive/2006/03/01/541882.aspx
http://blogs.msdn.com/remusrusanu/archive/2006/01/12/512085.aspx

The first link is posted today and is an actual example on how to call a procedure in another database under activation.

|||

Thanks for the information - it's just what I was looking for.

Ian

|||

One more question....

Is it essential that the owner of the other DB is the same as the owner of the activated stored proc?

I don't seem to be able to get this to work if they are different.

Thanks

Ian

|||You can use any user with receive permission on the queue.|||I think you must grant AUTHENTICATE permission on the 'other' DB to the user from the EXECUTE AS clause of the CREATE/ALTER procedure. If the EXECUTE AS is OWNER, then to the owner of the activated procedure)

Monday, March 26, 2012

Intermittent connection loss?

Hi all,
I have a .Net windows application that uses the micrsoft application block
to make calls to the database. I am doing a few thousand records that must
be inserted. I have a problem where on occasion I get an exception that
says "SQL Server does not exist or access denied." This seems to be an
intermittent problem, and profiler has not turned up any info. The server is
running locally, so I don't think it is a network issue.
Anybody have any ideas?
Thanks
J
Are you running the .NET application using TCP/IP or Shared Memory?
Check the sysprocesses table when your application is running & look at the
net_library column to confirm.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.
|||Kevin,
I get a timeout period elapsed error when trying to open a connection on a
machine where the server is local. It does not occur when running the same
app on another client on the network. It is a .net application using the
SQLClient. If I turn off shared memory protocol for clients on the server the
error does not occur. Is there an issue with shared memory access and .Net?
"Kevin McDonnell [MSFT]" wrote:

> Are you running the .NET application using TCP/IP or Shared Memory?
> Check the sysprocesses table when your application is running & look at the
> net_library column to confirm.
> Thanks,
> Kevin McDonnell
> Microsoft Corporation
> This posting is provided AS IS with no warranties, and confers no rights.
>
>
|||There may be an issue. I would open a case with a VC engineer in the
Webdata group to investigate.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.