加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

.net – 使用impersonate = true时如何在IIS中获取当前应用程序

发布时间:2020-12-13 22:44:12 所属栏目:Windows 来源:网络整理
导读:在.net中托管的网站如何获得网站运行的当前用户.即,应用程序池用户不是访问该站点的当前用户. 使用Windows集成和模拟. authentication mode="Windows"/identity impersonate="true"/ 要在托管代码中恢复为应用池用户,您可以执行以下操作: using (WindowsIde
在.net中托管的网站如何获得网站运行的当前用户.即,应用程序池用户不是访问该站点的当前用户.

使用Windows集成和模拟.

<authentication mode="Windows"/>
<identity impersonate="true"/>
要在托管代码中恢复为应用池用户,您可以执行以下操作:
using (WindowsIdentity.Impersonate(IntPtr.Zero)) 
{
   //This code executes under app pool user
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读