error while running from a network machine
-
Hi all, I have installed my program on my network machine (EXE and the DB) I have set the sharing & Security for the folder of the network machine When I try to run the program from my machine I get the following error: Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version= 1.0.5000.0, Culture =neutral, PublicKey Token = b77a5c561934e089 failed It runs fine from the network machine i.e. If run it from the NETWORK machine. This is the code for me to open my conection: Imports System.Data.SqlClient .... Dim Conn As SqlConnection = New SqlConnection Conn.ConnectionString = "Data Source=(local);" & _ "Initial Catalog=Rsch1;" & _ "Integrated Security=SSPI" Conn.Open() How do I set the permision for the network machine? Tnx
-
Hi all, I have installed my program on my network machine (EXE and the DB) I have set the sharing & Security for the folder of the network machine When I try to run the program from my machine I get the following error: Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version= 1.0.5000.0, Culture =neutral, PublicKey Token = b77a5c561934e089 failed It runs fine from the network machine i.e. If run it from the NETWORK machine. This is the code for me to open my conection: Imports System.Data.SqlClient .... Dim Conn As SqlConnection = New SqlConnection Conn.ConnectionString = "Data Source=(local);" & _ "Initial Catalog=Rsch1;" & _ "Integrated Security=SSPI" Conn.Open() How do I set the permision for the network machine? Tnx
Programs run from a network share run with a lower permission than applications run from the local machine. This is because the network share could be a WebDav drive out on the internet, etc. The first thing is, the connection string won't work from your machine. When your machine runs the code, it will see "Data Source=(local)," and it will attempt to attach to your machine and not the networked machine. Presumably, you want to run against the databse on the network machine. So your connection string needs to look like: Data Source=SERVER\.;Initial Catalog=Rsch1;Integrated Security=SSPI Additionally both your machine and the server must be members of mutually trusted domains, or SSPI will fail. If you are in a workgroup, you probably can't use integrated security (SSPI) reliably, but your milage may vary. Of course, in my version of the connect string, SERVER needs to be either the IP Address of your SQL Server or its machine name -- it shouldn't be the word SERVER unless that happens to be what its name is. Also, you need to make sure that SQL Server is configured to allow remote connections (Surface Area Manager in newer versions configures it for connections from the same machine only by default -- you can change this in your management tool). Additionally, when you are running from a network share, you lose permissions from the .NET framework. When you run from your local drive, you run at full trust. When you run from a network share, you don't run at full trust. This is a defense mechanism against Worm programs and other attacks. In control panel, you can use the .NET Configuration Assistance to trust the assembly or publisher. If you are on a corporate network, you want to have a domain administrator update the group policy to allow the executable the necessary permissions. If you are using .NET 2.0, the SDK provides a program that can tell you the exact permissions your application requires. The tool is named SecUtil, and it usually is in C:\Program Files\Microsoft.NET\SDK\v2.0\bin\secutil -- depending on your install order versus mine, it may be in a different location (I install the SDK, then install Visual Studio -- if you install the SDK as part of Visual Studio, then it ends up under Visual Studio somewhere). There is documentation on the tool on Microsoft's site. Note that you'll have to adjust the machine configuration or user configuration to trust the assembly -- there is nothing you can do on the network share to trust it. This is a defense mechanism. The best