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();
}
未设置用户名和密码目录已正确创建。当我设置用户名和密码时,我收到系统找不到指定路径的消息,但存在路径。也许我应该改变某种身份验证类型?