一个数据库设计的问题![权限管理] (200分)

  • 主题发起人 梦菲斯
  • 开始时间
人员分组权限:用于区别各个部门等级,总经理0x-部门经理1x-职员2x……
数据分组权限:用于区分各个数据表单控件等,a窗体0y-b菜单1y-c数据表2y……
人员分组权限-数据分组权限 对照表:用于最终确定大部分职员的权限。
或者用一张大表
------项目-------------
- -
人------权 限----------
员------限 权----------
- -
---------------------
当然实现shi除了用数据表外,还可以用专门的程序进行控制。
 
这个问题很好
 
可以告诉小弟解决方法吗?
 
我所撰写的可以动态的控制使用者的画面。
例如主选单和任一个Form的Button或Function。
但是这个实做不是很容易的,要有几个Table。
1员工主档
2 (主选单资料文件)树状资料文件
3 Form使用权资料文件
4 Function的资料文件等
最重要的是要写在父代的Form 上 ,当要撰写一个维护或查询的程序时,就继承其父代的Form,其程序代码如下
此段写在FromCreate,就可以达到某一字段或是Button的使用权的设定
for I := ComponentCount - 1do
wnto 0do
begin
if Components is TDCOMConnection then
begin
TDCOMConnection(Components).ComputerName:=SECConnection.ComputerName;
LCComputerName:=TDCOMConnection(Components).ComputerName;
end;
{ if Components is TWebConnection then
begin
LCComputerName:=TWebConnection(Components).url;
// LCComputerName:='11111111';
// showmessage(LCComputerName);
end;
}
if Components is TDbKeyComboBox then
begin
if (not (rtEdit in RightList)) then
TDbKeyComboBox(Components).Enabled:=false;
end;

if Components is TDBMatchComboBox then
begin
if (not (rtEdit in RightList)) then
TDBMatchComboBox(Components).Enabled:=false;
end;

if Components is TDBCombBox then
begin
if (not (rtEdit in RightList)) then
TDBCombBox(Components).Enabled:=false;
end;
//增加wwDBComboBox
if Components is TwwDBComboBox then
begin
if (not (rtEdit in RightList)) then
TwwDBComboBox(Components).Enabled:=false;
end;
//wwDBCombDlg
// if Components is TwwDBCombDlg then
// begin
// if (not (rtEdit in RightList)) then
// TwwDBCombDlg(Components).Enabled:=false;
// end;
//wwDBLookupComboDlg
if Components is TwwDBLookupComboDlg then
begin
if (not (rtEdit in RightList)) then
TwwDBLookupComboDlg(Components).Enabled:=false;
end;
//wwDBLookupCombo
if Components is TwwDBLookupCombo then
begin
if (not (rtEdit in RightList)) then
TwwDBLookupCombo(Components).Enabled:=false;
end;

if Components is TDBRadioGroup then
if (not (rtEdit in RightList)) then
TDBRadioGroup(Components).Readonly:=True;
if Components is TDBCheckBox then
if (not (rtEdit in RightList)) then
TDBCheckBox(Components).Readonly:=True;
if Copy(TXTString[0],1,4)<>'CPDS' then
begin
if Components is TEDBNavigator then
//判断使用者是否有权限使用此Form上Navigator之增,修,删,查,印表(RList)
begin
RightSet:=[];
for j:=0 to TXTString.Count-1do
begin
if GetLeftStr(TXTString[j],' ')=rs_FormName+'L' then
begin
S:=GetRightStr(TXTString[j],' ');
if Pos('I',S)>0 then
Include(RightSet, nbInsert);
if Pos('D',S)>0 then
Include(RightSet, nbDelete);
if Pos('E',S)>0 then
Include(RightSet, nbEdit);
if Pos('Q',S)>0 then
Include(RightSet, nbQuery);
if Pos('P',S)>0 then
Include(RightSet, nbPrint);
TEDBNavigator(Components).VisibleButtons:=
TEDBNavigator(Components).VisibleButtons-RightSet;
Exit;
end;
end;
end else
if (Components is TButton) or (Components is TBitBtn)
or (Components is TSpeedButton) Or (Components is TfcShapeBtn)
then
//判断使用者是否有权限使用此Form上之Button(RFunc)
begin
if TXTString.Find(rs_FormName+'F '+Components.Name,index) then
TButton(Components).Enabled:=False;
end else
if (Components is TDBEdit) or (Components is TwwDBEdit) then
//判断使用者是否有权限使用此Form上之Edit(ROther)
begin
if TXTString.Find(rs_FormName+'O '+Components.Name,index) then
TDBEdit(Components).ReadOnly:=True;
end else
If (Components is TTabSheet) then
if TXTString.Find(rs_FormName+'F '+Components.Name,index) then
TTabSheet(Components).TabVisible:=False;
end;
//if Copy(TXTString[0],1,4)<>'CPDS' then
end;
//for i:=ComponentCount-1do
wnto 0do

