0
我想爲我的VirtualDirectory設置憑據。我以前創建的用戶和我所做的是:如何設置VirtualDirectory憑據
DirectoryEntry site = new DirectoryEntry"IIS://localhost/W3SVC/1/Root");
string className = site.SchemaClassName.ToString();
if ((className.EndsWith("Server")) || (className.EndsWith("VirtualDir")))
{
DirectoryEntries vdirs = site.Children;
DirectoryEntry existingDirectoryEntry = vdirs.OfType<DirectoryEntry>().SingleOrDefault(d => d.Name == name);
if (existingDirectoryEntry != null)
throw new Exception("The virtual directory you want to create already exists");
DirectoryEntry newVDir = vdirs.Add(name, (className.Replace("Service", "VirtualDir")));
newVDir.Username = username;
newVDir.Password = password;
newVDir.Properties["Path"][0] = path;
newVDir.Properties["AccessScript"][0] = true;
if (authFlags.HasValue)
newVDir.Properties["AuthFlags"].Value = authFlags.Value;
newVDir.CommitChanges();
}
未設置用戶名和密碼目錄已正確創建。當我設置用戶名和密碼時,我收到系統找不到指定路徑的消息,但存在路徑。也許我應該改變某種身份驗證類型?