We can list all users belongs to particular user store using jaggery. To achieve this, create a directory(ListUser) inside "<BPS>/repository/deployment/server/jaggeryapps" and then create a jaggery file(listUser.jag) inside a newly created folder. In this example, I used WSO2 BPS to test this sample.
<%
var carbon = require('carbon');
var tenantId = -1234;
var url = 'https://<HOSTNAME>:9443/admin/services/';
var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId);
print(userManager.getUserListOfRole("ROLE"));
%>
Here, you need to change the "HOSTNAME" and "ROLE" according to your config. Please find the sample listUser.jag blow, where my "HOSTNAME" is localhost and user "ROLE" is WSO2USERSTORE/clerk.<%
var carbon = require('carbon');
var tenantId = -1234;
var url = 'https://localhost:9443/admin/services/';
var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId);
print(userManager.getUserListOfRole("WSO2USERSTORE/clerk"));
%>
Once you add "listUser.jag" file, go to the browser and enter the URL https://localhost:9443/ListUser/listUser.jag
["WSO2USERSTORE/testUser", "WSO2USERSTORE/testuser123", "WSO2USERSTORE/vive123"]

Comments
Post a Comment