Solved

SSRS - Windows username

Posted on 2014-04-28
9
1,262 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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
 
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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

813 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

10 Experts available now in Live!

Get 1:1 Help Now