Solved

SSRS - Windows username

Posted on 2014-04-28
9
1,307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

734 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