知识大全 如何获得SQL Server 2000中知道对象的权限
Posted 权限
篇首语:初心不与年俱老,奋斗永似少年时。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 如何获得SQL Server 2000中知道对象的权限相关的知识,希望对你有一定的参考价值。
如何获得SQL Server 2000中知道对象的权限 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
问题 如何获得SQL SERVER 中知道对象的权限? 解决 前几天看到有人问是否可以方便的获得SQL SERVER 指定对象的权限和指定USER的权 限 我写了一个存储过程 可以获得用户和角色的权限 请大家帮忙测试一下 看看是 否还有BUG: ) IF OBJECTPROPERTY( OBJECT_ID( usp_getObjectAuthor ) IsProcedure ) = DROP PROC usp_getObjectAuthor GO /*************************************************************/ /* Created By : leimin */ /* Created On : May */ /* Description : This stored procedure returns the object permission which you */ /* GRANT DENY and REVOKE */ /**************************************************************/ Create proc usp_getObjectAuthor @objectname sysname = null @username sysname = null as set nocount on begin /**************************************************************/ /* defined the initilization variable */ /**************************************************************/ Declare @rc int Declare @rowcount int Declare @groupid int Set @rc= Set @rowcount= /**************************************************************/ /* Judge the input parameters if @objectname is null and @username is null */ /* then return all objects authorization */ /*************************************************************/ if @objectname is null and @username is null begin select object_name(a id) as objectname user_name(a uid) as usename case b issqlrole when then Group else User end as Role case a protecttype when then Grant when then Grant when then Deny else Revoke end as ProtectType case a [action] when then REFERENCES when then CREATE FUNCTION when then SELECT when then INSERT when then DELETE when then UPDATE when then CREATE TABLE when then CREATE DATABASE when then CREATE VIEW when then CREATE PROCEDURE when then EXECUTE when then BACKUP DATABASE when then CREATE DEFAULT when then BACKUP LOG when then CREATE RULE else end as [Action] user_name(a grantor) as Grantor from sysprotects a inner join sysusers b on a uid=b uid where exists (select from sysobjects where [name]=object_name(a id) and xtype <> S ) order by object_name(a id) select @rowcount=@@rowcount if @rowcount= begin select @rc= print There a no user objects in database! return @rc end end /**************************************************************/ /* Judge the input parameters if @objectname is null and @username is not null */ /* then return all objects authorization where relation @username */ /* if the user belong to a group so we must add the group authorization */ /**************************************************************/ if @rc= and @username is not null and @objectname is null begin if not exists(select * from sysusers where [uid]=user_id(@username) and status<> ) begin select @rc= print The user name is not include in sysusers table return @rc end if exists(select from sysmembers where [memberuid]=user_id(@username)) begin select object_name(a id) as objectname user_name(a uid) as usename case b issqlrole when then Group else User end as Role case a protecttype when then Grant when then Grant when then Deny else Revoke end as ProtectType case a [action] when then REFERENCES when then CREATE FUNCTION when then SELECT when then INSERT when then DELETE when then UPDATE when then CREATE TABLE when then CREATE DATABASE when then CREATE VIEW when then CREATE PROCEDURE when then EXECUTE when then BACKUP DATABASE when then CREATE DEFAULT when then BACKUP LOG when then CREATE RULE else end as [Action] user_name(a grantor) as Grantor from sysprotects a inner join sysusers b on a uid=b uid where exists (select from sysobjects where [name]=object_name(a id) and xtype <> S ) and ( exists (select from sysmembers where groupuid=a uid and memberuid=user_id(@username)) or a uid=user_id(@username)) order by object_name(a id) select @rowcount=@@rowcount if @rowcount= begin select @rc= print @username+ have not any objects authorization return @rc end end else begin select object_name(a id) as objectname user_name(a uid) as usename case b issqlrole when then Group else User end as Role case a protecttype when then Grant when then Grant when then Deny else Revoke end as ProtectType case a [action] when then REFERENCES when then CREATE FUNCTION when then SELECT when then INSERT when then DELETE when then UPDATE when then CREATE TABLE when then CREATE DATABASE when then CREATE VIEW when then CREATE PROCEDURE when then EXECUTE when then BACKUP DATABASE when then CREATE DEFAULT when then BACKUP LOG when then CREATE RULE else end as [Action] user_name(a grantor) as Grantor from sysprotects a inner join sysusers b on a uid=b uid where exists (select from sysobjects where [name]=object_name(a id) and xtype <> S ) and a uid=user_id(@username) order by object_name(a id) select @rowcount=@@rowcount if @rowcount= begin select @rc= print @username+ have not any objects authorization return @rc end end end /**************************************************************/ /* Judge the input parameters if @objectname is not null and @username is null */ /* then return one objects authorization */ /**************************************************************/ if @rc= and @objectname is not null and @username is null begin if not exists(select * from sysobjects where [id]=object_id(@objectname) and xtype<> S ) begin select @rc= return @rc end if @rc= begin select object_name(a id) as objectname user_name(a uid) as usename case b issqlrole when then Group else User end as Role case a protecttype when then Grant when then Grant when then Deny else Revoke end as ProtectType case a [action] when then REFERENCES when then CREATE FUNCTION when then SELECT when then INSERT when then DELETE when then UPDATE when then CREATE TABLE when then CREATE DATABASE when the cha138/Article/program/SQLServer/201311/22087相关参考
SQLServer2000中全文检索的使用 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 微软的
知识大全 .Net下调用SQL Server2000中存储过程
.Net下调用SQLServer2000中存储过程 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
知识大全 调整SQL Server 2000运行中数据库结构
调整SQLServer2000运行中数据库结构 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 开
知识大全 使用SQL Server 2008中对象相关性[2]
使用SQLServer2008中对象相关性[2] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
知识大全 使用SQL Server 2008中对象相关性[1]
使用SQLServer2008中对象相关性[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
知识大全 SQL Server 2000的视图中必须小心使用*符号[4]
SQLServer2000的视图中必须小心使用*符号[4] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一
知识大全 SQL Server 2000的视图中必须小心使用*符号[3]
SQLServer2000的视图中必须小心使用*符号[3] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一
知识大全 SQL Server 2000的视图中必须小心使用*符号[2]
SQLServer2000的视图中必须小心使用*符号[2] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一
知识大全 SQL Server 2000的视图中必须小心使用*符号[1]
SQLServer2000的视图中必须小心使用*符号[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一
知识大全 SQL Server 2000的视图中必须小心使用*符号[5]
SQLServer2000的视图中必须小心使用*符号[5] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一