SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


object privileges


object privileges

Author
Message
jgovindaraman
jgovindaraman
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 14
I need query to pull out all the objects privileges owned by the users in sql server 2000 databases. Any help is greatly appreciated. Thank You
Steve Jones
Steve Jones
SSC Guru
SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)SSC Guru (146K reputation)

Group: Administrators
Points: 146057 Visits: 19425
Try this: http://www.sqlservercentral.com/scripts/Permissions/64309/

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
bitbucket-25253
bitbucket-25253
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15699 Visits: 25280
If what Steve has recommended does not do what you need try this:
CREATE PROCEDURE UDP_User_Permissions AS    
SET NOCOUNT ON --Don't want all the counts from the process to return

--Check for and drop our temp table if exists
-- IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE [name] LIKE '#tmpInher%'
-- DROP TABLE #tmpInher

--Create our temp work table to make sure we have all the inheritance
CREATE TABLE #tmpInher (
[qid] [int] IDENTITY (1,1) NOT NULL,
[user] [int] NOT NULL,
[inherfrom] [int] NOT NULL,
PRIMARY KEY ([user],
[inherfrom]
)
)

--Insert the inheritance base items which are the users themselves.
INSERT INTO #tmpInher ([user], [inherfrom]) SELECT [uid], [uid] FROM sysusers WHERE issqlrole = 0 AND hasdbaccess = 1 and uid != 1

--Loop thru until we get all the inheritance items that a user is associated with.
WHILE EXISTS (SELECT
oT.[user],
groupuid
From
sysmembers
Inner Join
#tmpInher oT
ON
oT.[inherfrom] = sysmembers.memberuid
Where
groupuid NOT IN (
SELECT
inherfrom
From
#tmpInher iT
Where
iT.[User] = oT.[User]
)
)
BEGIN
INSERT INTO #tmpInher ([user], [inherfrom])
SELECT
oT.[user],
groupuid
From
sysmembers
Inner Join
#tmpInher oT
ON
oT.[inherfrom] = sysmembers.memberuid
Where
groupuid NOT IN (
SELECT
inherfrom
From
#tmpInher iT
Where
iT.[User] = oT.[User]
)
End

--Check permissions for the user from all inheritance paths.

SELECT
u2.[name] AS UserName,
u1.[name] AS InheritesVia,
Case xtype
WHEN 'U' THEN 'Table'
WHEN 'V' THEN 'View'
WHEN 'S' THEN 'System'
WHEN 'P' THEN 'Procedure'
WHEN 'FN' THEN 'Function'
END AS ObjectType,
sysobjects.[name] AS Object,
CASE WHEN xtype IN ('U','V','S') THEN
CASE
WHEN (actadd & 1) = 1 THEN 'Granted'
WHEN (actmod & 1) = 1 THEN 'Denied'
Else 'Revoked'
End
Else ''
END AS [SELECT],
CASE WHEN xtype IN ('U','V','S') THEN
CASE
WHEN (actadd & 8) = 8 THEN 'Granted'
WHEN (actmod & 8) = 8 THEN 'Denied'
Else 'Revoked'
End
Else ''
END AS [INSERT],
CASE WHEN xtype IN ('U','V','S') THEN
CASE
WHEN (actadd & 2) = 2 THEN 'Granted'
WHEN (actmod & 2) = 2 THEN 'Denied'
Else 'Revoked'
End
Else ''
END AS [UPDATE],
CASE WHEN xtype IN ('U','V','S') THEN
CASE
WHEN (actadd & 16) = 16 THEN 'Granted'
WHEN (actmod & 16) = 16 THEN 'Denied'
Else 'Revoked'
End
Else ''
END AS [DELETE],
CASE WHEN xtype IN ('P','FN') THEN
CASE
WHEN (actadd & 32) = 32 THEN 'Granted'
WHEN (actmod & 32) = 32 THEN 'Denied'
Else 'Revoked'
End
Else ''
END AS [EXEC],
CASE WHEN xtype IN ('U','V','S') THEN
CASE
WHEN (actadd & 4) = 4 THEN 'Granted'
WHEN (actmod & 4) = 4 THEN 'Denied'
Else 'Revoked'
End
Else ''
END As DRI
From
syspermissions
Inner Join
#tmpInher
Inner Join
sysusers u1
ON
u1.uid = [inherfrom]
Inner Join
sysusers u2
ON
u2.uid = [User]
ON
[inherfrom] = grantee
Inner Join
sysobjects
ON
sysobjects.[ID] = syspermissions.[ID]
Order By
[UserName],
[ObjectType],
[Object]

--Drop out temp table as we no longer need.
--DROP TABLE #tmpInher



If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search