4.16 - Deassign User

void deassignUser(UserRole uRole) throws SecurityException

This command deletes the assignment of the User from the Role entity. The command is valid if and only if:

  • the user is a member of the USERS data set
  • the role is a member of the ROLES data set
  • the user is assigned to the role.

required parameters:

  • UserRole#name - contains the name for already existing Role to be deassigned
  • UserRole#userId - contains the userId for existing User

Throws:

  • SecurityException - in the event data error in user or role objects or system error.

deassignUser

import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.model.UserRole;
import org.apache.directory.fortress.core.SecurityException;

@test
public static void testDeassignUser(String userId, String roleName)
{
    String szLocation = ".testDeassignUser";
    try
    {
        // Instantiate the AdminMgr implementation.
        AdminMgr adminMgr = AdminMgrFactory.createInstance();
        UserRole inUserRole = new UserRole(userId, roleName);
        adminMgr.deassignUser( inUserRole );
    }
    catch (SecurityException ex)
    {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}