4.10 - Delete User
void deleteUser(User user) throws SecurityException
This command deletes an existing user from the RBAC database. The command is valid if and only if the user to be deleted is a member of the USERS data set. The USERS and UA data sets and the assigned_users function are updated. This method performs a “hard” delete. It completely removes all data associated with this user from the directory. User entity must exist in directory prior to making this call else exception will be thrown.
required parameters:
- User#userId - maps to INetOrgPerson uid
Parameters:
- user - Contains the User#userId of the User targeted for deletion.
Throws:
- SecurityException - thrown in the event of data validation or system error.
deleteUser
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.ReviewMgr;
import org.apache.directory.fortress.core.ReviewMgrFactory;
import org.apache.directory.fortress.core.model.User;
@test
public static void testDeleteUser(String userId)
{
String szLocation = ".testDeleteUser";
try
{
// Instantiate the AdminMgr implementation which is used to provision RBAC policies.
AdminMgr adminMgr = AdminMgrFactory.createInstance();
User inUser = new User(userId);
adminMgr.deleteUser(inUser);
// now read it back:
// Instantiate the ReviewMgr implementation which is used to interrogate policy information.
ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
try
{
// this should fail because User was deleted above:
reviewMgr.readUser(inUser);
fail(szLocation + " user [" + inUser.getUserId() + "] delete failed");
}
catch (SecurityException se)
{
assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.USER_NOT_FOUND);
// pass
}
LOG.info(szLocation + " user [" + inUser.getUserId() + "] success");
}
catch (SecurityException ex)
{
LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}