ub_NewBillNo := False;
// rs_FormName := TForm(Sender).Caption;
ActiveDataSource.DataSet:=dsdataset;
//if WindowState<> wsMaximized then
// TForm(Sender).Height := TForm(Sender).Height+24;
 
请继续关注!采众之长!
 
overload the Windowproc of every component. once the component get
cm_visiblechange or cm_enablechange message, then

invoke a security check function.
if use action list, overload onupdate event
 
我在两层做过了相关的,是用代码控制的,成功了一部分,为什么说一部分呢,就是太
复杂了,设计时没有想好,听说这个用存储过程很好完成,可能就是做一个专门控制
权限返回的过程,传入所要查看的资料类型,部门等参数,然后返回是否有权限查看
吧,没做过,但想在下一版本中完成这个功能
 
关注·!学习
 
用菜单控制吧,不要想什么了。做就做个比较完整的机构
 
感觉Motar Liu的不错!
 
如何做到像WINDOWS用户组的权限继承,如aa属于ADMINISTRATORS组,那么他就有
ADMINISTRATORS的所有权限!
 
其實在設計表結構的時候加入創建的ID,在權限表中對ID進行控制就行了,如果是本部門的
經理則允許查看,不是本部門的經理必須經過授權才能查看。同時,如果是公司老總,則它
的數據濟鑒權限更大。
 
建立如下四张与权限有关的表:
Rights(RightID,RightName,...);
RightGroup(RightGroupID,RightGroupName);
RightGroupDetail(RightGroupID,RightID);
OperatorRight(OperatorID,RightGroupID);
这样就能实现权限组的功能,也可解决你的问题。
 
同意 hdfsun,而且我也是这样实现的。
 
本人设计了一权限系统,绝对满足楼顶所希望的设计,但是自认为扩展性不是很好,
如果需求对权限要求更细的话则可能不能满足要求。设计如下:
先假设客户表的字段里面有销售人员编号这个字段。
并且你们的人员资料表是按树型进行排列的,比如
比如总经理
采购部经理
客户部经理
。。。。。
李发
刘东方
人员资料里面有总经理,部门经理标志位。且每个人都有自己所属的部门,并且只能属于
一个部门,老板的所属的部门为空。
先建表如下,
right(int rightID,char(5) UserID,char(200) RightUserID)
UserID表示该员工自己的编号,RightUserID是表示该员工有权查看某人所填写的记录的
人员编号,格式为(11,23,17,245),写一个函数getRight(AUserID:integer):String,
该函数的功能是根据AUserID的身份不同可以生成查看员工编号的集合,如
(11,23,17,245),在选择客户表的记录的时候SQL语句是SELECT * FROM 客户表
where 客户表.UserID in (getRight(AUserID)),AUserID为当前登陆用户编号。
在getRight(AUserID)中,如果AUserID是部门经理的话,该函数返回该部门所有的
人员编号(在人员资料表里面可以实现)再加上RightUserID字段里面的人员编号,
如果AUserID是老板的话,那么返回空值。那么上面的SQL语句就不用加WHERE限制了。
当然现在缺的是一个权限维护窗口,就是对right表进行增,删,改的窗口,应该说
不是很难。
总的来说应该设计应该满足楼顶的需求,但是如果需求更改比如说经理要可以看不同的
部门的话,那么相应就要在RIGHT里面增加DEPT字段来管理,并且从效率上来讲,如过
公司在1000以上的话,那么RightUserID应该很多的,效率比较低。
 
我也做过,我用的是对菜单功能进行控制
 
1、2、3用过滤即可
4 具体情况具体对待
如果是分不共享、部门共享、公司共享……的话,
在客户的表中加个字段就行了,和1、2、3一样过滤
如果具体到对人
需要单独用表
 
按员工的职位信息设置权限,缺少灵活性。
我比较欣赏火鸟BBS的权限分配系统,所有权限以字母表示,
如某个用户的权限定义为"ABcdef",即表示该用户拥有
A,B,c,d,e,f六种权限,至于每个字母代表的权限含义,
在程序中定义。
另外再配合用户分组(类)权限的定义,就更好了。
 
有没有比较通用的权限管理例子啊。包括数据库设计
 
顶部