List of usage examples for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient listUsers
@Override
public ListUsersResult listUsers()
From source file:com.denismo.aws.iam.LDAPIAMPoller.java
License:Apache License
private void populateUsersFromIAM() { AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(credentials); try {/* ww w . ja v a 2s . co m*/ ListUsersResult res = client.listUsers(); Set<String> allUsers = new HashSet<String>(); while (true) { for (User user : res.getUsers()) { try { Collection<Group> groups = client .listGroupsForUser(new ListGroupsForUserRequest(user.getUserName())).getGroups(); Group primaryGroup = groups.size() > 0 ? groups.iterator().next() : null; if (primaryGroup == null) { LOG.warn("Unable to determine primary group for " + user.getUserName()); continue; } Entry groupEntry = getExistingGroup(primaryGroup); if (groupEntry == null) { LOG.warn("Unable to retrieve matching group entry for group " + primaryGroup.getGroupName() + " user " + user.getUserName()); continue; } addUser(user, getUserAccessKey(client, user), groupEntry); updateGroups(groups, user); allUsers.add(user.getUserName()); LOG.info("Added user " + user.getUserName()); } catch (Throwable e) { LOG.error("Exception processing user " + user.getUserName(), e); } } if (res.isTruncated()) { res = client.listUsers(new ListUsersRequest().withMarker(res.getMarker())); } else { break; } } removeDeletedUsers(allUsers); } finally { client.shutdown(); } }
From source file:org.zalando.stups.fullstop.jobs.IdentityManagementDataSource.java
License:Apache License
List<Tuple<String, ListUsersResult>> getListUsersResultPerAccountWithTuple() {
List<Tuple<String, ListUsersResult>> result = newArrayList();
for (String accountId : getAccountIds()) {
AmazonIdentityManagementClient identityClient = clientProvider.getClient(
AmazonIdentityManagementClient.class, accountId, Region.getRegion(Regions.EU_WEST_1));
if (identityClient != null) {
result.add(new Tuple<>(accountId, identityClient.listUsers()));
} else {//from w ww.j a v a 2 s . c o m
logger.error("Could not create 'AmazonIdentityManagementClient' for accountId : {}", accountId);
}
}
return result;
}