June 8, 2009 at 10:00 am
Ok, use Builtin Field "User ID" you would say. But that's to simple.
Let me explain why.
I use a dataset with the next in it:
declare @P_Gebruikervarchar(255)
set @P_Gebruiker= ''
set @P_Gebruiker= (select system_user)
When I run this in SQL Server Management Studio, I get the CORRECT result, example: "IT-DOMAIN\TILBXXXX"
When I run my report I get the name of the user defined in the DataSource Credentials.
We use a fixed username & password in the DataSource and not the current AD user, example "DatabaseReader"
Can someone help me to get the correct AD username of the current logged in who runs the report??
June 8, 2009 at 12:15 pm
June 9, 2009 at 12:46 am
Thanks for the reply, but as you could read in my first sentence is that not the solution.
Looking further for a solution, any help is welcome.....
June 9, 2009 at 6:06 am
ok, since you need to use it in a dataset (which I'm assuming because your sample code only seemed to get the userID for presentation or some such, which you can do with UserID...), create a hidden parameter default it to UserID and pass that parameter into your dataset as you would a parameter from any other parameter prompt. You can't get that info purely from SQL because the SQL Server doesn't know anything about your user, it only knows the credentials of the connection which you stated has been set to a static user.
-Luke.
June 9, 2009 at 6:09 am
(Luke, it seems that you where right afterall......)
Still looking and triggered why I couldn't get User!UserID to work for me, I searched and tryed on.
I've found the solution for my problem:
Define a Parameter (example @P_Username) and set de available value to NONE and default value to "=User!UserID".
When you are using more parameters, make sure this parameter is BEFORE the others.
Otherwise you get the error:
The report parameter ‘P_ParameterName’ has a DefaultValue or a ValidValue that depends on the report parameter “P_Username”. Forward dependencies are not valid.
Now you can use you're parameter @P_Username in a dataset/query.
June 9, 2009 at 6:13 am
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply