如何获得SQL SERVER2000数据库指定对象的权限列表?

3、SQL Server 2000 与关系数据库入门 本文全面介绍了 SQL Server 2000 及其作为关系数据库管理系统的基础知识。内容涵盖评估测试答案解析、客户端/服务器架构原理、数据库类型(包括关系数据库与平面文件数据库、数据仓库与OLTP的区别)、SQL Server 2000 的背景与发展历史、性能监控与资源优化方法、用户权限管理技巧、数据库类型的选择与应用,以及 SQL Server 与 Windows 2000 的协同工作等内容。通过这些内容,帮助读者掌握 SQL Server 2000 的核心概念和实际操作技能,适用于数据库初学者及有一定 阅读详情
前几天看到有人问是否可以方便的获得SQL SERVER2000指定对象的权限和指定USER的权
限。我写了一个存储过程,可以获得用户和角色的权限。请大家帮忙测试一下。看看是
否还有BUG:-)

IF OBJECTPROPERTY( OBJECT_ID( 'usp_getObjectAuthor' ) , 'IsProcedure' ) =1
        DROP PROC usp_getObjectAuthor
GO
/***************************************************************************
*****/
/* Created By : leimin                                   */
/* Created On : 29 May 2004                                              */
/* 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=0
Set @rowcount=0

/***************************************************************************
*****/
/*  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 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.id) and xtype <>'S' )
  order by object_name(a.id)

 select @rowcount=@@rowcount
 if @rowcount=0
  begin
   select @rc=-1
   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=0 and @username is not null and @objectname is null
begin
 if not exists(select * from sysusers where [uid]=user_id(@username) and
status<>0)
 begin
  select @rc=-2
  print 'The user name is not include in sysusers table.'
  return @rc
 end

 if exists(select 1 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 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.id) and xtype <>'S' )
  and ( exists (select 1 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=0
   begin
    select @rc=-3
    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 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 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=0
   begin
    select @rc=-4
    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=0 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=-5
  return @rc
 end
 if @rc=0
  begin
  select  object_name(a.id) as objectname,
   user_name(a.uid) as usename,
   case b.issqlrole when 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.id) and xtype <>'S' )
  and [id]=object_id(@objectname)
  order by object_name(a.id)

  select @rowcount=@@rowcount
  if @rowcount=0
   begin
    select @rc=-6
    print @objectname+' have not grant authorization to any user'
    return @rc
   end
  end
end
/***************************************************************************
*****/
/*  Judge the input parameters ,if @objectname is not null  and @username is
not null */
/*  then return one objects authorization by one user    */
/***************************************************************************
*****/
if @rc=0 and @objectname is not null and @username is not null
begin
 if not exists(select * from sysobjects where [id]=object_id(@objectname)
and xtype<>'S')
 begin
  select @rc=-7
  print 'The object name  is not include in sysobjects table.'
  return @rc
 end

 if not exists(select * from sysusers where [uid]=user_id(@username) and
status<>0)
 begin
  select @rc=-8
  print 'The user name is not include in sysusers table.'
  return @rc
 end

 if exists(select 1 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 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.[id]) and xtype <>'S' )
  and (exists (select 1 from sysmembers
    where groupuid=a.uid and memberuid=user_id(@username))
  or a.uid=user_id(@username))
  and [id]=object_id(@objectname)
  order by object_name(a.id)

  select @rowcount=@@rowcount
  if @rowcount=0
   begin
    select @rc=-9
    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 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.[id]) and xtype <>'S' )
  and  a.uid=user_id(@username)
  and  [id]=object_id(@objectname)
  order by object_name(a.id)

  select @rowcount=@@rowcount
  if @rowcount=0
   begin
    select @rc=-10
    print @username+' have not any objects authorization.'
    return @rc
   end
 end
   end
end
go
exec usp_getObjectAuthor

36、SQL Server 2000 安全管理全解析 本文全面解析了 SQL Server 2000 的安全管理,涵盖了登录设置、服务器角色、数据库用户账户、权限管理以及数据库角色等内容。通过详细的步骤和示例,介绍了如何合理配置安全策略,保障数据库的安全性和合理使用。同时,总结了安全管理的最佳实践和常见问题的解决方案,为数据库管理员提供了实用的参考。 阅读详情

相关推荐

SQL Server 2000数据库备份与迁移:SQL脚本生成详解

SQL Server提供了多种工具来生成和管理SQL脚本,例如SQL Server Management Studio(SSMS)、SQLCMD和Transact-SQL编辑器。SSMS以其图形化界面和丰富的功能集在脚本管理上尤其受到青睐,提供了从数据库对象的创建到数据操作等全面的脚本支持。生成脚本时,SSMS提供了多个选项以定制输出内容。在“脚本化”对话框中,您可以选择包含或排除特定对象的依赖项,以及是否包括脚本执行权限的命令。此外,您可以控制是否输出到新建查询窗口或文件,以及脚本的格式等。

