Show TOC

Editing Common User AttributesLocate this document in the navigation structure

Prerequisites

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

More information: User Management Functions for Users .

Context

This procedure describes how to edit the common user attributes programmatically in the user store. Use this procedure if you cannot use the existing user administration tools to edit user attributes and need to customize your tools to change user attributes programmatically.

Example

Some common user attributes are:

  • E-mail address

  • First name

  • Job title

  • Telephone number

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 user object.
  5. Use the method to set the user attribute.
    Example

    Use the method setEmail() to set the e-mail address of the user.

    More information:

    SAP Help Portal: http://help.sap.com/javadocs.

  6. Commit your changes.

Example

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

            public static void modifyUser_setEmail(String logonID, String email) {

        try {

                // Get the user.

                


                // Get the unique ID.

                


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

                

                                


                        // Get a modifiable user object.

                        


                        


                        // 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
        }

}