简体   繁体   English

c#冒充问题

[英]c# impersonation problem

I have a method that runs executes a batch file.我有一个运行批处理文件的方法。 This worked until I implemented the IIS7 integrated pipeline authentication, restricting access to any static files hosted in my app.这一直有效,直到我实现了 IIS7 集成管道身份验证,限制了对托管在我的应用程序中的任何 static 文件的访问。

I have since found out that adding this change, that the process tries to execute through the NETWORK SERVICE account instead of my impersonation token in my web.config.从那以后,我发现添加此更改,该过程尝试通过网络服务帐户而不是我的 web.config 中的模拟令牌执行。

Is there any reason for this or a way for me to force the method to use the impersonated user?有什么理由或者我可以强制该方法使用模拟用户吗?

EDIT编辑

Of course now Ive implemenet the integrated pipeline, the application sees the batch file as a static file and was trying to access it via the annoymous user account, which was set to application pool identity, which in turn is using NETWORK SERVICE account.当然,现在我已经实现了集成管道,应用程序将批处理文件视为 static 文件,并试图通过设置为应用程序池身份的匿名用户帐户访问它,而该用户帐户又使用 NETWORK SERVICE 帐户。

the files were situated in a separate class library directory on the hard drive and not hosted through the application.这些文件位于硬盘驱动器上单独的 class 库目录中,而不是通过应用程序托管。 I have tried to rectify this by adding them to a folder in my application, hoping that now integrated pipeline would see that the user is authenticated and allow access.我试图通过将它们添加到我的应用程序中的文件夹来纠正这个问题,希望现在集成的管道会看到用户已通过身份验证并允许访问。 This is not the case, the batch files are still executed using the annoymous authentication account.情况并非如此,批处理文件仍然使用匿名身份验证帐户执行。 :( :(

Thanks!谢谢!

If anyone gets here then I would suggest heading to this site如果有人到这里,那么我建议前往这个网站

http://blogs.msdn.com/b/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx http://blogs.msdn.com/b/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx

I found that the createprocessasuser method works a treat.我发现 createprocessasuser 方法很有效。 But now Im struggling with pipes to get the standard output from said method.但现在我正在努力用管道从上述方法中获得标准的 output。 Im using this post to help with this,我使用这篇文章来帮助解决这个问题,

How to get standard output from CreateProcessWithLogonW? 如何从 CreateProcessWithLogonW 获取标准 output?

hope this helps!希望这可以帮助!

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

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