How do you get the username of the sql server of the current command in the CLR trigger?

I know that SqlContext.WindowsIdentity returns the current user executing the command (in the CLR trigger), however this only works for authenticated Windows users. How can I get the username if he is instead a user of the SQL server? Any help is appreciated.

+3
source share
3 answers

Try using the function SUSER_NAME()on the SQL server. This will return the current user.

+11
source

Try using SYSTEM_USER.

SELECT SYSTEM_USER
+5
source

, .

( #):

SqlConnection connection = new SqlConnection("context connection=true");
0

Source: https://habr.com/ru/post/1711506/


All Articles