Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2005, 01:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default SP for parent/child relationship

I have three tables - basically the same as sysusers, sysmembers, and syspermissions which form a parent/child relationship, however, I can't for the life of me think how I the permissions out other than from 2 levels.
This is what I'm working with now essentially:
Code:
SELECT     MAX(dbo.syspermissions.actadd)
FROM         dbo.sysmembers RIGHT OUTER JOIN
                      dbo.syspermissions ON dbo.sysmembers.groupuid = dbo.syspermissions.grantee
WHERE     (dbo.syspermissions.grantee = 9) AND (dbo.syspermissions.id = 5) OR
                      (dbo.syspermissions.id = 5) AND (dbo.sysmembers.memberuid = 9)

So this will get me the maximum permissions on ObjectID = 5 for user id = 9 that have been granted to either the user themselves, or any group they are explicitly in.

For example, if UserA is a member of GroupB and GroupB has higher permissions, GroupB's permissions will be returned.

However, If GroupB is a member of GroupC, I can't get that work.

I could have a query along the lines of:
Code:
SELECT     MAX(dbo.syspermissions.actadd)
FROM         dbo.sysmembers sysmembers_1 RIGHT OUTER JOIN
                      dbo.sysmembers ON sysmembers_1.groupuid = dbo.sysmembers.memberuid RIGHT OUTER JOIN
                      dbo.syspermissions ON dbo.sysmembers.groupuid = dbo.syspermissions.grantee
WHERE     (dbo.syspermissions.grantee = 9) AND (dbo.syspermissions.id = 5) OR
                      (dbo.sysmembers.memberuid = 9) AND (dbo.syspermissions.id = 5) OR
                      (sysmembers_1.memberuid = 9) AND (dbo.syspermissions.id = 5)

but I'd rather have something which ran against itself, so I wouldn't have to explicitly state the number of levels

Anyone have any ideas?

I am a loud man with a very large hat. This means I am in charge
__________________
<hr noshade size=\"1\"><i><font color=\"blue\">I am a loud man with a very large hat. This means I am in charge</i></font id=\"blue\">





Similar Threads
Thread Thread Starter Forum Replies Last Post
parent child relationship in far point grid amitnigam Assembly Language 1 January 5th, 2012 10:43 PM
parent child connect s2mo SQL Server 2005 1 February 20th, 2007 07:16 AM
parent child presentation db96s1 Beginning PHP 0 February 7th, 2006 06:19 PM
XML file w ith parent / child relationship bh0526 VB.NET 3 June 18th, 2003 08:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.