Deleting Roles

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 delete a role programmatically. Use this procedure if you cannot use the existing user administration tools to perform role deletion and need to customize your tools to delete roles programmatically.

Procedure

  1. Use the IRole interface to get the role object.
  2. Use the deleteRole() method to delete the role.

Example

This example gets the role object, “demo_role” , then deletes it.

public static void deleteRole(String roleUniqueName) {

	try {

		// Get the role.

		IRole role = roleFactory.getRoleByUniqueName(roleUniqueName);

		// Delete the role.

		roleFactory.deleteRole(role.getUniqueID());

	} catch (NoSuchRoleException nsrex) {
		// TODO: Handle NoSuchRoleException.
	} catch (UMException umex) {
		// TODO: Handle UMException.
	} catch (UMRuntimeException umrex) {
		// TODO: Handle UMRuntimeException.
	}
}