on 05-23-2011 10:08 AM
HI,
Is there a API in portal or dynpro using which I can get UserID from the UserName. for example: username enterted by a user on the web dynpro screen is "XYZ". Now, he clicks on a button 'get ID'. User "XYZ" is maintained in portal. How to fetch UserID programatically ?
Regards
seventyros
Hi,
You can make use of IUserFactory and IUserSearchFilter APIs to search for users maintained in portal (UME), by providing either firstname, or lastname or userId or all the three. You will get the set of users whose details matches your search criteria.
Below is an example,
try {
IUserFactory userFactory = UMFactory.getUserFactory();
IUserSearchFilter searchFilter = userFactory.getUserSearchFilter();
searchFilter.setFirstName("firstName", ISearchAttribute.LIKE_OPERATOR, false);
searchFilter.setLastName("LastName", ISearchAttribute.LIKE_OPERATOR, false);
searchFilter.setUniqueName("userId",ISearchAttribute.LIKE_OPERATOR, false);
ISearchResult searchResult = userFactory.searchUsers(searchFilter);
while (searchResult.hasNext()) {
IUser user = UMFactory.getUserFactory().getUser(searchResult.next().toString());
user.getFirstName();
user.getLastName();
user.getUniqueName();
}
}
catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e.getMessage());
}
So you can set either firstname or lastname and user.getUniqueName() will get you UserId.
Regards,
Vishweshwara P.K.M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi buddy, your title and content are totally different,
which you want? get id from name or name from id?
id from name: you have to make search
name from id:
IUser user = userFactory.getUserByLogonID(userId);
user.getFirstName()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could retrieve the corresponding IUser object with all corresponding getters using
IWDClientUser wdUser = WDClientUser.getClientUser("youruserid");
IUser user = wdUser.getSAPUser();
Cheers,
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.