Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Mar 11, 2010 at 04:16 PM

    You can try this:

    session.getAttribute(u201CLOGON_IDu201D);

    Add a 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

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.