Important alert: (current site time 7/15/2013 8:07:43 PM EDT)
 

VB icon

spObjectPermissions

Email
Submitted on: 2/12/2001 8:07:39 PM
By: John C Kirwin  
Level: Advanced
User Rating: By 7 Users
Compatibility: SQL Server 7.0
Views: 18684
author picture
(About the author)
 
     Stored Procedure to query object permissions for specified user
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
--**************************************
-- Name: spObjectPermissions
-- Description:Stored Procedure to query object permissions for specified user
-- By: John C Kirwin
--
-- Inputs:User's name = @UserID AS VARCHAR(30)
--
-- Returns:User, Grant Status, Object Permission, Database Object
--
--This code is copyrighted and has-- limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=277&lngWId=5--for details.--**************************************

IF EXISTS (SELECT * FROM dbo.sysobjects 
 WHERE id = object_id(N'[dbo].[spObjectPermissions]') 
 AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[spObjectPermissions]
GO
CREATE PROCEDURE [spObjectPermissions] @UserID AS VARCHAR(30) 
AS
/***********************************************************/
/* Stored Procedure:spObjectPermissions*/
/* Creation Date:02/12/2001*/
/* Written by: John C. Kirwin */
/* */
/* Purpose:Stored Procedure to query object */
/*permissions for specified user */
/* */
/* Input Parameters:@UserID */
/* */
/* Updates:*/
/* Date Author Purpose */
/* <this section is used to track changes to the script> */
/* */
/* Examples:EXEC spObjectPermissions 'public' */
/* */
/***********************************************************/
SELECT sysusers.name
, Status = 
CASE protecttype 
	 WHEN 204 THEN 'GRANT_W_GRANT'
	 WHEN 205 THEN 'GRANT'
	 WHEN 206 THEN 'REVOKE'
 ELSE 'Unknown'
END
, Permission = 
CASE action
	 WHEN 193 THEN 'SELECT'
	 WHEN 195 THEN 'INSERT'
	 WHEN 196 THEN 'DELETE'
	 WHEN 197 THEN 'UPDATE'
	 WHEN 26 THEN 'REFERENCE'
	 WHEN 224 THEN 'EXECUTE'
 ELSE 'Unknown'
END 
, sysobjects.name 
FROM sysprotects, sysobjects, sysusers
WHERE sysobjects.id = sysprotects.id 
AND sysprotects.action in (193, 195, 196, 197, 224, 26) 
AND sysprotects.uid = sysusers.uid
AND sysusers.name = @userID
ORDER BY sysusers.name, sysobjects.xtype, sysobjects.name
GO


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
2/12/2001 8:12:13 PMlock & Load

This could prove verrrrryyy useful
(If this comment was disrespectful, please report it.)

 
1/17/2005 5:01:32 PMDavid Sopko

Needed a list of store procedure permissions for a user. Worked perfect. Thanks.
(If this comment was disrespectful, please report it.)

 
5/2/2005 5:26:19 AM

how i can set the sql statements for whenever user insert out of range parameter in my table ,view a alert in screen?
(If this comment was disrespectful, please report it.)

 
5/2/2005 5:28:32 AM

how i can set sql statements for if user insert out of range value in my tabale ,view a alert in the screen?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.