Users and groups

The user and group classes allow you to get a list of users and user groups on the iSeries™ server as well as information about each user through a Java™ program.

Note: IBM® Toolbox for Java also provides resource classes that present a generic framework and consistent programming interface for working with various iSeries objects and lists. After reading about the classes in the access package and the resource package, you can choose the object that works best for your application. The resource classes for working with users are RUser and RUserList.

Some of the user information you can retrieve includes previous sign-on date, status, date the password was last changed, date the password expires, and user class. When you access the User object, use the setSystem() method to set the system name and the setName() method to set the user name. After those steps, you use the loadUserInformation() method to get the information from the iSeries.

The UserGroup object represents a special user whose user profile is a group profile. Using the getMembers() method, a list of users that are members of the group can be returned.

The Java program can iterate through the list using an enumeration. All elements in the enumeration are User objects; for example:

    // Create an AS400 object.
    AS400 system = new AS400 ("mySystem.myCompany.com");

    // Create the UserList object.
    UserList userList = new UserList (system);

    // Get the list of all users and groups.
    Enumeration enum = userList.getUsers ();

    // Iterate through the list.
    while (enum.hasMoreElements ())
    {
        User u = (User) enum.nextElement ();
        System.out.println  (u);
    }
Retrieving information about users and groups

You use a UserList to get a list of the following:

The only property of the UserList object that must be set is the AS400 object that represents the system from which the list of users is to be retrieved.

By default, all users are returned. Use a combination of setUserInfo() and setGroupInfo() to specify exactly which users are returned.

Example: Using a UserList to list all of the users in a given group.