Solved

How to set Crystal Report Default connection to Integerated Security

Posted on 2012-04-10
7
1,567 Views
Last Modified: 2012-04-28
How to set Crystal Report Default connection to Integerated Security as a default connection so it never asks for the Username and password and instead uses the login. I am using crystal report for VS2010.

Paul
0
Comment
Question by:pauledwardian
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 37830798
I *think* you are talking about 2 different things.

It is better, I think, to let your Crystal Reports connection to sql server using SQL Server authentication mode.

This method is completely different from giving users access to crystal reports.

In your asp code, you can use windows integrated security mode to allow users access to the report.

So, in a nutshel, use Crystal Reports connection method to connect to sql server database.

Then use Windows Security to give users access to the report.

I hope this is clear. If not, let us know.
0
 
LVL 9

Assisted Solution

by:sevensnake77
sevensnake77 earned 500 total points
ID: 37830856
try this sample

  Dim rpt As New AccountingPassdue
        Dim myConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(HttpContext.Current.Application.Get("connectionstring"))

        Dim MyCommand As New SqlCommand("storedprocedure here", myConnection)
        Dim myDA As New SqlDataAdapter
        Dim myDS As New ConsolidatedStatement 'Dataset created
        '   Dim UserId As String
        Try
            'MyCommand.Connection = myConnection
            MyCommand.CommandText = "storedprocedure here" 'Stored Procedure
            MyCommand.CommandType = CommandType.StoredProcedure
            MyCommand.Parameters.Add(New SqlParameter("@Customer", SqlDbType.Char, (6))).Value =
 



            myDA.SelectCommand = MyCommand
            myDA.Fill(myDS, "spA1SAccountReview")
            rpt.SetDataSource(myDS)
            rpt.DataDefinition.SortFields(0).SortDirection = CrystalDecisions.Shared.SortDirection.AscendingOrder

            myConnection.Open()
            CrystalReportViewer7.ReportSource = rpt ' Connects to viewer using rpt
         
        Catch Excep As Exception
            'With Label2
            '    Label2.Visible = True
            '    .CssClass = "labelRed"
            '    .Text = Err.Description ""
            'End With

        End Try


        Dim oStream As MemoryStream
        ' using System.IO
        '  rpt.DataDefinition.SortFields("Billed").SortDirection = CrystalDecisions.Shared.SortDirection.AscendingOrder

        oStream = DirectCast(rpt.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat), MemoryStream)
        Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/pdf"
        Response.BinaryWrite(oStream.ToArray())
        Response.[End]()
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37830938
How did you set up the database connection for the report?

Is the SQL server setup for integrated security?

mlmcc
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:pauledwardian
ID: 37831030
I added a group as the authorized user to have read and write access to the database. And added specific user to that group in the AD.
SO, HOW can I approach this then?
If you like to provide the code, PLEASE only C# since I have no idea about VB.NET.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37831069
You set report security when you create the connection to the report.

mlmcc
0
 
LVL 9

Accepted Solution

by:
sevensnake77 earned 500 total points
ID: 37832593
ConsolidatedPaidadj rpt = new ConsolidatedPaidadj();
SqlClient.SqlConnection myConnection = new SqlClient.SqlConnection(HttpContext.Current.Application.Get("ConnString"));

SqlCommand MyCommand = new SqlCommand("storedprocedure", myConnection);
SqlDataAdapter myDA = new SqlDataAdapter();
ConsolidatedStatement myDS = new ConsolidatedStatement();
//Dataset created
//   Dim UserId As String
try {
      //MyCommand.Connection = myConnection
      MyCommand.CommandText = "spA1SGetConsolidatedPaid";
      //Stored Procedure
      MyCommand.CommandType = CommandType.StoredProcedure;
      MyCommand.Parameters.Add(new SqlParameter("@parameter", SqlDbType.Char, (6))).Value = yourvalue;
      
      myDA.SelectCommand = MyCommand;
      myDA.Fill(myDS, "spA1SGetConsolidatedPaid");
      rpt.SetDataSource(myDS);
      myConnection.Open();
      CrystalReportViewer7.ReportSource = rpt;
      // Connects to viewer using rpt
}

catch (Exception Excep) {
      {
            Label2.Visible = true;
            Label2.CssClass = "labelRed";
            Label2.Text = Err.Description;
            
      }

}
0
 

Author Closing Comment

by:pauledwardian
ID: 37906899
Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question