简体   繁体   English

IIS7.5应用程序池,进程标识和环境

[英]IIS7.5 Application Pool, process identity and environment

I have web application that have to access local resources, files/folders, to be able to do git clone/pull/push. 我有必须访问本地资源,文件/文件夹的Web应用程序,才能执行git clone / pull / push。 I've created a separate Application Pool with Process Identity == my own account (Administrator of machine). 我用自己的帐户(计算机管理员)创建了一个单独的带有“进程标识==”的应用程序池。

But, if I do: 但是,如果我这样做:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

The return value: 返回值:

"C:\\Windows\\system32\\config\\systemprofile\\AppData\\Local"

so, it looks like system profile is still used. 因此,看起来系统配置文件仍在使用。 git clone and other git operations hangs up, seems like fail to find .ssh keys etc. git clone和其他git操作挂断,似乎找不到.ssh密钥等。

The interesting thing, that it worked fine before Windows SP1 update (at least I blame update, since nothing more changed on machine). 有趣的是,它在Windows SP1更新之前运行良好(至少我归咎于更新,因为计算机上没有其他更改)。

If already not having it, try setting: 如果还没有,请尝试设置:

<identity impersonate="false"/>

in web.config 在web.config中

EDIT 编辑

I was wrong, you need to have your app pool identity with access to local folder here: 我错了,您需要具有可在此处访问本地文件夹的应用程序池标识:

System.Security.Principal.WindowsIdentity.GetCurrent()

EDIT 2 编辑2

I have found solution. 我找到了解决方案。 To run application AS you, you need to turn on impersonation after all (app pool setting does not apply on my IIS7.5), but AS A SPECIFIC USER. 若要按您的身份运行应用程序,您毕竟需要打开模拟功能(应用程序池设置不适用于我的IIS7.5),但需要作为特定用户使用。 So, to enable this, you need to turn impersonation on in web.config AND specify user: 因此,要启用此功能,您需要在web.config中打开模拟并指定用户:

    <identity impersonate="true" password="o1j2813n" userName="obrad" />

You can also set this through inetmgr: 您也可以通过inetmgr进行设置: ASP.NET模拟设置屏幕截图

Either way, after setting this, 无论哪种方式,在设置此设置之后,

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

gives: 给出:

C:\Users\obrad\AppData\Local

Another update: 另一个更新:

I have been searching for a way to do the same without putting my password in web.config, and can confirm that I get local user folder also when basic impersonation is on 我一直在寻找一种无需将密码输入web.config即可执行相同操作的方法,并且可以在启用基本模拟功能时确认我也获得了本地用户文件夹

    <identity impersonate="true"/>

But under condition that application connects (under app settings -> Connect as...) as me: 但是在应用程序像我一样连接的情况下(在应用程序设置->连接为...):

应用程序设置屏幕截图

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

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