getting logged in user name to the pc that running the report

  • hi all,

    is there anyway in SQL to getting logged in user name to windows on the pc that running the power bi report connected to SQL  as i've tried some scripts but it retrieved the logged in user to the SQL server itself

    I did search on some and found that script but it giving below error, is there any mistake I did?

    DECLARE @CMD VARCHAR(500) = 
    (SELECT TOP 1 'tasklist /S ' + client_net_address +
    ' /FI "PID eq ' + CONVERT(VARCHAR(MAX),host_process_id) +
    '" /V /FO LIST /U DOMAIN\Admin /P password'
    FROM sys.dm_exec_connections C JOIN sys.dm_exec_sessions S
    ON C.session_id = S.session_id WHERE S.session_id = @@SPID)
    EXEC xp_cmdshell @CMD

    Error:

    output The system cannot find the file specified.

    NULL

  • sys.dm_exec_sessions has the login_name column and host_name column

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply