user872744
user872744

Reputation:

How to get the WINDOWS USER within "EXECUTE AS OWNER"

Is there a function which returns the WINDOWS USER (NOT the database user!) within a procedure which is "EXECUTE AS OWNER" ?

Will ORIGINAL_LOGIN() do this, or does that only return the database user ?

Consider the following situation:

Now, anne is logging into the SQL Database via Windows Authentification (so she is database user "PLANNERS"), and she calls the procedure. In this procedure, I want to retrieve the Windows User ("anne").

Upvotes: 2

Views: 1055

Answers (1)

user872744
user872744

Reputation:

ORIGINAL_LOGIN() is the correct answer.

Just needed it again ;) Thanks @deterministicfail

Upvotes: 1

Related Questions