Lack of access to external SQL database from CRM module during debugging

I am having problems accessing an external database from a CRM plugin. Received error:

"Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx' failed."

The code works fine locally inside the "unit test". I tried to set the plugin isolation mode to "none". I tried looking at the article for help and tried everything he suggested, no luck.

Here is the current code I'm using:

var conn = new SqlConnection(@"Server=MyServer\Instance;DataBase=MyDB;User Id=MyUser;Password=MyPassword;Integrated Security=false;");
conn.Open();

I also tried this connection string and granted NT AUTHORITY \ NETWORK SERVICE user access to the database.

var conn = new SqlConnection(@"Data Source=MyDS\Instance;Initial Catalog=MyDB;Integrated Security=SSPI;");
conn.Open();

I am in Dynamics CRM 2015 On-Premise.

: , , , , . , ?

+4
3

. CRM Online, Visual Studio. OnPremise , Visual Studio CRM. .

+2

SQL " ", , CRM .

CRM 2013 On-Premise, , - -, .

, DB2 :

  • , CRM
    • MyCompanyWebService
    • UpdateDB2 ( MyCompanyWebService)

, -, ( ) , -.

+3

, (Sandbox), SQL Server, SqlClient.

In Dynamics CRM 2015 On Premise, you do not need to run plugins in Sandbox if you do not want it. Sandboxing is a requirement only for Dynamics CRM.

Have you tried running outside Sandbox? Did you do iisreset after changing the plugin isolation, maybe?

Here is an article with more detailed information.

0
source

Source: https://habr.com/ru/post/1629424/


All Articles