Skip to Content
avatar image
Former Member

How to get Username within custom code

Hello all,

I have written some custom code that asks the user for data that will in turn get printed out.

I am able to create the Activity, Attach it to a button within a POD, it pops up fine and I can collect the data, but I cannot tell who the User was.

The request object has the SFC, Site Operation, etc, but no User information.

I also tried the session object, but that has no data at all.

Any ideas on how I would be able to get the Username?

Thanks,

Mike

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 11, 2010 at 04:16 PM

    You can try this:

    session.getAttribute(u201CLOGON_IDu201D);

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Rusty Baldwin

      Sorry but the explanation and code snipet does not quite make sense to me.

      Could you please try to clarify it a little bit more for me? Perhaps some sample code might help?

      Here is what I have tried in the jsp code:

      <%

      try

      {

      out.println("Getting Principal<br>");

      java.security.Principal p = request.getUserPrincipal();

      out.println("Got Principal<br>");

      if(p == null)

      out.println("Principal is NULL<br>");

      else

      {

      out.println("Principal toString = "p.toString()"<br>");

      out.println("Getting Principal Name<br>");

      String n = p.getName();

      out.println("Got Principal Name = "n"<br>");

      }

      }

      catch(Exception e)

      {

      out.println(e);

      }

      %>

      Here are the results:

      Getting Principal

      Got Principal

      Principal is NULL

      Thanks for helping out it is much appreciated,

      Mike

  • Jul 05, 2012 at 10:18 AM

    Hello Mike,

    Have you found a solution already? If so, please, share it with the community and close this thread.

    Regards,

    Alex.

    Add comment
    10|10000 characters needed characters exceeded