K2 SmartForms

How to implement Role Base security for K2 SmartForms using Http Modules

How to implement Role Base security for K2 SmartForms

Usually, we will implement the security on each and every form to check user authorization.  In this article we will see how we can implement group level security trimming for all forms in one place.

Step 1: Create Class Library
a) Create a classlibrary project with a class inheriting from IHttpModule
b) Add event handlers – in our case we added three events –  BeginRequest, PreRequestHandlerExecute, EndRequest

How to implement Role Base security for K2 SmartForms

How to implement Role Base security for K2 SmartForms – Step 1

c) Implement your logic in PreRequestHandlerExecute Event, in this event we can get access to read the Logged-In user details and requested pagename.

How to implement Role Base security for K2 SmartForms

How to implement Role Base security for K2 SmartForms – Step 2

d) Check the logged-in user groupname /Rolename using smartobjects
e) Check if the group has authorization to access the requested page by passing page name and group name.

How to implement Role Base security for K2 SmartForms

How to implement Role Base security for K2 SmartForms – Step 3

f) If the group doesn’t have permission to access the requested page, then page will get redirected to the default page.

How to implement Role Base security for K2 SmartForms

How to implement Role Base security for K2 SmartForms – Step 4

Step 2: Add ClassLibrary DLL to SmartForms Config File

a) Build the class library and do signing with strong naming key
b) Install DLL to GAC
c) Register ClassLibrary DLL in SmartForms runtime web.config file

How to implement Role Base security for K2 SmartForms

How to implement Role Base security for K2 SmartForms – Step 6

Now, the users from Contribute/ Visitors group can access only their allowed forms.

Also we can make the list of page URL’s as dynamic by defining in the database table or some other appropriate places that can be modified by administrator.

How to implement Role Base security for K2 SmartForms

You may also like

Leave a comment

PODCAST  |  Why you need to establish a K2 Center of Excellence today

Interview with Arno van Rooyen, CEO, Velocity