Show TOC

Editing Custom and Other User AttributesLocate this document in the navigation structure

Use

This procedure describes how to edit an attribute of the user profile programmatically. Use this procedure if you cannot use the existing user administration tools to modify users and need to customize your tools to modify users programmatically. The user management engine API provides methods for modifying common user attributes, such as e-mail address and first name. For attributes, which do not have a dedicated method, use the generic setAttribute() method. You can use this method to modify any attribute, including custom attributes.

Custom Attributes

The UME enables you to define custom attributes for the user profile. You can use the UME API to manage custom attributes with your own applications.

Note

To manage multivalue custom attributes, you must create your own application to manage them. The identity management user interface does not support multivalue custom attributes. If you try to use identity management to view these attributes, identity management only displays a single value. If you change an attribute with identity management, identity management replaces any multivalues with a single value.

Prerequisites
  • To modify custom attributes, you have created the custom attributes already.

    Use identity management to configure the UME for custom attributes.

    More information:

    SAP Help Portal: Adding Custom Attributes to the User Profile

    Note

    You cannot use the UME API to create new custom attributes programmatically.

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

    More information: User Management Functions for Users .

Procedure

Modify your class with the following procedure.

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

  2. Use the getUniqueID() method to get the unique ID of the user.

  3. Use the isPrincipalAttributeModifiable() method to determine if the attributes you want to change are read-only.

  4. Use the getMutableUser() method to get a modifiable version of the user object.

  5. Use the setAttribute() method to set the attribute.

  6. Commit your changes.

Example

This example gets the unique ID of the user demo_user. The method then gets the user object and changes the value of the attribute myAttributeName in the namespace com.example to myValue.

            public static void modifyUser_additionalAttribute(String logonID,
                String nameSpace, String attributeName, String myValue) {

        try {

                // Get the user.

                


                // Get the unique ID.

                


                // Check if the attribute is read-only or read-write.

                

                                


                        // Get a modifiable user object.

                        


                        /*
                         * Set the attribute value. 
                         * 
                         * Note: The attribute value must not
                         * exceed 255 characters. The value of unique name must not
                         * exceed 200 characters.
                         */

                        

                                        


                        // Write the changes to the user store.

                        

                        

                } else {
                        // TODO: Handle attribute is not modifiable.
                }
        } catch (NoSuchUserException nsuex) {
                // TODO: Handle NoSuchUserException.
        } catch (NoSuchUserAccountException nsauex) {
                // TODO: Handle NoSuchUserAccountException.
        } catch (UMException umex) {
                // TODO: Handle UMException.
        } catch (UMRuntimeException umrex) {
                // TODO: Handle UMRuntimeException.
        }

}