Quantcast
Viewing all articles
Browse latest Browse all 3636

Database Roles And Connections

I am using Visual Studio C# and a SQL Server database.  I am using database application roles for security.  I am trying to allow a user who is restricted to just viewing reports to run a dynamically created Crystal Report from a form.  The application at logon sets the database application role for the user.  The role has permission to execute a stored procedure and select on a table.  The problem is that when the user clicks on the menu item to run the report, I get an error when it tries to add a field to the report.  If I logon as myself, the report is produced.  My privileges on the database are owner of the database (schema).


I believe what is happening is that the Crystal Report makes a new connection to the database as the user logged on, which is different from the original database connection made through the logon form.  Since the user has only permission to connect, I set the database application role right after logon which allows that described in the first paragraph.  But when the report is selected from the menu, a new connection is made for the user.  Since the application role is not set for this connection, the report fails.  It seems to me that the solution would be for Crystal Reports to use the same connection that was established through the logon form.  I do not see how in the API how to do this.  The connection API looks for a server name, a database name, and a parameter which is set to true or false of which I don't recall what it is as I don't have the code in front of me at the moment.  I would prefer to use my SQL Connection which I established at logon but it is a SqlConnection Class.  I don't see a way to do this.


If this is not possible, is there a way to execute the sp_setapprole procedure from within Crystal Reports?


Any help is appreciated.  You can reference my code here:


Dynamic Report Creation At Runtime


http://scn.sap.com/thread/3699339


Martin


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>