Sometimes you discover that the default User ACL entry is totally wrong. How to change all maildatabases’ ACL and it’s roles?

Need to know:

 

Constant
Integer
Access level
ACLLEVEL_NOACCESS
0
No access
ACLLEVEL_DEPOSITOR
1
Depositor access
ACLLEVEL_READER
2
Reader access
ACLLEVEL_AUTHOR
3
Author access
ACLLEVEL_EDITOR
4
Editor access
ACLLEVEL_DESIGNER
5
Designer access
ACLLEVEL_MANAGER
6
Manager access

Dim s As New notessession
Dim nab As NotesDatabase
Dim db As notesdatabase
Dim doc As NotesDocument
Dim caldoc As NotesDocument
Dim view As NotesView
Dim mailserv As String
Dim mailfl As String
Dim mailowner As String
Dim ACL As NotesACL
Dim entry As NotesACLEntry

‘gets current db (ie names.nsf on the server)
Set nab = s.getdatabase(“<servername>”, “names.nsf”) ‘POPULATE SERVERNAME
‘get people view on the names.nsf
Set view = nab.GetView(“People”)
‘gets the first persondoc from the view
Set doc = view.GetFirstDocument
‘loop to go through all person docs and change acl
While Not doc Is Nothing

‘get mail server and mail file from the person document
mailserv = doc.GetItemValue(“MailServer”)(0)
mailfl = doc.GetItemValue (“MailFile”)(0)
‘get the mail database from the mailserver and mail file name
Set db = s.GetDatabase(mailserv,mailfl)
If Not db Is Nothing Then
If db.IsOpen Then
‘Skip databases which you don’t have access to
On Error 4060 Goto Error4060
‘get the calendar profile to verify the owner of the mail file
Set caldoc = db.GetProfileDocument(“CalendarProfile”)
mailowner = caldoc.GetItemValue(“Owner”)(0)
‘This means the Owner property isn’t set cannot continue
If mailowner<>”” Then
‘Get the ACL of the mail db
Set ACL = db.ACL
‘Get the ACL entry for the mail owner
Set entry = acl.GetEntry (mailowner)
If entry Is Nothing Then ‘If the owner isn’t in the ACL add them:
‘This example adds the user as Editor (common with 6.x/7.x)
Set entry=acl.CreateACLEntry(mailowner, 4)
entry.IsPerson=True Else
entry.Level=4 End If
entry.CanDeleteDocuments=True
entry.CanCreateSharedFolder=True
‘You may optionally want to include
entry.CanCreatePersonalFolder=True
entry.CanCreatePersonalAgent=True
entry.CanCreateLSOrJavaAgent=True
‘Save the ACL updates
Call acl.Save End If ‘If mailowner<>”” Then End If ‘If db.IsOpen Then End If ‘If Not db Is Nothing Then

GetNextDoc:

Set doc = view.GetNextDocument(doc)

Wend
Exit Sub
Error4060:
‘If the code reaches here then the user does not have access rights.
Resume GetNextDoc

 

Visits: 323

By angioni

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.