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