|
|
|
|
|
|
|
|
|
|
|
|
|
|
Managing database ACLs from a browser (continued)
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim acl As NotesACL
Dim acle As NotesACLEntry
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
REM Get the required global entries from the ACL object and put them on the form
Set acl = db.ACL
Call doc.ReplaceItemValue("mxInet", acl.InternetLevel)
Call doc.ReplaceItemValue("dbroles",acl.Roles)
REM get the first username on the ACL
Set acle = acl.GetFirstEntry
REM start list of all the names on the ACL
nlist = acle.Name
Set acle = acl.GetNextEntry(acle)
REM get username selected before form reloaded & this agent was called
formSelectName = doc.getitemvalue("name")(0)
REM cycle through each entry in the database ACL
While (Not acle Is Nothing)
REM get username
tname = acle.Name
REM append name to list & use same delimiter from ACL form "users" field choices
nlist = nlist +"*!*"+tname
REM if this username is the same as the one selected on the form then get all its data
If acle.Name = formSelectName Then
Call doc.ReplaceItemValue("usrRoles",acle.Roles)
Call doc.ReplaceItemValue("usrType", acle.UserType)
Call doc.ReplaceItemValue("usrLevel",acle.Level)
REM the following user properties correspond to the choices in the "usrprops" field
If acle.CanCreateDocuments = True Then props = props+"CRD "
If acle.CandeleteDocuments = True Then props = props+"DLD "
If acle.CanreplicateorcopyDocuments = True Then props = props+"CD "
If acle.ispublicreader = True Then props = props+"RPD "
If acle.ispublicwriter = True Then props = props+"WPD "
REM the following line turns the props variable into a text array
props = Evaluate("@Explode({"+props+"}{ })")
REM set the usrprops field with the values from the array
Call doc.ReplaceItemValue("usrprops",props)
End If
REM get the next ACL entry to process
Set acle = acl.getnextentry(acle)
Wend
REM put the names of all the ACL entries in the acles field
Call doc.ReplaceItemValue("acles",nlist)
|
The code is pretty well documented so I won't go into specifics, but basically it cycles through all the entries on the ACL and collects their names to populate the "users" field choices on the ACL form. It also gets the names of all the database roles, and checks to see if a user has been selected in the "users" field. If so, when the script comes across its ACL entry, it copies all the data to the form fields.
The next agent is the "AddACLUsr" agent, which adds new users to the ACL. The code for the agent is as follows:
Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim acl As NotesACL
Dim acle As NotesACLEntry
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Set acl = db.ACL
REM Create new ACL Entry with data from form
nUser = doc.GetItemValue("newUser")(0)
uLvl = doc.GetItemValue("usrlevel")(0)
Set acle = acl.CreateACLEntry(nUser, uLvl)
REM set the new entry's ACL user type
uType = doc.GetItemValue("usrType")(0)
acle.UserType = uType
REM Cycle & set ACL Entry Roles
uRoles = doc.GetItemValue("usrRoles")
Forall x In uRoles
acle.EnableRole(x)
End Forall
REM Cycle & select ACL Entry Properties.
uProps = doc.GetItemValue("usrProps")
Forall x In uProps
Select Case x
Case "CRD"
acle.cancreatedocuments = True
Case "DLD"
acle.CanDeleteDocuments = True
Case "RPD"
acle.IsPublicReader = True
Case "WPD"
acle.IsPublicWriter = True
Case "CD"
acle.CanReplicateOrCopyDocuments = True
End Select
End Forall
REM save all the changes to the database ACL
Call acl.save()
REM Redirect user's browser
wpath = doc.getitemvalue("dbpath")(0)
Print "["+wpath+"ACL?Open&name="+nUser+"]"
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino
- Don't spend unproductive time maintaining different versions of the same spreadsheet
- Preserve data integrity and security in multi-user environments
- Create reports in minutes INSIDE Notes
- Get freedom from iterative report requests, deliver self-serve capabilities
Experience Reporting, Dashboards, and Analysis INSIDE Notes.
Try IntelliPRINT NOW! |
|
|
|
|
|
|
|
|
|
|