Link to home
Start Free TrialLog in
Avatar of Manju
ManjuFlag for India

asked on

SSRS - Windows username

Team - I have a SSRS report which is based on nt login. Ex: I have a table called userlist where i have ntlogin and Name as columns. in SSRS, i have a query which will fetch data from projects table using ntlogin..

The challenge is i connect the SSRS using SQL Authentication. So whenever i try
select stuff(SYSTEM_USER, 1, charindex('\', SYSTEM_USER), '') or
select stuff(suser_sname(), 1, charindex('\', suser_sname()), '')

it populates only the SQL Authentication username. Is there a way, i can get the actual user's id?
Avatar of Manju
Manju
Flag of India image

ASKER

i mean, i need windows user name instead of SQL Authentication name
Why get rid of the domain part? Just use this
select suser_sname()

Open in new window

and you'll get
domain\username
.

OTOH, if you want the user that you're logged in to the database as (not into the server), use
select user_name()

Open in new window


hth

Mike
who is the report data source configured?
Avatar of Manju

ASKER

Hi All -

Both select user_name() & select suser_sname() is populating the user logged into the database.

My issue is, I use SQL Authentication to connect to the database. So both the above queries are pulling only the SQL Authentication username, however I'd like to know the actual windows user who is trying to query the db.
to catch the user on the SQL Server side,you'll have to change the data source to integrated authentication.
Avatar of Manju

ASKER

x-men -

I have a SSRS report which is connected to SQL via SQL Authentication. Hence i cannot change it to Integrated authentication. Is there anyways we can get windows username despite connecting via SA?
I'm not sure if I fully understood what you need to achieve but are you already aware of the User!UserID built-in field in the SSRS reports?  Perhaps that can help you out?  It can be used to filter data based on the user that's requesting the report.

More info: Using Built-in Field References in Expressions (Reporting Services)
Avatar of Manju

ASKER

All -

I have an SSRS report with SQL Authentication.

For ex: I use, "reportuser" as SQL Authentication for all the users to connect to the sql query.

What i need is,

i need to display the user who is accessing the report.

For ex: manjunathsw is the windows username, i need to display this in the report. Currently it shows only as "reportuser"

how can i achieve this?
ASKER CERTIFIED SOLUTION
Avatar of ValentinoV
ValentinoV
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial