|
Re: Get Logged in user [message #883501 is a reply to message #883313] |
Fri, 08 June 2012 17:12 |
|
You can get session variables in a report expression or script like:
var sess = reportContext.getHttpServletRequest().getSession();
var myvar = sess.getAttribute("youvariable");
I am not sure how you would get the user into session.
Jason
On 6/8/2012 5:16 AM, Rick Mising name wrote:
> We're running Tomcat 3.7.1. on Tomcat 5.5.
> Tomcat 5.5 is running on Linux, the clients are Windows clients in an AD
> Domain. What would be the best way to get the username of the user
> requesting the report? I should be able to get it from Tomcat using this
> method?
> Unfortunately, i'm unable to post links, but googling for this gives the
> post i'm talking about:
> 20140-accessing-servlet-context-in-the-report
> I've been trying to get this working, but i can't figure it out entirely.
|
|
|
|
Re: Get Logged in user [message #884711 is a reply to message #884635] |
Mon, 11 June 2012 16:44 |
|
Thanks for posting your solution.
Jason
On 6/11/2012 10:25 AM, Rick Mising name wrote:
> Thanks for your reply Jason. Further investigation based on your
> response made me find the solution ;)
>
> This describes is (cp, because i can't post urls)
>
>
> A. Application server configuration (e.g. Tomcat)
>
> Add the jcifs-x.jar to the '<BIRT_VIEWER_HOME>\WEB-INF\lib' directory
> Configure the BIRT-viewer application to authenticate via NTLM by adding
> the NTLM-filter to the web.xml:
> <filter>
> <filter-name>NtlmHttpFilter</filter-name>
> <filter-class>jcifs.http.NtlmHttpFilter</filter-class>
>
> <init-param>
> <param-name>jcifs.smb.client.domain</param-name>
> <param-value>your.domain</param-value>
> </init-param>
> <init-param>
> <param-name>jcifs.netbios.wins</param-name>
> <param-value>domain-controller.your.domain</param-value>
> </init-param>
>
> <init-param>
> <param-name>jcifs.util.loglevel</param-name>
> <param-value>2</param-value>
> </init-param>
> </filter>
>
> <filter-mapping>
> <filter-name>NtlmHttpFilter</filter-name>
> <servlet-name>ViewerServlet</servlet-name>
> </filter-mapping>
> <filter-mapping>
> <filter-name>NtlmHttpFilter</filter-name>
> <servlet-name>EngineServlet</servlet-name>
> </filter-mapping>
> </filter>
> Restart your Tomcat application server Test if your BIRT-application is
> secured:
> --> You should now be prompted for your username & password
> NTLM Authentication
>
> B. BIRT Report design
> Once authenticated, you can check authorization via your Report using
> the BIRT Rhino Javascript.
> On your dataset you can add a parameter using a default scripted value
> like:
> var myLoginName = null;
> var request = reportContext.getHttpServletRequest();
> if (request!=null) {
> if (request.getRemoteUser()!=null) {
> myLoginName = request.getRemoteUser();
> }
> }
> myLoginName;
> BIRT authentication: scripted parameter
> This parameter you can use in your query / stored procedure to filter
> data matching the logged-in username.
> Download report-authentication example
>
> When you run this example report on your NTLM-enabled application server
> (see A.), you get prompted for username & password and will see a list
> of products (our example query simply checks if the username is not null)
>
>
> optional: you can also embed this into a global
> getLoggedInUsername()-function, so you can simply call
> getLoggedInUsername() to get the logged-in user (*).
> function getLoggedInUsername() {
> var myLoginName = null;
> var request = reportContext.getHttpServletRequest();
> if (request!=null) {
> if (request.getRemoteUser()!=null) {
> myLoginName = request.getRemoteUser();
> }
> }
> return myLoginName;
> }
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03308 seconds