4.15 - Assign User

void assignUser(UserRole uRole) throws SecurityException

This command assigns a user to a role. 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 not already assigned to the role
  • The SSD constraints are satisfied after assignment.

required parameters:

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

optional parameters

  • UserRole#beginTime - HHMM - determines begin hour role may be activated into user’s RBAC session
  • UserRole#endTime - HHMM - determines end hour role may be activated into user’s RBAC session.
  • UserRole#beginDate - YYYYMMDD - determines date when role may be activated into user’s RBAC session
  • UserRole#endDate - YYYYMMDD - indicates latest date role may be activated into user’s RBAC session
  • UserRole#beginLockDate - YYYYMMDD - determines beginning of enforced inactive status
  • UserRole#endLockDate - YYYYMMDD - determines end of enforced inactive status
  • UserRole#dayMask - 1234567, 1 = Sunday, 2 = Monday, etc - specifies which day role may be activated into user’s RBAC session

Throws:

  • SecurityException - in the event of validation or system error.

assignUser

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 testAssignUser(String userId, String roleName)
{
    String szLocation = ".testAssignUser";
    try
    {
        // Instantiate the AdminMgr implementation.
        AdminMgr adminMgr = AdminMgrFactory.createInstance();
        UserRole inUserRole = new UserRole(userId, roleName);
        adminMgr.assignUser( inUserRole );
    }
    catch (SecurityException ex)
    {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}