简体   繁体   English

如何在dotnet core 1.1中使用模拟功能?

[英]How do I use impersonation in dotnet core 1.1?

I am trying to authenticate my MSSQL connection with Trusted_Connection=True. 我正在尝试使用Trusted_Connection = True验证我的MSSQL连接。 In order to get that working, I installed NuGet package Impersonate.AspNetCore.Windows (Impersonate) , and set it up in my Startup.cs, like so: 为了使它正常工作,我安装了NuGet包Impersonate.AspNetCore.Windows (Impersonate) ,并在Startup.cs中对其进行设置,如下所示:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseWindowsImpersonation(options => {
        options.Enabled = true;
    });
}

In my Program.cs I added UseIISIntegration to setup .net core to be hosted in IIS: 在我的Program.cs中,我添加了UseIISIntegration来设置要托管在IIS中的.net核心:

public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }

In IIS I created a new Website, changed the ApplicationPool Basic Settings to No managed Code and Classic pipeline mode. 在IIS中,我创建了一个新网站,将ApplicationPool基本设置更改为No managed CodeClassic管道模式。 In the Advanced Settings I set the Identity under Process Model to an existing Windows User account: 在“高级设置”中,我将“流程模型”下的“ Identity ”设置为现有的Windows用户帐户:

高级应用程序池设置

When I use Trusted_Connection=True in my connection string, the application fails to authenticate my connection to the SQL server: 当我在连接字符串中使用Trusted_Connection=True时,应用程序无法验证我与SQL Server的连接:

"ConnectionStrings": {
    "DashboardDatabase": "Server=<SOME_SERVER>;Database=<SOME_DATABASE>;Trusted_Connection=True"
}

(where and are replaced by the actual names of the server and database, of course). (当然,其中和被服务器和数据库的实际名称代替)。

My question is: Am I forgetting something here? 我的问题是:我在这里忘记了什么吗?

I had exactly the same setup as you and I got it working. 我的设置与您完全相同,并且可以正常使用。 Did you add forwardWindowsAuthToken="true" to your web.config file? 您是否将forwardWindowsAuthToken="true"添加到您的web.config文件中? You might have to create the web.config file in the root folder of your application if you haven't yet. 如果尚未安装,则可能需要在应用程序的根文件夹中创建web.config文件。 See the package repo 查看包装回购

FYI I also have Integrated Security=true; 仅供参考,我也有Integrated Security=true; in my connection string, not sure if that is needed. 在我的连接字符串中,不确定是否需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 c#7元组。 无法在mac dotnet核心1.1中使用元组 - c# 7 tuples . not able to use tuples in mac dotnet core 1.1 如何在 dotnet cli 中使用“-optimize”? - How do I use “-optimize” with dotnet cli? 如何在 dotnet core 中使用 HttpClient 进行补丁请求? - How do I do a patch request using HttpClient in dotnet core? 如何在 .net Core 1.1 中使用 MySQL - How can I use MySQL in .net Core 1.1 如何操作dotnet核心中的控制台光标位置? - How do I manipulate console cursor position in dotnet core? 我可以使用csc.exe将一个cs文件编译成.net框架中的dll ...但是我如何通过dotnet cli在dotnet核心中执行此操作? - I can use csc.exe to compile one cs file to a dll in .net framework…but how can i do this in dotnet core by dotnet cli? 在.NET 1.1中,如何将用户凭据从一个进程传递到另一个进程以进行模拟? - How do you pass user credentials from one process to another for Impersonation in .NET 1.1? 如何使用Entity Framework Core模拟SQL Server? - How to do SQL Server impersonation with Entity Framework Core? 如何在C#Winforms应用程序上使用模拟以管理员权限运行? - How do I use impersonation on a C# Winforms application to run with admin privileges? 如何使用dotnet core 3内在StoreAlignedNonTemporal - How to use dotnet core 3 intrinsic StoreAlignedNonTemporal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM