简体   繁体   English

在ASP.Net中临时模拟Windows身份验证的用户

[英]Temporarily impersonate the Windows authenticated user in ASP.Net

I'm just reading about temporarily impersonating a user in ASP.Net 我只是在阅读有关在ASP.Net中临时模拟用户的信息

at http://msdn.microsoft.com/en-us/library/ff647405.aspx http://msdn.microsoft.com/en-us/library/ff647405.aspx

To achieve this the following code is used. 为此,使用以下代码。

// Temporarily impersonate the original user. //临时模拟原始用户。

WindowsImpersonationContext wic = wi.Impersonate();
try
{
  // Access resources while impersonating.
}
catch
{
  // Prevent exceptions propagating.
}
finally
{
  // Revert impersonation.
  wic.Undo();
}

I am using Windows Server 2008 and have an application pool and just wanted to cofirm that when I am not impersonating by using the above code by default the service will then use the identity of my what I have set for my application pool. 我正在使用Windows Server 2008,并且有一个应用程序池,只是想确认一下,当我默认不使用上述代码进行模拟时,该服务将使用我为应用程序池设置的身份。

Issue is I want a different security access to resources depending on if the user logged in via windows application or used ASP.Net forms authentication Thanks 问题是,我希望对资源进行不同的安全访问,具体取决于用户是否通过Windows应用程序登录或使用过ASP.Net表单身份验证。谢谢

That is by what I know correct. 据我所知,这是正确的。 If you do not impersonate as the calling user, by default it should run under the default identity from the application pool. 如果您不冒充主叫用户,则默认情况下,它应以应用程序池中的默认身份运行。

=============================================================================== ================================================== =============================

Below are some good links you can go through these to understand the iis user 以下是一些不错的链接,您可以通过这些链接来了解iis用户

In summary: 综上所述:

  • IIS 5.1 (Windows XP) - it's a local ASPNET account IIS 5.1(Windows XP)-这是本地ASPNET帐户
  • IIS 6 - by default, application pools run under the Network Service account which is a member of IIS_WPG group IIS 6-默认情况下,应用程序池在网络服务帐户下运行,该帐户是IIS_WPG组的成员
  • IIS 7.0 - still Network Service IIS 7.0-静止网络服务
  • IIS 7 SP2 / 7.5 - runs under an ephemeral thing called ApplicationPoolIdentity which maps to an account IIS APPPOOL\\ApplicationPool (eg IIS APPPOOL\\DefaultAppPool). IIS 7 SP2 / 7.5-在名为ApplicationPoolIdentity的临时名称下运行,该名称映射到帐户IIS APPPOOL \\ ApplicationPool(例如IIS APPPOOL \\ DefaultAppPool)。 This account is a member of IIS_IUSRS user group 该帐户是IIS_IUSRS用户组的成员

Infomation source:- 信息来源:

User ASP.NET runs under What are all the user accounts for IIS/ASP.NET and how do they differ? 用户ASP.NET在IIS / ASP.NET的所有用户帐户下运行,它们有何不同?

http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount

http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis

http://imar.spaanjaars.com/287/how-do-i-determine-the-security-account-that-iis-uses-to-run-my-web-site http://imar.spaanjaars.com/287/how-do-i-determine-the-security-account-that-iis-uses-to-run-my-web-site

Source: Shekhar - In which Account By Default ASP.NET 4.0 Code Execute? 来源:Shekhar- 默认情况下在哪个帐户中执行ASP.NET 4.0代码?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM