Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

[5分]权限读取

李制樯  发表于:2014-03-30 09:51:40  
复制

 

Top
杜超-2号 发表于:2014-03-31 15:28:56

将以下代码粘贴到 Main.mdb 的 basRDPRef模块中:

Public Function HasPermission(ByVal ModuleName As String, _
                              Optional ByVal FunctionName As String _
                              ) As Boolean
    On Error GoTo ErrorHandler
    Dim strRoleID       As String
    Dim lngModuleID     As Long
    Dim lngFunctionID   As Long
    Dim strModuleName   As String
    Dim strFunctionName As String
    Dim strMessage      As String
    Dim blnNoControl    As Boolean
    Dim strWhere        As String
   
    HasPermission = False
   
    strModuleName = "'" & Replace(ModuleName, "'", "''") & "'"
    lngModuleID = Nz(DLookup("ModuleID", "SysLocalModules", "ModuleName=" & strModuleName), 0)
    If lngModuleID = 0 Then
        strMessage = LoadString("Permission module | is not defined, control does not effective.")
        strMessage = Replace(strMessage, "|", ModuleName)
        MsgBoxEx strMessage, vbCritical
        Exit Function
    End If
   
    If GetParameter("Use Developer Identity Login", dbBoolean, False) Then
        HasPermission = True
        Exit Function
    End If
   
    If ACount("*", "Sys_Roles") < 2 Then
        HasPermission = True
        Exit Function
    End If
   
    strRoleID = GetParameter("Current User Role ID", dbLong, "")
    If Not ACount("*", "Sys_ModulePermissions", "RoleID=" & strRoleID & " AND ModuleID=" & lngModuleID) > 0 Then
        Exit Function
    End If
   
    If Len(FunctionName) = 0 Then
        Exit Function
    End If
   
    strFunctionName = "'" & Replace(FunctionName, "'", "''") & "'"
    lngFunctionID = Nz(DLookup("FunctionID", "SysLocalFunctions", "FunctionName=" & strFunctionName), 0)
    If lngFunctionID = 0 Then
        strMessage = LoadString("Permission item |2| in |1| is not defined, control does not effective.")
        strMessage = Replace(strMessage, "|1|", ModuleName)
        strMessage = Replace(strMessage, "|2|", FunctionName)
        MsgBoxEx strMessage, vbCritical
        Exit Function
    End If
   
    If ACount("*", "Sys_FunctionPermissions", "RoleID=" & strRoleID & " AND FunctionID=" & lngFunctionID) > 0 Then
        HasPermission = True
    End If

ExitHere:
    Exit Function
   
ErrorHandler:
    MsgBoxEx Err.Description, vbCritical
    Resume ExitHere
End Function



总记录:1篇  页次:1/1 9 1 :