取得資料庫中到某個role中所有人員名單函數
------------------------------------
Function getRoleUsersOnDB( RoleName As String , ndb As notesDatabase ) As Variant
%REM
功能:取得某角色在資料庫上的所有使用者名稱
參數:
RoleName:要查詢的角色名稱
ndb:要查詢的資料庫物件
傳回值:符合RoleName的所有人員陣列
%END REM
Dim tacl As NotesACL
Dim taclEntry As NotesACLEntry
Dim tmpArray As Variant , hasRolesInACL As Boolean
Dim arr1 As Variant, i As Integer
On Error Goto SubHander
hasRolesInACL = False
Redim arr1(0) As String
getRoleUsersOnDB = arr1
If RoleName = "" Then Exit Function
If ndb Is Nothing Then Exit Function
If Not( ndb.IsOpen ) Then If Not( ndb.Open( ndb.Server , ndb.FilePath ) ) Then Exit Function
Set tacl = ndb.ACL
For i = Lbound( tacl.Roles ) To Ubound( tacl.Roles )
If Lcase( tacl.Roles( i ) ) = Lcase( RoleName ) Then
hasRolesInACL = True
RoleName = tacl.Roles( i )
Exit For
End If
Next
If hasRolesInACL Then
Set taclEntry = tacl.GetFirstEntry
While Not( taclEntry Is Nothing )
If taclEntry.Isroleenabled( RoleName ) Then
If Not Isarray( tmpArray ) Then
Redim tmpArray( 0 ) As String
Else
Redim Preserve tmpArray( Ubound( tmpArray ) + 1 ) As String
End If
tmpArray( Ubound( tmpArray ) ) = taclEntry.Name
End If
Set taclEntry = tacl.GetNextEntry( taclEntry )
Wend
End If
getRoleUsersOnDB = tmpArray
Exit Function
SubHander:
Exit Function
End Function
---來源臭氧層 Notes 討論區
2008年8月19日 星期二
使用者名稱的比對函數
這範例可以『作 一個使用者名稱的比對』,當 FindMatch = TRUE 時 針對該使用者做出警示工作內容上為完成部分,或是更多的權限控管。
----------------------------------------
%Include "LSCONST.LSS"
' Declare an array of Strings and initialize it with some
' names.
Dim theNames(1 to 6) As String
theNames(1) = "Alex"
theNames(2) = "Leah"
theNames(3) = "Monica"
theNames(4) = "Martin"
theNames(5) = "Elizabeth"
theNames(6) = "Don"
Function FindMatch(yourName As String) As Boolean
Static callCounter As Integer ' To count the number of
' calls to FindMatch.
Dim counter As Integer ' Loop counter.
FindMatch = FALSE
For counter% = 1 to 6
If yourName$ = theNames(counter%) Then
FindMatch = TRUE
Exit For ' Exit from the For loop now.
End If
Next
' If the user enters an invalid name,
' increment callCounter%.
If FindMatch = False Then callCounter% = callCounter% + 1
' After three consecutive invalid names, terminate the script.
If callCounter% = 3 Then
Print "Go away, friend."
End ' Terminate execution.
End If
End Function
--來源 Lotus Notes Designer Help
----------------------------------------
%Include "LSCONST.LSS"
' Declare an array of Strings and initialize it with some
' names.
Dim theNames(1 to 6) As String
theNames(1) = "Alex"
theNames(2) = "Leah"
theNames(3) = "Monica"
theNames(4) = "Martin"
theNames(5) = "Elizabeth"
theNames(6) = "Don"
Function FindMatch(yourName As String) As Boolean
Static callCounter As Integer ' To count the number of
' calls to FindMatch.
Dim counter As Integer ' Loop counter.
FindMatch = FALSE
For counter% = 1 to 6
If yourName$ = theNames(counter%) Then
FindMatch = TRUE
Exit For ' Exit from the For loop now.
End If
Next
' If the user enters an invalid name,
' increment callCounter%.
If FindMatch = False Then callCounter% = callCounter% + 1
' After three consecutive invalid names, terminate the script.
If callCounter% = 3 Then
Print "Go away, friend."
End ' Terminate execution.
End If
End Function
--來源 Lotus Notes Designer Help
取得資料庫使用者名稱
下面這一個範例是『取得使用者名稱』;當可以取得使用者名稱後,可以針對『使用者』加以限制,他的閱讀權限。可以應用在編輯介面與閱讀介面的切換;又或是在『審核過程中』後配合使用者名稱,加以控管『目前審核者』,所擁有的權限。
---------------------------------------
Dim ws As New NotesUIWorkspace
Dim sess As New NotesSession
Dim db As NotesDatabase '目前資料庫
Set db = ws.CurrentDatabase.Database
'以下是宣告ACL,準備讀取角色
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set acl = db.ACL
Set entry = acl.GetEntry( sess.CommonUserName )
If entry Is Nothing Then
Set entry = acl.GetEntry( sess.UserName )
End If
If entry Is Nothing Then
Messagebox _
"No entry for " & sess.CommonUserName & _
" or " & sess.UserName,, "No entry"
Exit Sub
End If
---來源 Lotus Notes Designer Help
---------------------------------------
Dim ws As New NotesUIWorkspace
Dim sess As New NotesSession
Dim db As NotesDatabase '目前資料庫
Set db = ws.CurrentDatabase.Database
'以下是宣告ACL,準備讀取角色
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set acl = db.ACL
Set entry = acl.GetEntry( sess.CommonUserName )
If entry Is Nothing Then
Set entry = acl.GetEntry( sess.UserName )
End If
If entry Is Nothing Then
Messagebox _
"No entry for " & sess.CommonUserName & _
" or " & sess.UserName,, "No entry"
Exit Sub
End If
---來源 Lotus Notes Designer Help
訂閱:
文章 (Atom)