September 29, 2012 at 5:44 pm
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.
September 30, 2012 at 4:53 am
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
October 1, 2012 at 1:34 pm
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?
October 2, 2012 at 3:00 am
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
October 2, 2012 at 7:43 am
Thank you for the clarification. I appreciate your help!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply