Show TOC

Displaying UsersLocate 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 you can get a user and read an attribute of that user. Use this procedure when you need to display user data and no existing application suits your needs. Once your custom application has read the data, you must decide how to display it.

Note

The SAP NetWeaver Application Server (AS) Java includes a user viewer application. This application is meant to display contact information to other users.

More information:

SAP Help Portal: Allowing Users to View the Contact Information of Other Users .

Procedure

  1. Use the IUser interface to get a user.
  2. Read the required attributes.
    • For some attributes there are dedicated methods to read them, such as the getEmail() method.

    • For other attributes, determine the attribute type and use the appropriate method to read them.

      • For single-value attributes, use the getBinaryAttribute() method.

      • For multivalue attributes, use the getAttribute() method.

    • For multivalue attributes, use the getAttribute() method.

    • For single-value attributes, use the getBinaryAttribute() method.

Example

This example gets the user demo_user and reads the attribute myAttributeName in the com.example namespace.

            public static void showUser(String logonID, String nameSpace,
                String attributeName) {

        try {
                // Get the user.

                


                // Show basic data.
                
                

                

                


                /*
                 * Check the attribute type and read the attribute content with the
                 * corresponding method.
                 */

                

                


                        // Read the content of a multi-value string attribute.

                        

                                        

                


                        // Read the content of a single-value binary attribute.

                        

                                        


                } else {
                        // TODO: Handle attribute not available or does not exist.
                }
        } catch (NoSuchUserException nsuex) {
                // TODO: Handle NoSuchUserException.
        } catch (NoSuchUserAccountException nsauex) {
                // TODO: Handle NoSuchUserAccountException.
        } catch (UMException umex) {
                // TODO: Handle UMException,
        } catch (UMRuntimeException umrex) {
                // TODO: Handle UMRuntimeException.
        }
}