How can I get the actual CURRENT_USER for dbo in SQL 2005?

I have a stored procedure that runs this to create a new ticket number:

 INSERT INTO [Test_DB42].[dbo].[TicketNumber]
  ([On], [By])

VALUES (CURRENT_TIMESTAMP, CURRENT_USER)

When I start with a user with db_datareader and execute permissions, I get the ActiveAlAccountName Active Directory value that I want - this user gets access through the AD group that has the login.

When I start the user with the sysadmin role, he simply says "dbo". This use has an explicit Login for your AD account.

Is there a way to change this or return the username samAccountName or the SQL name?

+3
source share
1

SUSER_SNAME() CURRENT_USER

+7

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


All Articles