Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Permissions

Author  Topic 

IanMJ
Starting Member

3 Posts

Posted - 2001-01-15 : 07:45:05
Hi,

I'm trying to build a permissions based system using ASP & SQLServer.

I have two tables, a users/groups table and a parent/child join table.

Example:
tblUsersGroups
Id 1 Name = Parent Company A
Id 2 Name = Subsidiary Company B
Id 3 Name = Subsidiary Company C
Id 4 Name = User A
Id 5 Name = User B
Id 6 Name = User C

tblParentChild relationships
Parent id 1 Child id 2
Parent id 1 Child id 3
Parent id 1 Child id 4
Parent id 2 Child id 5
Parent id 3 Child id 6

This makes 'User A' a member of the 'Parent Company A', 'User B' a member of 'Subsidiary Company B' and 'User C' is a member of 'Subsidiary Company C'.

What I'm trying to do with SQL is get my user's id, find out what group they belong to and show them products from that group and groups that are below them in the chain, so if you are a member of 'Parent Company A' you can see everything from Parent Company A, Subsidiary Company B, Subsidiary Company C. If you are only a member of Subsidiary Company B you can only see Subsidiary Company B's products. You could then go on to define Subsidiary Company B has Team A and B etc.

Would I need to go through a loop to achieve this?

Thanks,

Ian
   

- Advertisement -