有没有办法以编程方式获取默认FTP站点(在IIS中)的本地路径?
如C:\program files\ftproot,如下所示:

我想应该是这样的:
DirectoryEntry ftproot = new DirectoryEntry("IIS://localhost/MSFTPSVC/1/Root");
string directory; // = ftproot.something有什么想法吗?
编辑:这是针对IIS 6.0的。当然,这必须存储在某个地方--也许是在注册表中?
发布于 2010-01-06 14:12:39
至少对于IIS 6,我在注册表中找到了它:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MSFtpsvc\Parameters\Virtual根目录\
数据的格式有点奇怪-例如,D:\ftproot,,1

发布于 2010-01-06 14:13:30
据我所知,有两个Active Directory属性: msIIS-FTPRoot和msIIS-FTPDir。
来自Technet
基本上,用户的主文件夹是通过查询Active Directory中用户对象的msIIS-FTPRoot和msIIS-FTPDir属性在身份验证时确定的。msIIS-FTPRoot和msIIS-FTPDir值的串联将生成用户主文件夹的路径。
示例如下所示:
msIIS-FTPRoot = D:\FTP Users
msIIS-FTPDir = \JohnSmith这将导致"D:\FTP Users\JohnSmith“作为用户的主文件夹。
遍历所有用户和默认目录的代码:
static void Main(string[] args)
{
string domain = Environment.GetEnvironmentVariable("USERDNSDOMAIN");
string dc = GetDC(domain);
string ldap = String.Format("LDAP://{0}/{1}", domain, dc);
DirectoryEntry e = new DirectoryEntry(ldap);
DirectorySearcher src = new DirectorySearcher(e, "(objectClass=user)");
SearchResultCollection res = src.FindAll();
foreach (SearchResult r in res)
{
DirectoryEntry f = r.GetDirectoryEntry();
Console.WriteLine(f.Name + "\t" + f.Properties["msIIS-FTPRoot"].Value + f.Properties["msIIS-FTPDir"].Value);
}
Console.ReadKey();
}
private static string GetDC(string domain)
{
StringBuilder sb = new StringBuilder(domain);
sb.Replace(".", ",DC=");
sb.Insert(0, "DC=");
return sb.ToString();
}https://stackoverflow.com/questions/2011095
复制相似问题