Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

View Records That Are Associated With a User Table Expand / Collapse
Author
Message
Posted Saturday, September 29, 2012 5:44 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 31, 2013 3:09 PM
Points: 18, Visits: 60
I would like to find a way to setup a user table with logins (UserID) in one column and a department number in another column. A single user might be associated with multiple department numbers. When a report is run I would like the user to only see department data for the departments they are associated with in the table.

The article below is close to what I need except that a user is only associated with ONE department. I will have some people that are over multiple departments and will need access to all of those.

[url=http://www.mssqltips.com/sqlservertip/1743/dynamically-control-data-filtering-in-sql-server-reporting-services-reports][/url]


Post #1366222
Posted Sunday, September 30, 2012 4:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:35 AM
Points: 7,874, Visits: 9,613
I don't understand why you think the article you reference doesn't solve the problem. It certainly allows each user to be associated with (and therefor see data concerning) one or multiple offices, so the only change you appear to need is to change the word "office" to "department", ie it is purely a terminology difference.

Tom
Post #1366249
Posted Monday, October 1, 2012 1:34 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 31, 2013 3:09 PM
Points: 18, Visits: 60
Thanks for the response! The example looks like it works for employees that would be associated with only one office. Mine will have multiple offices (departments). Am I missing something in the example?
Post #1366741
Posted Tuesday, October 2, 2012 3:00 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:35 AM
Points: 7,874, Visits: 9,613
Look at the example beginning with this text:

the Report

In order to test the report, login as a particular user or launch Internet Explorer by right clicking on it, selecting Run As, and entering the credentials to use. I have setup two accounts for my test: Tom has access to all offices and Joe is restricted to just seeing two offices.


You'll see that when run by joe the report produces information for two offices, when run by tom it produces information for 6 offices.
According to the article, the user-office association is defined in the table declared like this:
CREATE TABLE [dbo].[UserOffice](
[UserOfficeKey] [smallint] IDENTITY(1,1) NOT NULL,
[UserAccount] [nvarchar](50) NOT NULL,
[OfficeKey] [smallint] NOT NULL
)
ALTER TABLE dbo.UserOffice
ADD CONSTRAINT pk_UserOffice
PRIMARY KEY CLUSTERED (UserAccount, OfficeKey)

This table allows multiple rows for each user since there's no unique constraint on the UserAccount column, so each user can be associated with multiple offices.


Tom
Post #1366911
Posted Tuesday, October 2, 2012 7:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 31, 2013 3:09 PM
Points: 18, Visits: 60
Thank you for the clarification. I appreciate your help!
Post #1367038
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse