以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 目录树形式的授权的例子,我用的是外部独立用户登录系统,全局变量里定义的用户和组,请问函数怎么写呀, (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=55227)
|
-- 作者:jinxilin
-- 发布时间:2014/8/13 1:00:00
-- 目录树形式的授权的例子,我用的是外部独立用户登录系统,全局变量里定义的用户和组,请问函数怎么写呀,
http://www.foxtable.com/help/index.html?n=2405.htm
目录树形式的授权的例子,看了这个例子,很有用。
我用的是外部独立用户登录系统,全局变量里定义的用户和组,
Public _UserName
As
String Public _UserGroup As
String
但函数这里搞不懂。
请问函数怎么改写呀?
增加一个自定义函数,函数名为ShouQuan,代码为: If User.Type <> UserTypeEnum.User Then \' 如果是开发者或者管理员 Return True \'则具备所有权限 End If Dim dt As DataTable = DataTables("授权") Dim dr As DataRow \'首先判断分组的授权用户是否包括此用户或此用户所属的分组 dr = dt.Find("分组 = \'" & args(0) & "\' And 权限 Is Null" ) If dr Is Nothing Then MessageBox.show("不存在名为""" & args(0) & "分组!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim nms() As String = dr("用户").Split(",") For Each nm As String In nms If nm = User.Group OrElse nm = User.Name Then \'如果授权用户包括登录用户所属的分组或其用户名 Return True \'返回True End If Next End If \'然后判断权限的授权用户是否包括此用户或此用户所属的分组 If Args(1) = "" Then Return False End If dr = dt.Find("分组 = \'" & args(0) & "\' And 权限 = \'" & args(1) & "\'") If dr Is Nothing Then MessageBox.show("不存在名为""" & args(1) & "权限!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim nms() As String = dr("用户").Split(",") For Each nm As String In nms If nm = User.Group OrElse nm = User.Name Then \'如果授权用户包括登录用户所属的分组或其用户名 Return True \'返回True End If Next End If Return False
|
-- 作者:Bin
-- 发布时间:2014/8/13 8:41:00
--
User.Group 改为_UserGroupUser.Name 改为 _UserName
|
-- 作者:jinxilin
-- 发布时间:2014/8/13 8:45:00
--
是不是改成下面这样就行了?
If _UserName.Type <> UserTypeEnum.User Then \' 如果是开发者或者管理员 Return True \'则具备所有权限 End If Dim dt As DataTable = DataTables("授权") Dim dr As DataRow \'首先判断分组的授权用户是否包括此用户或此用户所属的分组 dr = dt.Find("分组 = \'" & args(0) & "\' And 权限 Is Null" ) If dr Is Nothing Then MessageBox.show("不存在名为""" & args(0) & "分组!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim nms() As String = dr("用户").Split(",") For Each nm As String In nms If nm = _UserGroup OrElse nm = _UserName Then \'如果授权用户包括登录用户所属的分组或其用户名 Return True \'返回True End If Next End If \'然后判断权限的授权用户是否包括此用户或此用户所属的分组 If Args(1) = "" Then Return False End If dr = dt.Find("分组 = \'" & args(0) & "\' And 权限 = \'" & args(1) & "\'") If dr Is Nothing Then MessageBox.show("不存在名为""" & args(1) & "权限!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim nms() As String = dr("用户").Split(",") For Each nm As String In nms If nm = _UserGroup OrElse nm = _UserName Then \'如果授权用户包括登录用户所属的分组或其用户名 Return True \'返回True End If Next End If Return False
|
[此贴子已经被作者于2014-8-13 8:49:57编辑过]
|
-- 作者:Bin
-- 发布时间:2014/8/13 8:46:00
--
是的
|
-- 作者:jinxilin
-- 发布时间:2014/8/13 8:50:00
--
谢谢。我研究下,
|