Sample Code:
Sub SetGroupPermissions()
Dim session As New NotesSession
Dim serverName As String
Dim dbDirectory As NotesDbDirectory
Dim database As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
serverName = session.CurrentDatabase.Server ' 取得目前伺服器名稱
' 開啟資料庫目錄
Set dbDirectory = session.GetDbDirectory(serverName)
' 處理所有資料庫
Set database = dbDirectory.GetFirstDatabase(DATABASE)
While Not database Is Nothing
' 開啟 ACL
Set acl = database.ACL
' 檢查群組是否已存在於 ACL 中
Set entry = acl.GetEntry("DeclineAccess", True)
If entry Is Nothing Then
' 如果群組不存在,創建一個新的 ACL設定
Set entry = acl.CreateACLEntry("DeclineAccess",
ACLLEVEL_NOACCESS)
Else
' 如果群組已存在,設定權限級別為無權限
Call entry.SetLevel(ACLLEVEL_NOACCESS)
End If
' 將群組類型設為個人群組
entry.IsPersonGroup = True
' 更新 ACL
Call acl.Save()
' 取得下一個資料庫
Set database = dbDirectory.GetNextDatabase
Wend
MsgBox "群組權限設定完成。"
End Sub
沒有留言:
張貼留言