cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve all the users through Webdynpro Java

Former Member
0 Kudos

Hello All,

I am writing a Webdynpro Java Application where I want to retrieve all the users who use the Portal . Our portal is connected to the LDAP server.

I know that I can get the current logged in user using the code below:

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

IUser sapUser = wdClientUser.getSAPUser();

Is there a way to get all the users the portal has, using Webdynpro Java.?

Any help would be highly appreciated.

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

what's your real requirement?

if you try to retrieve all user, it is likely to make your page hang.

Edited by: John Wu on Aug 24, 2011 6:54 PM

Stefan-EA
Contributor
0 Kudos

Take look at this example on how to retrieve all the users who are logged in the portal

http://wiki.sdn.sap.com/wiki/display/WDJava/CheckallUserswhohaveloggedintoportal-webdynproappl

Here is an overview of the UME API.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3641e490-0201-0010-c68f-e51221925...

Former Member
0 Kudos

Hello Stefan,

Thanks for the reply. So we can get all the current logged in users, what i am thinking can we get the list of all the users using the Portal, whether they are logged on or not.

Pls reply.

Thanks

Former Member
0 Kudos

You may have to write the code to loop through the datasources, and get all the users associated with each datasource.

You can get datasource of a user by following code:

String[] datasources = umeUser.getAttribute(IPrincipal.DEFAULT_NAMESPACE, IPrincipal.DATASOURCE);
if(datasources[0].equals("CORP_LDAP")){
.........
}

Not sure if reverse is possible...

If Portal just uses LDAP as the only datasource, then you can get this list directly from LDAP (contact the LDAP admin).

Hope this helps.

Former Member
0 Kudos

Thanks for the reply.

So I can get the LDAP Data Source for the Portal. Once I get the datasource , how can I retrieve the list of all users for that datasource using Webdynpro Java .?

Pls reply.

Thanks again

Former Member
0 Kudos

Try this:

IUserFactory userfact = UMFactory.getUserFactory();

IUserSearchFilter sf = ufact.getUserSearchFilter();

sf.setUniqueName("*USER.CORP_LDAP.*", ISearchAttribute.LIKE_OPERATOR, false);

ISearchResult sr = userfact.searchUsers(sf);

while (sr.hasNext()) {
/*loop through all the users in LDAP*/
}

Former Member
0 Kudos

Thanks for the reply. So how can I get the SearchResult Set as an ArrayList so as to loop through the list as like Arralist<i> th element.?

Pls help

former_member40425
Contributor
0 Kudos

Hi

Use following to get all users.



IUserFactory uFactory = UMFactory.getUserFactory();
ISearchResult AllUserIds = uFactory.getUniqueIDs();
while (AllUserIds.hasNext()) {
String UserID = (String) AllUserIds.next();
IUser sapUser = uFactory.getUser(UserID );
if (sapUser.getUserAccounts()[0] != null) {
wdComponentAPI.getMessageManager().reportSuccess("Logon UID: " + sapUser.getUserAccounts()[0].getLogonUid());
}
}

I hope it helps.

Regards,

Rohit

Former Member
0 Kudos

Writing such a component may result in out-of-memory exception or the page might hang. Try this alternate way:

Search for all the groups (*) in LDAP (from All Data Sources dropdown) in UME. Select "Yes, show me the complete result." from the warning. Now click export and copy-paste this in a text file. Write a simple parsing program, that'll get the user list from this huge file.