Solved

SSRS - Windows username

Posted on 2014-04-28
9
1,247 Views
Last Modified: 2014-05-02
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?
0
Comment
Question by:Manju
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 6

Author Comment

by:Manju
ID: 40026903
i mean, i need windows user name instead of SQL Authentication name
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 40028679
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
0
 
LVL 18

Expert Comment

by:x-men
ID: 40029024
who is the report data source configured?
0
 
LVL 6

Author Comment

by:Manju
ID: 40029209
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.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 18

Expert Comment

by:x-men
ID: 40029417
to catch the user on the SQL Server side,you'll have to change the data source to integrated authentication.
0
 
LVL 6

Author Comment

by:Manju
ID: 40029501
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?
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40031724
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)
0
 
LVL 6

Author Comment

by:Manju
ID: 40036547
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?
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 40036845
i need to display the user who is accessing the report.

Okay, try putting the following expression in a textbox on the report:

=User!UserID

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
syadmin MSSQL 2 57
T-SQL for SS2000 -- get position of char(13) in a long text field 11 28
Add '#' to end of file 2 29
SQL 2008 R2 calc date formula 3 23
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now