一个Access control的例子
//This function is simple, so i don't have much explain with it.
//Please do not hesitate to contatct me if you have any questions or suggestions!
Function issue_AccessControl(actionname, actiontype, username)
' actionname As String
' actiontype As Long
' username As String
' issue_AccessControl As Boolean
' action is Open
' record type name is Issue
REM return TRUE if the user has permission to perform this action. Example:
REM If username = "pat" Then
REM issue_AccessControl = TRUE
REM Else
REM issue_AccessControl = FALSE
REM End If
//define
dim session
dim resultset
dim SQLquery
On Error Resume Next
userIsAMember = FALSE
set session = GetSession
fullname = session.GetUserFullName
issue_AccessControl = FALSE
REM Only allow the "OwnerResponsible" to Open an Issue
If fullname=GetFieldValue("OwnerResponsible").GetValue() Then
Issue_AccessControl = TRUE
End If
REM Only allow the "ProjectTeam" group users to Open an Issue
If userIsAMember (GetFieldValue("ProjectTeam").GetValue) Then
Issue_AccessControl = TRUE
End If
REM Only allow the CQAdmin group users to Open an Issue
If userIsAMember("CQAdmin") Then
Issue_AccessControl = TRUE
End If
End Function
下面是userIsAMember的定义:
//判断用户是否属于某个特定的组,如果是,则返回true,否则false
Function userIsAMember(groupname)
' groupname As String
set Session = GetSession
userGroups = Session.GetUserGroups
If Not IsArray(userGroups) Then
UserIsAMember = FALSE
Else If "" = Join(Filter(userGroups, groupname, TRUE, vbTextCompare)) Then
UserIsAMember = FALSE
Else
UserIsAMember = TRUE
End If
End if
End Function
搜索更多相关主题的帖子:
control Access 例子