Editing Custom and Other User Attributes 
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.
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.
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.
Modify your class with the following procedure.
Use the IUser interface to
get the user object.
Use the getUniqueID() method
to get the unique ID of the user.
Use the isPrincipalAttributeModifiable() method
to determine if the attributes you want to change are read-only.
Use the getMutableUser() method
to get a modifiable version of the user object.
Use the setAttribute() method
to set the attribute.
Commit your changes.
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.
Syntax
public static void modifyUser_additionalAttribute(String logonID,
String nameSpace, String attributeName, String myValue) {
try {
// Get the user.
IUser user = userFactory.getUserByLogonID(logonID);
// Get the unique ID.
String uniqueID = user.getUniqueID();
// Check if the attribute is read-only or read-write.
if (principalFactory.isPrincipalAttributeModifiable(uniqueID,
nameSpace, attributeName)) {
// Get a modifiable user object.
IUserMaint userMaint = userFactory.getMutableUser(uniqueID);
/*
* Set the attribute value.
*
* Note: The attribute value must not
* exceed 255 characters. The value of unique name must not
* exceed 200 characters.
*/
userMaint.setAttribute(nameSpace, attributeName,
new String[] { myValue });
// Write the changes to the user store.
userMaint.save();
userMaint.commit();
} 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.
}
}