on 10-12-2005 4:19 PM
I know, old question, has been answered a milion times by now but mine is somewhat different...
I'm trying to add the current user in an inputfield for a metadata property. We need to add multiple users in on metadata property and I need the current user as the default user. No problem you would say.
Problem is I wrote this customized Java class (NO Web Dynpro or iView) based on Thilo Brandts article:
This class is added as a metadata extension so it's NOT a standalone application.
Result is I do not have the 'request' value I need to get the current user id with the:
IUser me = request.getUser();
command. Also I don't find the information on how to use the context method to retrieve the user information.
Anyone?
Hi Luc,
this may help....
If you have a hold of the IResource object (res), then you may be able to use the following command to get the current user:
com.sapportals.portal.security.usermanagement.IUser currentUser = res.getContext().getUser();
regards,
harman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed this looks like the code we need but where do I get the IRecourse ('res') variable from?
public IMetaValue getDefaultValue(IMetaName metaName) { ... }
This is the function where I need the user and as you can see there is no context variable that I can use. This is an obligated function that I have to implement according to the interface.
Any ideas?
Hi,
The code for getting all the users in portal is
IUserFactory userfactory = UMFactory.getUserFactory();
IUserSearchFilter userfltr = userfactory.getUserSearchFilter();
userfltr.setMaxSearchResultSize(2000);
ISearchResult result = userfactory.searchUsers(userfltr);
while (result.hasNext())
{
Vector inData = new Vector();
String uniqueid = (String) result.next();
IUser user = userfactory.getUser(uniqueid);
System.out.println("User Name " + user.getName());
}
Regards
gEorgE
Thanks for the code example but this doesn't solve my problem... I need the username of the CURRENT USER, this list gives an overview of all the users.
How do I extract the current user from this list?!
Let's say I would like to upload a document... the default author value should show MY name.
Thanks!
Hi Luc,
You can try out if ur using portal components
IPortalComponentRequest request=(IPortalComponentRequest)this.getRequest();
IUser user=request.getUser();
String name=user.getUniqueID();
For webDynpro....
IWDClientUser wdUser = WDClientUser.getCurrentUser();
IUser user = wdUser.getSAPUser();
if (user != null)
{
IUserAccount[] acct = user.getUserAccounts();
if(acct[0] != null)
{
String strUserid = acct[0].getLogonUid();
}
}
Hope this Helps
gEorgE
I'm not using WebDynpro, just downloaded the example and tried to adjust it. Problem is I'm not writing a full application but just an extension for my metadata in the Knowledge Management module = only one Java class with a bundle file.
As a result the getReaquest() method does not exist... because it's not a component, just an extension.
Thanks for the help but it still doesn't solve my problem.
Thanks for your answer but this doesn't work either...
This is the kind of solution is I'm looking for: how to get the resource context to ask for the current user. Problem is I don't have the resource context and creating an empty one like Roberto suggests doesn't solve it, it's just an empty resource context.
I was thinking of making a component (that has a valid resource context and can therefor look for the current user) but I don't know if this will work and how I should do this?!
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.