Solved

How to set Crystal Report Default connection to Integerated Security

Posted on 2012-04-10
7
1,542 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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