Show TOC

Creating RolesLocate this document in the navigation structure

Prerequisites

You have imported the required interfaces and gotten the required factories.

More information: User Management Functions for Roles .

Context

This procedure describes how to create a role programmatically in the user store. Use this procedure if you cannot use the existing user administration tools to create a role and need to customize your tools to create roles programmatically.

Procedure

  1. Use the IRole interface to create the role object and set the required attributes.
    Note

    The unique name may not exceed 200 characters. All other attributes are limited to a maximum of 255 characters.

  2. Commit your changes.

Example

This example create a role with the name "demo_role" and sets the description attribute to "This role is for demo purposes." .

            public static void createRole(String roleName, String roleDescription) {
                        
        /*
     * Note: The unique name of a role cannot exceed 200 characters.
     * All other attributes have a maximum limit of 255 characters.
    */
                        
        try {

                


                // Set the description attribute of the role. 
                                
                


                // Write the changes to the user store.

                

                


        } catch (RoleAlreadyExistsException raeex) {
                // TODO: Handle RoleAlreadyExistsException.
        } catch (UMException umex) {
                // TODO: Handle UMException.
        } catch (UMRuntimeException umrex) {
                // TODO: Handle UMRuntimeException.
        }
}