2017-11-17 11 views
0

を使用してAS400が有効なユーザーのみを取得する方法は、jt400のUserListのgetUsersメソッドに有効なユーザーのみを取得する可能性がありますか?jt400 API

私は次の実装を行いましたが、パフォーマンスは良くありません。 これで、より良い方法を見つけようとしています。ユーザーをフィルタリングし、有効なユーザーのみを取得する可能性がある場合。

Set<String> as400Users = new HashSet(); 
AS400 as400 = new AS400(host, username, password); 

//Retrieving Users 
UserList users = new UserList(as400); 
Enumeration io = users.getUsers(); 

    while (io.hasMoreElements()) { 
      com.ibm.as400.access.User u = (com.ibm.as400.access.User)io.nextElement(); 
      String userName = u.getName(); 

      if (u.getStatus().equalsIgnoreCase("*ENABLED")) { 
       as400Users.add(userName); 
      } 

     } 

答えて

3

あなたはこのようUSER_INFOビューを照会できます。

select * 
from qsys2.user_info 
where status = '*ENABLED' 

これは、V7.1で使用可能になりました。これは、あなたが権限を持っているユーザーのみを提供することに注意してください。

また、フィルタ内部getName()コールに移動する場合があります

Set<String> as400Users = new HashSet(); 
AS400 as400 = new AS400(host, username, password); 

//Retrieving Users 
UserList users = new UserList(as400); 
Enumeration io = users.getUsers(); 

while (io.hasMoreElements()) { 
    com.ibm.as400.access.User u = (com.ibm.as400.access.User)io.nextElement(); 

    if (u.getStatus().equalsIgnoreCase("*ENABLED")) { 
     as400Users.add(u.getName()); 
    } 

} 

それとも、今だけの最速の方法を選択しgetUsers(-1,0)

Set<String> as400Users = new HashSet(); 
AS400 as400 = new AS400(host, username, password); 

//Retrieving Users 
UserList users = new UserList(as400); 
for (com.ibm.as400.access.User u: users.getUser(-1,0)) { 
    if (u.getStatus().equalsIgnoreCase("*ENABLED")) { 
     as400Users.add(u.getName()); 
    } 
} 

で新しいforeach構文を使用することができます。

関連する問題