views:

274

answers:

3

Hi

Is there a way to get windows account username of the client accessing the ssrs report. If user is accessing reports on server B from machine A how can we get the user's windows username in the SSRS report?

I used User!UserID and it worked fine since I was running it from my local machine. As soon as it was deployed to a different server it stopped working because valid User!UserID is not available.

Pls. suggest.


My bad. I am getting the username. But it seems that the "Code" i needed to execute on the server didnt work. I added a vb.net code under "Report properties -> Code" tab. It works fine on the local machine. I simply right clicked and deployed the report to the server. Is there any extra step that needs to be performed for the "Code" to be deployed to the server as well or to be executed. Its a very simple vb.net function as shown below

Public Shared Function GetUserName(ByVal input as String) As String
        Try
            input = input.Replace("<domain>\", "")
            Dim details(2) As String
            details = input.Split(".".ToCharArray())
            input = String.Concat(details(1), ", ", details(0))
        Catch ex As Exception
            Return ex.Message
        End Try
        Return input
End Function

Update:
It seems for some reason input=input.Replace("\","") is not working. Remaining part of the code seems to be working. So the code is definitely deployed along with the report. Confused as to why input.Replace() is working on local machine and not on the server.

Update: It seems the domain name i was getting on local machine was in lowercase while the one on the server was in uppercase hence the Replace was not functioning. Now i am applying ToLower() to the input before replace and it is working. My bad. I should have debugged it better.

I hope this question will be useful for someone who is looking to get windows username in the ssrs report.

Thanks

A: 

this blog entry may help you:
http://blogs.msdn.com/tudortr/archive/2004/07/20/189398.aspx

bugtussle
This article talks about how to pass the windows credentials. In my case I already have this working. Somehow my custom vb.net code does not seem to be working on the server.
stackoverflowuser
A: 

Use the built-in User!UserID

gbn
A: 

If you want to display the name on the report use [&UserID]

nojetlag