User''s NT Login as a Parameter in a SRS Report

  • Does anyone know of a way to use the user's NT login that authenticates with SRS as a parameter in a SRS report.  I need to pass the user's login (domain\jdoe) to the report to cross reference that with a table that will provide a parameter for the department value in a report.

  • Believe it or not it's easy as can be. Just reference the value of User.USerID. That contains the NT login of the user running the report, simple and easy...for once!

  • Ben,

     

    I am not sure what you mean.  Can you elaborate?

     

    Thanks!

  • This may solve what you are trying to do.  Set up 2 datasets, one as you would normally for a report, and another that will get your department value (I use 'Dept' as the name throughout this explanation).

    In the department dataset (Dept), you will need to use the suser_sname() function in SQL (this returns domain\username).  Cross reference your user table with your department table and return the value for a specific user (based on suser_sname()).  Depending on your table designs, something like this will be needed.

    select department.name

    from users_table

         inner join department on users_table.departmentid = department.departmentid

    where users_table.username = suser_sname()

    Setup your other dataset as you normally would for your report.  Something like this:

    select ...

    from ...

    where department_name =  @dept_param

    Go to the Layout tab and finish setting up your report display.  Then, right click outside of the main report area to get to your report parameters.

    Create a department parameter (@dept_param), In the 'Default values:' section, select 'From query', select 'Dept' as your dataset, then 'name' from the value field.

    Go back to the data tab and edit your main dataset.  Click on the Parameters tab and make sure @dept_param is there.  If it isn't, you will need to add it.

    This will put the return value from your department dataset as the default value for the department parameter for a specific user when the report is opened.

    Hope this helps.

    Jarret

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply