Lotus Script Technique: Get The List of Users From ACL Given Levels.

Programming Tips-And-Tricks

The following function returns a List of Names (users) given a comma-separated-value string of levels: 0-No Access, 1-Depositor… 6-Manager
e.g: Levels = “1,2,3,4” or “4,5,6” or “5”
The users having one of these access levels are returned in a list.

Function getNamesByLevels(Levels As String) As Variant	

	Dim session As New NotesSession 
	Dim db As NotesDatabase 
	Dim acl As NotesACL
	Dim aclEntry As NotesACLEntry	
	Dim userType As Integer
	Dim namesList() As Variant
	Dim currUserNdx  As Integer

	Set db = session.CurrentDatabase
	Set acl = db.acl
	Set aclEntry = acl.GetFirstEntry	
	currUserNdx = -1
	While Not aclEntry Is Nothing	

		If InStr(Levels, CStr(aclentry.Level)) >= 1 Then	
			userType = aclentry.Usertype
			If userType=1 Then    ''Person only
				currUserNdx = currUserNdx + 1
				ReDim Preserve namesList(currUserNdx) As Variant
				namesList(currUserNdx) = aclentry.Name
			End If			
		End If		
		Set aclentry = acl.GetNextEntry(aclentry)

	getNamesByLevels = namesList
End Function

Leave a Reply

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