[英]How to retrieve only AS400 Enabled Users using jt400 API
is there a possibility to retrieve only the Enabled Users -to add a filter- to the getUsers method of UserList of jt400? 是否只能检索jt400的UserList的getUsers方法的“已启用的用户”(添加过滤器)?
I did the following implementation but it does not have a good performance, so I am trying to find a better way and if there is a possibility to filter the users and to get only the Enabled users. 我执行了以下实现,但是它的性能不佳,因此,我试图找到一种更好的方法,是否有可能过滤用户并仅获取已启用的用户。
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);
}
}
You could query the USER_INFO view like this: 您可以像这样查询USER_INFO视图:
select *
from qsys2.user_info
where status = '*ENABLED'
This became available at v7.1. 从v7.1开始可用。 Note that this only provides users that you have authority to.
请注意,这仅提供您有权访问的用户。
You also might want to move the getName()
call inside the filter: 您可能还想将
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());
}
}
Or you could use the newer foreach
syntax with getUsers(-1,0)
或者您可以对
getUsers(-1,0)
使用更新的foreach
语法
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());
}
}
Now just choose the fastest method. 现在只需选择最快的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.