简体   繁体   English

是否有可能以编程方式管理IIS7中FTP服务器的状态?

[英]Is it actually possible to programmatically manage the state of an FTP server in IIS7?

I'm able to manage FTP sites via the IIS manager, however, all attempts so far to manage the state of FTP sites using other means have failed, including: 我能够通过IIS管理器管理FTP站点,但到目前为止,使用其他方法管理FTP站点状态的所有尝试都失败了,包括:

  1. Using the IIS7 API ( Microsoft.Web.Administration ) 使用IIS7 API( Microsoft.Web.Administration
  2. Using WMI (with IIS6 compatibility enabled) 使用WMI(启用IIS6兼容性)
  3. Using the AppCmd tool in System32\\inetsrv 使用System32 \\ inetsrv中的AppCmd工具

Related questions: 相关问题:

Are there any workarounds I haven't tried? 有没有我没试过的变通方法? My objective is to manage (start/stop/query the state of) the FTP sites with C# code (as you can see from the 3 above attempted workarounds). 我的目标是使用C#代码管理(启动/停止/查询状态)FTP站点(从上面的3个尝试的解决方法中可以看到)。

When querying the FTP server state using WMI, it returns code 4, which means "Stopped", even though the site is definitely shown as running in IIS manager. 当使用WMI查询FTP服务器状态时,它返回代码4,这意味着“已停止”,即使该站点肯定显示为在IIS管理器中运行。

AppCmd is useless, as it returns "Unknown" for FTP sites: AppCmd没用,因为它为FTP站点返回“Unknown”:

c:\Windows\System32\inetsrv>appcmd list site
SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Stopped)
SITE "Default FTP Site" (id:2,bindings:ftp/*:21:,state:Unknown)

My workaround for managing the state is to set ServerAutoStart to false, and restart the ftpsvc Windows service. 我管理状态的解决方法是将ServerAutoStart设置为false,然后重新启动ftpsvc Windows服务。 Thus far I have not found a way of detecting the state of a specific FTP server (IIS can have multiple FTP servers with different bindings). 到目前为止,我还没有找到一种检测特定FTP服务器状态的方法(IIS可以有多个具有不同绑定的FTP服务器)。

To determine the state, you could just make a connection attempt. 确定状态,您可以尝试连接。

To manage the state, I don't have any suggestions, I would've put my chips on WMI. 为了管理状态,我没有任何建议,我会把我的芯片放在WMI上。

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

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