We have a web application that uses forms authentication to authenticate a user based on a user table in a database. (For example, there are no active directory accounts or SQL servers). The web application accesses the SQL server using the service account. However, for audit, authorization, and other purposes, our stored procedures must know for which user any given operation is performed.
In a previous life, I worked with a similar situation using an Oracle database. In this case, every time we opened the connection, we first called the Oracle build procedure to set the connection context context variable. This variable contains the user ID for the user who will use the connection. Then, all stored procedures that the current user should know will check the context variable.
Conceptually, this worked the same way as dragging user information into a CallContext before a remote call.
My question is, is there a similar mechanism on a Microsoft SQL server?
Obvioulsy, if I should, I can pass UserId as an argument for each stored procedure, but this is exactly what I'm trying to avoid.
source
share