Manju
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?
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?
Why get rid of the domain part? Just use this
OTOH, if you want the user that you're logged in to the database as (not into the server), use
hth
Mike
select suser_sname()
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()
hth
Mike
who is the report data source configured?
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.
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.
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 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)
More info: Using Built-in Field References in Expressions (Reporting Services)
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER