在项目中常常要定义不同的project级别的用户与权限,仿照windows的role/user/access right的控制,我的实现如下:
if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[tsvobject]) and objectproperty(id, nisusertable) = 1)drop table [dbo].[tsvobject]go 【程序编程相关:ActiveX控件的打包发布[无证书发布】
1.在数据库中建立5个表:tsvrole, tsvuser, tsvobject, tsvroleuser与tsvroleobject,分别存储role.user.object.role-user对应关系以及role-object对应关系.建表的tsql如下: 【推荐阅读:怎么由DataSet将数据导入Excel】
if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[tsvroleobject]) and objectproperty(id, nisusertable) = 1)drop table [dbo].[tsvroleobject]go 【扩展信息:Using a Custom Actio】
if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[tsvrole]) and objectproperty(id, nisusertable) = 1)drop table [dbo].[tsvrole]go
if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[tsvroleuser]) and objectproperty(id, nisusertable) = 1)drop table [dbo].[tsvroleuser]go
if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[tsvuser]) and objectproperty(id, nisusertable) = 1)drop table [dbo].[tsvuser]go
create table [dbo].[tsvobject] ([fobjectid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null ,[fobjectname] [varchar] (50) collate sql_latin1_general_cp1_ci_as not null ) on [primary]go
create table [dbo].[tsvrole] ([froleid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null ,[frolename] [varchar] (50) collate sql_latin1_general_cp1_ci_as not null ) on [primary]go
... 下一页