English 中文(简体)
IIS 应用程序库
原标题:IIS Application Pool Recycle

I have to recycle IIS (version 7.5) application pool programatically using c#. When I try to get ApplicationPoolCollection using "ServerManager" class UnauthorizedAccessException raised. I guess I have to use impersonation. But I don t know to use impersonation. And is there anyway to use impersonation with attribute instead of web.config?

问题回答

为了在信息管理系统中开展任何行政行动,如回收应用池、开始和停止网站、建立网站等等,你需要担任管理者。

如果你想在方案上冒用用户,那么你需要使用、Windows Identity.Iate 方法。

There s a reasonably good snippet of sample code there to get you started.

当然,在您的<代码>web.config文档(或硬编码)中存储高度特权用户的证书时,所有通常的卡韦特都在此适用。

Also if you re trying to debug code that accesses IIS programmatically using the managed ServerManager API then make sure you start Visual Studio by doing "Run As Administrator". You need to do this even if your own Windows account is a member of the Administrators group.





相关问题
Validate NT User via SQL CLR

I need to be able to validate a given username and password against Active Directory and return whether that user exists. My setup is that I have two web servers in a DMZ, and then a SQL Server in ...

Impersonating user with Entity Framework

So we have our web app up and going with entity framework. What we d like to do is impersonate the current user when we re accessing the DB. We re not interested in setting impersonation up in our ...

Why is a published website referencing my machine?

I have a website that I publish in Visual Studio 2008 and then send off to other people. One of the pages needs to alter a few configuration files, so an action is executed using ...

热门标签