Questions tagged [execute-as]

15 questions
8
votes
2 answers

The server principal "sa" is not able to access the database "model" under the current security context

I created a stored procedure which performs a series of operations that require special permissions, e.g. create database, restore database, etc. I create this stored procedure with execute as self ...so that it runs as SA. This is because I want…
user884248
  • 2,134
  • 3
  • 32
  • 57
3
votes
1 answer

SQL Server Execute As Requires Individual Logins

Evening, I would like some practical confirmation in relation to an issue we are having. We have a K2/SourceCode solution that turns upon the successful use of EXECUTE AS with Sql Server 2008 R2. We have no direct control over how this solution is…
2
votes
4 answers

Switching execution context inside logon trigger

I have a database called MyDB in a Microsoft SQL Server 2008 Express instance using mixed mode authentication. The application using the database MyDB currently connects using Windows Authentication, using the current user's Windows credentials.…
René
  • 9,880
  • 4
  • 43
  • 49
2
votes
3 answers

SQL 'Execute As' Login Command and Linq to SQL

I am trying to execute a sql query as another login using the 'Execute As' command. I am using Linq to SQL, so I've generated a Data Context class and I am using the ExecuteQuery method to run the 'Execute As' SQL command. I then call a Linq to SQL…
SaaS Developer
  • 9,835
  • 7
  • 34
  • 45
1
vote
2 answers

SQL Server EXECUTE AS misbehavior

I have a user which I gave grant access to credential using: GRANT ALTER ANY CREDENTIAL TO userA When I log in with that user, the following returns me data SELECT * FROM sys.credentials I can see that I have the permission on the SERVER level.…
DOMZE
  • 1,369
  • 10
  • 27
1
vote
0 answers

Execute as in SQL Server stored proc

I have some problem with using Execute as user in a SQL Stored proc. I've two users called user1 and user2. User1 has just public access in TestDB User2 has execute permissions in TestDB I've created a stored procedure as below: USE…
1
vote
1 answer

How to execute oracle DMBS_AQ.REGISTER behalf of different user?

One privileged scheduler user - user1 receive email notifications while two another (user2, user3) no. I want to execute code below on user3 schema, we tried this successfully on user2 (code executed directly on schema with temporary sys.dbms_aq…
jareeq
  • 311
  • 2
  • 9
1
vote
0 answers

SQL Server 'Execute As'/Revert pattern in a 'Try/Catch' Block

I wish to ensure I am using the "best" pattern when using an Execute As/Revert from within a Try/Catch block on SQL Server 2012. The below code "seems" to behave correctly... Am I missing anything or are there any security concerns, "better"…
RAA
  • 31
  • 5
0
votes
1 answer

How to write Execute AS Script in Stored Procedure in Azure Synapse Dedicated Pool?

I am trying to create a Stored Procedure in Azure Synapse Dedicated Pool, but I am facing an error. I don't know much about Transact-SQL and Synapse limitations, so I am unable to debug the real issue here. This Stored Procedure is part of…
0
votes
1 answer

Speed up strategy for SQL Server when EXECUTE AS is used for security

I've just started looking at a system that implements security a little differently to the norm. They create a new SQL user for each user of the system (of which there are about 32K now). Each query is sent via a connection that is initially using…
0
votes
1 answer

Execute As not impersonating permissions when trying to create sql server agent jobs programmatically

I am trying to create a stored procedure that creates a job and step programmatically and runs it. This works, but I also need to impersonate a user as the end-user will not have permission to do this. I have created a test user (sa2) and given it…
Paul
  • 693
  • 1
  • 10
  • 25
0
votes
1 answer

Is it possible to call EXECUTE AS OWNER later in object?

Consider this code: ALTER TRIGGER [dbo].[AfterInsertUpdateTenant_Korisnici] ON [dbo].[Korisnici] WITH EXECUTE AS OWNER FOR INSERT AS DECLARE @TenantId INT = dbo.GetCurrentTenantId(); EXECUTE AS LOGIN = 'sa'; UPDATE Korisnici SET…
Hrvoje Batrnek
  • 535
  • 1
  • 5
  • 15
0
votes
1 answer

DM_EXEC_SESSIONS not returning active connections

I am using SYS.DM_EXEC_SESSIONS to get all active SQL Server connections from my system. I know that if the logged user has no VIEW SERVER STATE permission, only the logged user is shown, otherwise all users. But I do not want to give all basic…
Heikki
  • 21
  • 3
0
votes
1 answer

Where is result of OBJECT_NAME(@@PROCID) obtained from? (typo corrected)

I have a stored procedure that has EXECUTE AS another user that has very restricted access. I cannot get the results from OBJECT_NAME(@@PROCID) when I run that stored procedure. @@PROCID does have a value, so it's the lookup that is failing. I…
Maa421s
  • 159
  • 1
  • 12
0
votes
2 answers

Execute stored procedure as another login

We have some SQL Agent jobs running in our product. But we want to do away with SQL server agent so that we can use Sql server express. So I am writing our own service to execute stored procedures that currently run as jobs. Everything else except…
neel roy
  • 147
  • 1
  • 13