weixin_32102617的博客 760

SQL Server 2000 XML 概述

摘要:在一个任务关键数据存储于不同异构源的世界中,可扩展标记语言 (XML) 通过一种标准格式为不同应用程序间的数据交换和不同系统间的集成提供了强大的机制。 XML 已被紧密集成到 Microsoft® SQL Server™ 关系数据库管理系统 (RDBMS) 当中,可以帮助开发人员建立下一代 Web 和企业应用程序。本白皮书讲述了 SQL Server 2000 中的 XML 功能以及这些

0ffs3t 1448

PB与SQL Server 2000打造学生管理信息系统

本文还有配套的精品资源,点击获取 简介:PB学生管理信息系统是一个使用PowerBuilder和SQL Server 2000开发的教育管理应用程序,旨在优化学校对学生的管理。通过这个系统,初学者可以学习如何使用PowerBuilder开发界面和数据库集成,并通过SQL Server 2000进行数据管理。系统的多个模块,包括学生信息、成绩、出勤、课程、教师和权限管理,为数...

weixin_42126677的博客 1300

如何获得SQLSERVER2000指定对象的权限列表?

<!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--><script type="text/javascript"

zgqtxwd的专栏 264

EXCEL实现分层自定义比例随机抽样(图+文教程)

EXCEL实现分层自定义比例随机抽样(图+文教程) 单一字段分层自定义比例随机抽样 多字段分层自定义比例随机抽样 单一字段分层自定义比例随机抽样 首先数据源如下,我们想随机抽张三的金额数据10%、李四金额20%、王五5%、哈哈15%、李六10% 首先第一步,添加辅助列,随机数 =RAND() 对数据进行高级排序 升序、降序都可以 添加辅助列...

可乐联盟 2万+

智能车常规 PID 以及改进式 PID

智能车常规 PID 以及改进式 PID:连续型PID,增量式PID,位置式PID,不完全微分PID,微分先行PID,以及积分死区,三段式积分分离,变速积分,有效偏差法,抗积分饱和,遇限削弱积分,梯形积分

ittuann的博客 3980

sql2000 mysql_sql2000迷你版 超精简版SQL Server 2000数据库下载

这个《sql2000迷你版》其实就是一个超精简的SQL Server 2000数据库版本!《sql2000迷你版》的好处是,不需要安装庞大的sql2000版本,并且你的电脑可能还用不了,因为不是服务器,而这个普通电脑就可以用了,它是一个精简版SQL Server 2000数据库。sql2000迷你版又称sql2000精简版,这个版本是基于MSDE2000 SP4及SQL2000 SP4企业版合并后...

weixin_36139240的博客 1万+

Chatbox使用指南

Chatbox使用指南

weixin_65289420的博客 2万+

sql server 2000的合并复制及遇到的一些问题

简要介绍一下:sql2000提供了3种复制:快照复制:每次同步时同步所有数据(属于从主服务器-〉备份服务器的单向复制)事务复制:相当于增量复制,只复制改变了的数据(属于从主服务器-〉备份服务器的单向复制)合并复制:相当于双向复制,随便一方改变了数据,其他方都会同步更新,这里也涉及到了数据冲突的问题注:在做事务复制跟合并复制的时候,其实会隐含的自动做一次快照复制,来同步初始数

nihao900的专栏 2046

Codesys电子凸轮从入门到应用:手把手教你用MC_CamIn/MC_CamOut实现主从轴同步

本文详细介绍了如何在Codesys平台上使用MC_CamIn和MC_CamOut功能块实现电子凸轮的主从轴同步控制。从环境配置、轴使能到凸轮表创建与动态切换,提供了完整的程序编写指南和调试技巧,帮助工程师快速掌握工业自动化中的高精度运动控制技术。

weixin_26878995的博客 286

通过一个具体的例子,讲解 SAP Cloud Platform Integration(CPI) 的使用方法

最近笔者由于项目需要,又得学习一个新工具:SAP Cloud Platform Integration,简称 CPI,以前又叫做HCI - HANA Cloud Platform Integration Service.笔者想通过本文,把使用这个工具的第一手体会,分享给曾经用过SAP CRM中间件,但尚未有机会接触到CPI的朋友们。之所以本文标题里把SAP CRM中间件和SAP CPI关联在一起,是因为二者同广义上说,扮演的都是系统集成里中间件的角色。SAP ERP和CRM通过qRFC进行业务数据同步,而中

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 2291

【数据库】sql server 2000升级 2008 r2 后速度慢的问题

更新索引/统计信息: USE 你的库名 EXEC sp_updatestats; 通过以下语句启用自动统计信息创建功能: ALTER  DATABASE[你的库名] SET AUTO_CREATE_STATISTICS ON; 使用一下语句来开启自动更新统计信息: ALTER DATABASE[你的库名] SET AUTO_UPDATE_STATISTICS ON; 使用以下语句...

