Show TOC Start of Content Area

Background documentation User  Locate the document in its SAP Library structure

The SAP NetWeaver Application Server (AS) Java provides interfaces to get details about the current user.

User Management Factory

The user management factory provides access to the user management functions. The user management factory is in the following package:

com.sap.security.api.UMFactory

Interface IUser

The IUser interface provides read access to the available user information.

Examples for user information:

      Company the user belongs to.

      Profile information, like full name and address)

      Authorization information. Which rights does the user have.

The IUserMaintinterface extends the IUser interface and provides methods to change the user information.

Getting a User Object

The user management factory provides several methods to get the IUser object, for example, get user by user name. For all available methods, refer to the Java Docs.

Accessing the Logon ID of a User

You can access the logon ID by iterating through the IUserAccounts array that is returned by method getUserAccounts(), with method getLogonUid().

    IUserAccount accounts[]= null;
    
try {
        accounts= user.getUserAccounts();
    } 
catch (UMException e) {
        response
            .write(
                (
"<br>Error getting accounts: "
                    
+ e.getLocalizedMessage());
    }
    
if (accounts != null) {
        response.write(
            
"<br>Number of Login Accounts: " + accounts.length);
        
for (int i= 0; i < accounts.length; i++) {
            response.write(
                
"<br>** Login ID #"
                    
+ i
                    + 
": Logon ID="
                    
+ accounts[i].getLogonUid()
                    + 
", Assigned user unique ID="
                    
+ accounts[i].getAssignedUserID());
            response.write(
                
"<br>Last Login: "
                    
+ accounts[i]
                        .getLastFailedLogonDate()
                        .toString());
            response.write(
                
"<br># Logins: "
                    
+ accounts[i].getSuccessfulLogonCounts());
        }
    }

 

End of Content Area