question

EricaVismer avatar image
EricaVismer asked

Auditing Security when using execute as

If you create a stored procedure with the execute as clause - can you somehow still record the username of actual user running the stored procedure?
execute
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kevin Feasel avatar image
Kevin Feasel answered
Yes. SYSTEM_USER will tell you the current context, but ORIGINAL_LOGIN() should be able to tell you the base user account. ![ORIGINAL_LOGIN() shows that I'm still the one running this query, even though SYSTEM_USER tells me that I am executing as Reader.][1] [1]: /upfiles/OriginalLogin.png
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you so much
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.