Show TOC

Creating GroupsLocate this document in the navigation structure

Prerequisites

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

More information: User Management Functions for Groups .

Context

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

Procedure

  1. Use the IGroup interface to create the group object and set the required attributes.
    Note

    The unique name may not exceed 200 characters. All other attributes are limited to a maximum of 255 characters.

  2. Commit your changes.

Example

The following example creates a group with the name demo_group and sets the group description.

public static void createGroup(String groupName, String groupDescription) {
			
	/*
     * Note: The unique name of a group cannot exceed 200 characters.
     * All other attributes have a maximum limit of 255 characters.
    */
			
	try {

		IGroup mutableGroup = groupFactory.newGroup(groupName);

		// Set the description attribute of the group. 
				
		mutableGroup.setDescription(groupDescription);

		// Write the changes to the user store.

		mutableGroup.save();
		mutableGroup.commit();

	} catch (GroupAlreadyExistsException gaeex) {
		// TODO: Handle GroupAlreadyExistsException.
	} catch (UMException umex) {
		// TODO: Handle UMException.
	} catch (UMRuntimeException umrex) {
		// TODO: Handle UMRuntimeException.
	}
}