Show TOC

Editing Role AttributesLocate 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 edit a role attribute programmatically. Use this procedure if you cannot use the existing user administration tools to perform role modification and need to customize your tools to edit roles programmatically.

Procedure

  1. Use the IRole interface to get the role object.
  2. Use the getUniqueID() method to get the unique ID of the role.
  3. Use the isPrincipalAttributeModifiable() method to determine if the attributes you want to change are read-only.
  4. Use the getMutableRole() method to get a modifiable version of the role object.
  5. Use the setAttribute() method to set the attribute.
  6. Commit your changes.

Example

This example gets the unique ID of the role "demo_role" . The class then gets the role and changes the value of the attribute "myAttributeName" in the namespace "com.example" to "myValue" .

            public static void modifyRole_additionalAttribute(String roleUniqueName,
                String nameSpace, String attributeName, String myValue) {

        try {

                // Get the role.

                


                // Get the unique ID.

                


                // Check if the attribute is read-only or read-write.

                


                        // Get a modifiable role object from the UME.

                        


                        /*
                         * Set the attribute value. 
                         * 
                         * Note: The attribute value must not exceed 255 characters. 
                         * The value of unique name must not exceed 200 characters.
                         */

                        


                        // Write the changes to the database.

                        

                        

                                                
                } else {
                        // TODO: Handle attribute is not modifiable.
                }
        } catch (NoSuchRoleException nsrex) {
                // TODO: Handle NoSuchRoleException.
        } catch (UMException umex) {
                // TODO: Handle UMException.
        } catch (UMRuntimeException umrex) {
                // TODO: Handle UMRuntimeException.
        }

}