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
Solved

SSRS - Windows username

Posted on 2014-04-28
9
1,278 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
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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
query question 12 31
SQL Script to Remove Data from Two Joined Tables 1 19
SQL Query 2 31
MSSQL - Lock Row from reading by other programs 9 32
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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…

792 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