Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to run a .rpt without login on? 2

Status
Not open for further replies.

ITCPhil

Technical User
Jun 30, 2005
181
CA
This is for Crystal Report/Enterprise 10 using an Oracle ODBC. Notice that we do not use EPortfolio here, most reports are just viewed online with the odd report that can be run when you click on a url.

My question is for someone who is requesting a report that they can run themselves at any time prior to coming into the office. They want the report to be run when they click on a weblink, but of course, if you do that, the database login information is viewable either in the address bar or source code.

Is there a simple way to bypass this login but allowing the report to prompt the database? The BO site mentions 2 solutions - either using ASP or creating a domain account. Would anyone have a simpler solution?? I am extremely low on the priority list of the group who maintains the server so whatever I ask them can take weeks or even months to be processed...

Thanks in advance.
Phil
 
Hi,
Don't confuse the database login needed for the report's data and the authentication user/pass needed to access objects in the CMS ( like Reports)..

The URL can have &apsname=Guest, for instance, to run any report which allows the Guest account ( which usually has no password) to view_on_demand..The database info for that report's data is saved when it is published and need not be provided when running the report..
Example ( BOE XI R2):
Code:
[URL unfurl="true"]http://<YourCEServer>/crystalreportviewers115/viewrpt.asp?id=1112914&apsname=Guest&apsauthtype=secEnterprise[/URL]
Substitute your CE server's name and any valid Report ID
to have the Report prompt for any parameters or supply them on the URL in the form :

&promptex-paramname=123





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Not sure if this is relevant but if it's a published report you can set the login info in the enterprise management system, thereby negating the need to pass it at runtime.
 
Hi,
I am talking about the usercode/password to access the report's data, not the CMS itself.

For the code you gave, I don't know what to make of the ID, CE does not seem to have those.

For example -
My link looks like :
but the report has a parameter so you get a prompt saying <Enter your User ID and password for the database>.

If I enter them manually, it could look something like :

That is what I want to avoid, I cannot show my database logon information within the URL. The information is not saved with the report in this case as they want to run it every time it is accessed to get the latest data available.

Let me know if what I am saying is unclear.

Thank you,
Phil
 
I think I see now, you're running the reports in "unmanaged" mode, which requires the login info to be passed in the url, yes this is bad. Also v10 and above do not officially support that mode anymore. We used to do this too, we had to go to a "managed" scenario, which is far superior and does not expose the login info, you set it in the managed system when you "publish" the report. I strongly recommend you switch to this mode, it is a bit of work but very well worth it. You have to write an asp that gets the report id, etc, from the cms db, and you call all your reports through this, you pass it the report name and other parameters, but not the login info. The code is freely available on the BO site and elsewhere (here somewhere I'm sure), or if you wish I can post mine here for you, just let me know. Of course I could have misread your entire problem too, in which case ignore this.
 
You have it dead on hejamana. Actually, I ended up using a different ODBC once I was given an account with read only admin access to allow me to see the tables. We can tolerate this one being shown online.

Still though, I would like to see your code if you don't mind. The BO site has a set of asp code, but it's quite a few years old and probably no longer even supported.

Thank you,
Phil
 
Here it is, in asp.net/vb.net, if you're using classic asp just copy and paste the relevant bits and modify slightly to vbscript. Now bear in mind you will have to publish your reports using the publishing wizard that came with your enterprise installation for this to work, it will assign them an id, you then call this asp and pass it the report name (url querystring: &rpt=reportname), it queries the cms to get the id and then invokes the viewer (we use java, you can change this to actx if you like). When you publish them, choose "modify properties" and give them the login info at that time, so it has it when you run it, you can also do this later in the management admin tool. Also you will have to change my version 11 object names to your version 10, these are registered COM objects.
Some of the lines wrapped here btw, sorry.
Good luck.

Dim svr As String = System.Environment.MachineName
Dim qs As String = "&" & context.Request.QueryString.tostring
Dim rpt = Context.Request("rpt")
Dim cmd = Context.Request("cmd")
Dim cesm = CreateObject("CrystalEnterprise11.SessionMgr.1")
Dim ces = cesm.Logon("administrator", "adminpassword", svr, "secEnterprise")
Dim ceis = ces.Service("", "InfoStore")
Dim cetokmgr = ces.LogonTokenMgr
Dim cetok = cetokmgr.CreateLogonTokenEx("", 2, 100)
Dim sSQL As String = "Select SI_ID From CI_INFOOBJECTS Where SI_PROGID = 'CrystalEnterprise.Report' AND SI_INSTANCE = 0 AND SI_NAME = '" & rpt & "'"
Dim rID As Integer

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ceio = ceis.Query(sSQL)
Dim init As String = ""
If ceio.count > 0 Then
rID = ceio.item(1).ID
Else
Response.Write("Report " & rpt & " not found")
Exit Sub
End If
If cmd = "" Then init = "&init=java_plugin:connect"
Response.Redirect("/crystalreportviewers11/viewrpt.aspx?id=" & rID & _
"&apstoken=" & cetok & qs & init)
End Sub

Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
cetok = Nothing
cetokmgr = Nothing
ceis = Nothing
ces = Nothing
cesm = Nothing
End Sub
 
Thank you very much for the code.

I will look into it and see what I can do.

Phil
 
Hi,
Here is a 'plain' asp page ( save it as somename.asp in a virtual web directory - substitute your authentication info where needed:
Code:
<%
    CMS = "<YOURCESERVER>"
Username = "<USERNAME- NEEDS VIEW ON DEMAND RIGHTS>"
Password = "THAT USER'S PASSWORD"
Authtype = "secEnterprise"
    rpt = Request.QueryString("rpt")
    cmd = Request.QueryString("cmd")
    Set cesm = Server.CreateObject("CrystalEnterprise.SessionMgr")
     Set ces = cesm.Logon(Username, Password, CMS, Authtype)
     Set ceis = ces.Service("","InfoStore")
    
     Set cetokmgr = ces.LogonTokenMgr
     cetok = cetokmgr.CreateLogonTokenEx("", 2, 100)
     sSQL  = "Select SI_ID From CI_INFOOBJECTS Where SI_PROGID = 'CrystalEnterprise.Report' AND SI_INSTANCE = 0 AND SI_NAME = '" & rpt & "'"
    Set  ceio = ceis.Query(sSQL)
    rID = ceio.Item(1).ID
     init  = ""
        If cmd = "" Then 
       	init = "&init=" 
        else
       	init = "&init=" & cmd
        end if        Response.Redirect("/crystalreportviewers115/viewrpt.aspx?id=" & rID & _
        "&apstoken=" & cetok & init)
        cetok = Nothing
        cetokmgr = Nothing
        ceis = Nothing
        ces = Nothing
        cesm = Nothing
      %>

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top