Show TOC

Procedure documentationDeleting Users Locate this document in the navigation structure

 

This procedure describes how to delete a user programmatically from the user store. Use this procedure if you cannot use the existing user administration tools to delete a user and need to customize your tools to create users programmatically.

Recommendation Recommendation

We do not recommend that you delete users, but rather lock them and set their validity date so that they are no longer valid. This is to keep the users in the system for the purpose of maintaining an audit trail.

End of the recommendation.

Prerequisites

You have imported the required interfaces and gotten the required factories.

More information: User Management Functions for Users.

Procedure

  1. Use the IUser interface to get the user object.

  2. User the deleteUser() method to delete the user.

Example

This example gets the user demo_user and deletes it.

Syntax Syntax

  1. public static void deleteUser(String logonID) {
    
    	try {
    
    		// Get the user.
    
    		IUser user = userFactory.getUserByLogonID(logonID);
    
    		// Delete the user.
    
    		userFactory.deleteUser(user.getUniqueID());
    
    	} catch (NoSuchUserException nsuex) {
    		// TODO: Handle NoSuchUserException.
    	} catch (NoSuchUserAccountException nsuaex) {
    		// TODO: Handle NoSuchUserAccountException.
    	} catch (UMException umex) {
    		// TODO: Handle UMException.
    	} catch (UMRuntimeException umrex) {
    		// TODO: Handle UMRuntimeException.
    	}
    }
    
End of the code.