One of the things I find I am often doing in creating business logic for an application is determining if the curtrent user has a specific role. I have just added the following HasRoles property to the DominoDatabase class inside the .DOmino Framework as a way of quickly if a user has a specific role:-
'/**
' * Determine if specific user has a particular role for this database
' */
Property Get HasRole(pUserName As Variant,pRole As String) As Boolean
Dim Username As String
Dim UserRoles As Variant
Try:
On Error Goto Catch
If(iDB Is Nothing) Then Exit Property
Select Case Typename(pUsername)
Case "STRING"
If (pUserName = "") Then UserName$ = Session.UserName$ Else UserName$ = Cstr(pUserName)
Case "NOTESITEM"
UserName = Cstr(pUserName.Values(0))
Case Else
UserName$ = Session.UserName$
End Select
UserRoles = iDB.QueryAccessRoles(UserName$)
Forall UserRole In UserRoles
If Cstr(UserRole) = pRole Then
HasRole = True
Exit Property
End If
End Forall
HasRole = False
Exit Property
Catch:
Stop
Call ReportError()
Exit Property
End Property
Comments (0)