I am stuck with this problem for several days - any help is greatly appreciated.
I have a SQL trigger that calls a DLL written in C #. In this function, I need a login name for the person who initiated the SQL command that triggered the trigger. It doesn't matter if I get this information from C # or SQL.
Unfortunately, most of the usual routes I did not succeed.
The built-in SQL function NT_CLIENT () only works if Windows authentication is used to log in to SQL.
The DLL runs on the server, and therefore Environment.UserName does not matter and WindowsIdentity.GetCurrent (). The name returns an empty string if the database user (thread creator) did not use Windows authentication.
I know the domain name, IP address and workstation name. From this, I found out how to get the SID in C # - is there anyway I can get the Windows login from these bits of information using C # or is there a built-in SQL function that I missed?
EDIT: Thanks for letting me know that SQL is the problem for this problem. We have a client that registers everyone in the database as one user. What I had to do was make an unsafe build that calls the WMIC command line function. Yucky, but he did his job. Thanks again for the tip. :)
source
share