[英]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 Code
和Classic
管道模式。 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.