Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need User Name/userid from Portal in WebDynpro Java application

Hi All,

I am using my Webdynpro for Java application as a iveiw in Enterprise portal. I want to get the Username/userid for the portal. how can we get that?

Regards,

Puneet Aggarwal

Former Member
Former Member replied

Use below code for retrive al users from portal:

try {
		IUserFactory ufactory=UMFactory.getUserFactory();
		ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();
		
		IUserFactory usf = UMFactory.getUserFactory();
		
		
		
		IUser iuser = null;
		
		//IUserListElement userElement = null;
		
		int i = 0;
		IPrivateKmnewsView.IUserNodeNode usernode=wdContext.nodeUserNode();
		IPrivateKmnewsView.IUserNodeElement usernodeelement = null;
		
		while (rst.hasNext()) {
		
		iuser =
		
		UMFactory.getUserFactory().getUser(rst.next().toString());
		//wdComponentAPI.getMessageManager().reportSuccess("rst.next().toString() : "+rst.next().toString());
		usernodeelement = usernode.createUserNodeElement();
		String UID=iuser.getUid().toString();
		//wdComponentAPI.getMessageManager().reportSuccess("UID:"+UID);
		usernodeelement.setUserId(UID);
		//wdContext.currentUserNodeElement().setUserId(UID);
		String UniqueID=iuser.getUniqueID().toString();
		//wdComponentAPI.getMessageManager().reportSuccess("UniqueID:"+UniqueID);
		String email = iuser.getEmail();
		
		String fname = iuser.getFirstName();
		
		String lname = iuser.getLastName();
		String Name =fname+lname;
		//if(!(fname.equalsIgnoreCase("") ^ fname.equalsIgnoreCase("")))
		//{
		//if(currentUsers.equals()
		usernodeelement.setUserName(Name);
		usernodeelement.setUserEmailID(email);
		usernode.addElement(usernodeelement);
		
		//wdComponentAPI.getMessageManager().reportSuccess("Name : "+fname+""+lname);
		
		//wdComponentAPI.getMessageManager().reportSuccess("Email : "+email);
		//}
		} 
		wdContext.currentContextElement().setUserTableVisible(WDVisibility.VISIBLE);
	} catch (UMException e) {
		// TODO Auto-generated catch block
		wdComponentAPI.getMessageManager().reportSuccess("Exception "+e);
	}  

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question