学习永不晚 6132

RK3568平台(camera篇)点亮imx586摄像头

mipi摄像头硬件确认点:1.供电:5V,2.8V,1.2V,1.8V,reset脚(硬拉3.3,上电的时候从低到高),pwron脚外接3.3V。2,时钟:MCLKOUT是24兆时钟。3.4组差分mipi线。mipi的data线的波形为方波。

weixin_49303682的博客 7265

SQL Server 2000 基础(5)——系统存储过程

  一、一般存储过程1、信息查看类1.1、查看系统对象过程名系统表或视图描述sp_helpserversysservers查看所有服务器信息sp_helpdbsysdatabases查看所有数据库信息,如:名称、大小sp_helploginssyslogins查看所有

张骞 2885

【VisDrone数据集】YOLOX训练VisDrone数据集步骤与结果

YOLOX训练VisDrone数据集步骤与结果。

Gorgeous_wxd 2242

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

数据库可以为用户设置不同的权限

bulkadmin 可以执行bulk insert 语句 dbcreator 可以创建、更改和除去数据库 diskadmin 可以管理磁盘文件 processadmin 可以管理在sql server 中运行的进程 securityadmin 可以管理登录和create database权限,还可以读取错误日志和更改密码 serveradmin 可以设置服务器范围的配置选项,关闭服务器 setup

Cyanapple_wen的专栏 2597

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

SQL Server 数据库对象

SQL Server数据库对象SQL Server的数据库一共有11种对象,包括关系图、表、视图、存储过程、用户、角色、规则、默认、用户定义的数据类型、用户定义的函数、全文目录。关于这11种数据库对象,可以在使用数据库的过程中逐步加深了解。SQL Server 2000默认数据库在SQL Server 2000安装之后,系统自动创建了6个数据库,在企业管理器中可以查看,如图所示:

sky2098的专栏 1万+

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

SQL Server 2000 数据库分离与附加

sp_detach_db从服务器分离数据库,并可以选择在分离前在所有的表上运行 UPDATE STATISTICS。语法sp_detach_db [ @dbname = ] dbname    [ , [ @skipchecks = ] skipchecks ]参数[@dbname =] dbname要分离的数据库名称。dbname 的数据类型为 sysname,默认值为

枫的专栏 4167

SQL Server2000配远程连接配置

SQL Server 2000无论是个人版、企业版还是标准版,只要细版本在8.00.1760以下,均不提供远程数据库连接,即使服务器端工具和客户端工具的设置均有TCP/IP设置和数据库连接属性也设置了RPC远程连接,仍然不能实现远程连接。该怎么解决呢? 解决方案如下: 首先,需要打S...

chuge6367的博客 1841

SQL server 2000邮件配置方法

  --========================================--SQL 邮件配置--outlook 2003,sql server 2000,163邮局--========================================OutLook配置:OutLook 2000 网上说经常发不成功,我用的是OutLook 2003,打开sql server 2000的...

renyucheng的专栏 231

sql2000的数据库角色和服务器角色总结

sql2000的数据库角色和服务器角色总结 SQL Server 2000 和 SQL Server 7.0 版在安装过程中定义几个固定角色。可以在这些角色中添加用户以获得相关的管理权限。下面是服务器范围内的角色。 全名

Simplicity is more complicated than you think 766

如何手动删除 SQL Server 2000 默认实例、命名实例或虚拟实例

如何手动删除 SQL Server 2000 默认实例、命名实例或虚拟实例概要 删除 Microsoft SQL Server 2000 前应考虑的事项 删除 SQL Server 的步骤 删除 SQL Server 的特定实例 删除 SQL Server 的所有已知实例 删除 SQL Server 的默认实例 删除 SQL Server 的命名实例 如何包含全文检索删除 重新安装 SQL Ser

威尔逊的专栏 1459

SQL Server 2000 权限问题

sysadmin 可以在 SQL Server 中执行任何活动。 serveradmin 可以设置服务器范围的配置选项,关闭服务器。 setupadmin 可以管理链接服务器和启动过程。 securityadmin 可以管理登录...

cuixie2370的博客 385

将Sql Server对象的当前拥有者更改成目标拥有者

 批量更改数据库对象所有者nf_ChangeObjectOwner   数据库操作当中,当数据库对象列表不只有一个普通的元素——objectname时,你将要使用objectowner.objectname来引用对象,但如果需要更改当前数据库中对象的所有者可以使用系统存储过程 sp_changeobjectowner (点击这里更详细)sp_changeobjectowner更改当前数据库

zhuimengzhe的专栏 666
上一篇: 如何在SQL SERVER 2000中删除系统文件?
下一篇: 如何建立一个安全的MSSQL SERVER的启动账号?
leimin
博客等级 码龄25年 85粉丝 25原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址