Action access control hook example

Access-control hooks restrict access to particular actions based on a specific set of criteria. In HCL Compass Designer, you can restrict actions to specific groups of users by choosing a hook type of User Group, or you can give everyone access to the action by choosing All Users. You can also choose the Scripts option and write a VBScript or Perl hook to determine access.

The following example shows how to limit access to a user named "Pat."

VBScript


Function swbug_AccessControl(actionname, actiontype, username)

    ' actionname As String

    ' actiontype As Long

    ' username As String

    ' swbug_AccessControl As Boolean

    ' action = close


    Dim is_ok 

    ' Test whether the current user has the privilege to close this bug

    If username = "Pat" Then

      is_ok = TRUE

    Else

      is_ok = FALSE

    End If

    swbug_AccessControl = is_ok


End Function 

Perl


sub swbug_AccessControl {

    my($actioname, $actiontype, $username) = @_;

    my $result;

    # $actionname string scalar, $actiontype as long scalar

    # $username as string scalar, # action is Close

    # return TRUE if the user has permission to perform this action



    if ($username eq "Pat") {

      $result = 1;

    } else {

      $result = 0;

    }

    return $result;

}