cancel
Showing results for 
Search instead for 
Did you mean: 

Need to get the user details

Former Member
0 Kudos

Am using below code to get the user details;

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

    {

      

            response.write("Hello world");

            IUserFactory userFactory= UMFactory.getUserFactory();

            response.write("Hello world 1 ");

            IUser myUser = userFactory.getUser(request.getUser().getLogonUid());

            response.write("Hello world 2");

            response.write(myUser.toString());

            response.write("Hello world 3");

}

Its print only "hello world" and "hello world1".

pls suggest how to dispaly current user logged in details.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member193577
Active Contributor
0 Kudos

Hi,

If hello world 2 isnt appearing that means your code is failing with an Exception before that line..

You can just debug and see the error.



In  any case you can try the following:

String userid = request.getUser().getUniqueID();

String useName= request.getUser().getUniqueName();

BR,

Tal

vijay_kumar49
Active Contributor
0 Kudos

Hello Anurag,

I thought IPortalComponentRequest request here you are getting problem. because that

IUser myUser = userFactory.getUser(request.getUser().getLogonUid()); is not executed.


please print what information is coming from the resuest.



Below code its working fine...



try

   {

  wdComponentAPI.getMessageManager().reportSuccess("Hello World");

   IUserFactory userFactory= UMFactory.getUserFactory();

   wdComponentAPI.getMessageManager().reportSuccess("Hello world 1 "+userFactory);

   ISearchResult result = userFactory.getUniqueIDs();

  IUser myUser=null;

  while (result.hasNext()) {

  String uniqueid = result.next().toString();

  myUser= userFactory.getUser(uniqueid);

  String userid = myUser .getUniqueName();

   }

  

  

  wdComponentAPI.getMessageManager().reportSuccess("Hello world 2");

  wdComponentAPI.getMessageManager().reportSuccess(myUser.toString());

  wdComponentAPI.getMessageManager().reportSuccess("Hello world 3");

   }catch(UMException ex)

   {

  

   }

Regards

Vijay Kalluri