actuate.getUserID() returns null after authenticated using JSAPI - authenticate

bcmp
bcmp Member
edited February 11, 2022 in Analytics #1
<p>Once the user is authenticated using acutate.authenticate(), and tried to access the actuate.getUserID(). It returns null.</p>
<p> </p>
<p>Any steps is missed out. Plz do know the steps to retrieve the user id once authenticated </p>

Comments

  • Clement Wong
    Clement Wong E Community Moderator
    <p>Are you using single sign-on?  Or passing in null into authenticate()?</p>
    <p> </p>
    <p><a data-ipb='nomediaparse' href='http://developer.actuate.com/be/documentation/ManualsIHUB31/actuate-api-reference.pdf'>http://developer.actuate.com/be/documentation/ManualsIHUB31/actuate-api-reference.pdf</a></p&gt;
    <p style="margin-left:40px;"> </p>
    <p style="margin-left:40px;"><em>Returns the user name of the logged-in user that was supplied to authenticate().<br>
     <br>
    If single sign-on is used and login occurs without passing credentials to authenticate( ), this method returns null or an empty string.</em></p>
    <p style="margin-left:40px;"> </p>
    <p>
    If it is not behaving as expected, please log a case with Support.</p>
    Warning No formatter is installed for the format ipb
  • <p>Using single sign on....</p>
  • Clement Wong
    Clement Wong E Community Moderator
    <p>null is expected for SSO.  For security, the JSAPI login servlet only returns success or failure, and sets a JSESSIONID cookie.  No username or other user information is transmitted over the wire.</p>
    <p> </p>
    <p>Wouldn't your existing app that first authenticated before the JSAPI authenicate() know the username?</p>
    <p> </p>
    <p>A colleague provided a workaround if you truly needed to get the username. </p>
    <p> </p>
    <p>1. Create a JSP under /iportal.  This page will return a JSON string of the logged in username.</p>
    <pre class="_prettyXprint">
    <%@ page language="java" contentType="application/json"  pageEncoding="ISO-8859-1"%>
    <%@ page import="java.util.Arrays" %>
    <%@ page import="javax.json.*" %>

    <jsp:useBean
        id="userinfobean"
        class="com.actuate.activeportal.beans.UserInfoBean"
        scope="session"/>    

    <%
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", -1);

    String user = userinfobean.getUserid();
    out.println("{user: '" + user + "'}");
    %>
    </pre>
    <p>2. From your application, make an AJAX call to the JSP page to retrieve the username.</p>
    Warning No formatter is installed for the format ipb
  • <p>In the app as a part of login mechanism, authenticate() method is used for login. From then on, all the call to reporting server are made with null value for username and password.</p>
    <p> </p>
    <p>I meant Single sign on this aspect and not the implementation in another application.</p>
    <p> </p>
    <p>It was quite informative on other use cases scenario mentioned above. Thanks!</p>
  • @Clement Wong This code worked for me today.

    Thanks you.