Show TOC

Displaying 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 you can get a role and read an attribute of that role. Use this procedure when you need to display role data and no existing application suits your needs. Once your custom application has read the data, you must decide how to display it.

Procedure

  1. Use the IRole interface to get the role object.
  2. Read the required attributes.

    For some attributes there are dedicated methods to read them, such as the getDescription() method. For other attributes, determine the attribute type and then use the getAttribute() method to read them.

Results

With this procedure you have read the contents of the role attributes. You must determine the best way to display this data and modify your custom application to do so.

Example

This example gets the role, "demo_role" , reads the description, then reads the value of the attribute "myAttributeName" in the namespace "com.example" .

            public static void showRole(String roleUniqueName, String nameSpace,
                String attributeName) {

        try {
                // Get the role by unique name.

                


                // Show basic data. 
                                        
                


                // Check the attribute type and read the attribute content with the
                // corresponding method.

                


                if (attributeType == IPrincipal.STRING_TYPE) {
                                                
                        // Read the content of a multi-value string attribute.
                                                
                        


                } else if (attributeType == IPrincipal.BYTE_TYPE) {
                                        
                        // Read the content of a single-value binary attribute.
                                                
                        

                } else {

                        // TODO: Handle attribute not available or does not exist.
                }
        } catch (NoSuchRoleException nsrex) {
                // TODO: Handle NoSuchRoleException.
        } catch (UMException umex) {
                // TODO: Handle UMException.
        } catch (UMRuntimeException umrex) {
                // TODO: Handle UMRuntimeException.
        }
}