Manage Learn to apply best practices and optimize your operations.

Check if user is part of a specific group

Often it is useful to check if the current user is a member of a specific group. The following subroutine allows you to do this.

View member feedback to this tip.

Often, it is useful to check if the current user is a member of a specific group. The following subroutine allows you to do this.

This is how you call it: if isGroupMember("Administrator")

The ACL property enforce consistent ACL must be checked. You can check roles surrounding the role name between [ ].

Code: Function isGroupMember(grpName As String)

Check if the current user is a member of the group passed as parameter.
Dim namesList
Dim i As Integer , res As Integer
 
namesList = Evaluate
({@UserNamesList})
 
For i = 0 To Ubound(namesList)
  If namesList(i) = grpName Then
   res = True
   Exit For
  End If
 Next
 
 isGroupMember = res
 
End Function

MEMBER FEEDBACK TO THIS TIP

This can be simplified further by using the following code:

Dim v as Variant  ' v must be 
of type Variant v = Evaluate({@Ismember
("Administrator"; @UserNamesList)})
 isGroupMember = v(0)

—Guy G.

******************************************

You can increase the performance if you use the ArrayGetIndex function.

—Eduardo A.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Thierry Seunevel. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close