简体   繁体   English

如何在C#中使用DirectoryEntry删除IIS 6 Web目录属性

[英]How to remove IIS 6 web directory property using directoryentry in C#

I want to delete a particular property of IIS when directory from Metabase. 我想从Metabase目录中删除IIS的特定属性。 Can anyone please help me? 谁能帮帮我吗? How can we do that with DirectoryEntry class in C#? 如何使用C#中的DirectoryEntry类做到这一点?

Use following code sample from MSDN 使用来自MSDN的以下代码示例

using System;
using System.DirectoryServices; 

class MyClass1
{
   static void Main()
   {
      try
      {
         String strPath = "IIS://localhost/W3SVC/1/Root";
         String strName = "";

         // Create a new 'DirectoryEntry' with the given path.
         DirectoryEntry myDE = new DirectoryEntry(strPath);
         DirectoryEntries myEntries = myDE.Children;

         // Create a new entry 'Sample' in the container.
         DirectoryEntry myDirectoryEntry = 
            myEntries.Add("Sample", myDE.SchemaClassName);
         // Save changes of entry in the 'Active Directory'.
         myDirectoryEntry.CommitChanges();
         Console.WriteLine (myDirectoryEntry.Name + 
            " entry is created in container.");

         // Find 'Sample' entry in container.
         myDirectoryEntry = myEntries.Find("Sample", myDE.SchemaClassName);
         Console.WriteLine(myDirectoryEntry.Name + " found in container.");
         // Remove 'Sample' entry from container.
         strName = myDirectoryEntry.Name;
         myEntries.Remove(myDirectoryEntry);
         Console.WriteLine(strName+ " entry is removed from container.");

      }
      catch(Exception e)
      {
         Console.WriteLine("The following exception was raised : {0}",
            e.Message);
      }
   }
}

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

相关问题 当您使用DirectoryEntry对象设置Web目录属性“ AuthNTLM”时,实际上要更改哪些IIS设置? - When you set a web directory property “AuthNTLM” using the DirectoryEntry object, what IIS setting are you actually changing? C#:如何使用DirectoryContext,Domains和DirectoryEntry类在启用SSL的情况下连接到Active Directory? - C#: How to Connect to Active Directory with SSL Enabled using DirectoryContext, Domains and DirectoryEntry classes? C#:无法使用DirectoryEntry获取所有属性名称 - C#: Unable to get all property names using DirectoryEntry DirectoryServices DirectoryEntry获取pwdLastSet属性C# - DirectoryServices DirectoryEntry get pwdLastSet property c# 如何使用C#代码在IIS 7中删除或更新虚拟目录 - How to remove or update virtual directory in IIS 7 with C# code 如何使用DirectoryEntry更新Active Directory中的数据? - How to update data in Active Directory using DirectoryEntry? C#DirectoryEntry错误? - C# DirectoryEntry Error? 如何使用C#在IIS Express中创建虚拟目录 - How to create a virtual directory in IIS Express using C# 在 Active Directory C# 中创建用户的 PrincipalContext 或 DirectoryEntry 哪个更好 - Which is better PrincipalContext or DirectoryEntry for user creation in Active Directory C# 检查DirectoryEntry是否是Active Directory C#中组的最后一个 - Check if a DirectoryEntry is the last of a Group in Active Directory C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM