当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryEntry.DeleteTree方法代码示例

本文整理汇总了C#中System.DirectoryServices.DirectoryEntry.DeleteTree方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.DeleteTree方法的具体用法?C# DirectoryEntry.DeleteTree怎么用?C# DirectoryEntry.DeleteTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DirectoryServices.DirectoryEntry的用法示例。


在下文中一共展示了DirectoryEntry.DeleteTree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

		public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
		{
			ADHelper adHelper = SynchronizeContext.Current.ADHelper;

			if (SynchronizeContext.Current.RecycleBinOU.IsNotEmpty())
			{
				ProcessDeleteEntry(modifyType, srcObject, targetObject, context);

				//ChangeEntryNameToFullPath(targetObject);

				using (DirectoryEntry parentEntry = adHelper.NewEntry(SynchronizeContext.Current.RecycleBinOU))
				{
					DoTheMove(targetObject, parentEntry, srcObject);
				}
			}
			else
			{
				targetObject.DeleteTree();
			}
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:20,代码来源:DeleteADObjectSetter.cs

示例2: DirectoryEntry_Properties2

		public void DirectoryEntry_Properties2()
		{
			// delete entry, create a new one (the same) and access properties of the old object
			string barakTsabariDN = configuration.ServerRoot + "cn=Barak Tsabari,ou=Human Resources,ou=people" + ((configuration.BaseDn.Length == 0) ? String.Empty : ("," + configuration.BaseDn));
			de = new DirectoryEntry(barakTsabariDN,
									configuration.Username,
									configuration.Password,
									configuration.AuthenticationType);

			// cause to properties loading
			Assert.AreEqual(de.Properties.Count,6);
			Assert.AreEqual(((PropertyValueCollection)de.Properties["sn"]).Value,"Tsabari");

			// delete entry
			de.DeleteTree();

			// the local property chache is still accessible
			Assert.AreEqual(de.Properties.Count,6);
			Assert.AreEqual(((PropertyValueCollection)de.Properties["sn"]).Value,"Tsabari");

			de.CommitChanges();

			// the local property chache is still accessible
			((PropertyValueCollection)de.Properties["sn"]).Value = "Barbari";

			// create the entry back again
			using (DirectoryEntry ouHumanResources = new DirectoryEntry(	configuration.ServerRoot + "ou=Human Resources,ou=people" + ((configuration.BaseDn.Length == 0) ? String.Empty : ("," + configuration.BaseDn)),
																	configuration.Username,
																	configuration.Password,
																	configuration.AuthenticationType)){
			using (DirectoryEntry cnBarakTsabari = ouHumanResources.Children.Add("cn=Barak Tsabari","Class")){
			((PropertyValueCollection)cnBarakTsabari.Properties["objectClass"]).Add("person");
			((PropertyValueCollection)cnBarakTsabari.Properties["objectClass"]).Add("organizationalPerson");
			cnBarakTsabari.Properties["cn"].Value = "Barak Tsabari";
			cnBarakTsabari.Properties["facsimileTelephoneNumber"].Value = "+1 906 777 8853";
			((PropertyValueCollection)cnBarakTsabari.Properties["ou"]).Add("Human Resources");
			((PropertyValueCollection)cnBarakTsabari.Properties["ou"]).Add("People");
			cnBarakTsabari.Properties["sn"].Value = "Tsabari";
			cnBarakTsabari.Properties["telephoneNumber"].Value = "+1 906 777 8854";
			cnBarakTsabari.CommitChanges();
			}
			}
			
			// the local property chache is still accessible
			Assert.AreEqual(((PropertyValueCollection)de.Properties["sn"]).Value,"Barbari");

			// Refresh from server
			de.RefreshCache();
			// ensure the properties of an entry are still accessible through the old object
			Assert.AreEqual(((PropertyValueCollection)de.Properties["sn"]).Value,"Tsabari");

		}
开发者ID:Profit0004,项目名称:mono,代码行数:52,代码来源:DirectoryServicesDirectoryEntryTest.cs

示例3: DirectoryEntry_Properties1

		public void DirectoryEntry_Properties1()
		{
			de = new DirectoryEntry(configuration.ConnectionString);

			Assert.AreEqual(de.Properties.Count,3);
			Assert.AreEqual(((PropertyValueCollection)de.Properties["dc"]).Value,"example");
			Assert.AreEqual(((PropertyValueCollection)de.Properties["description"]).Value,null);

			
			de = new DirectoryEntry(configuration.ConnectionString,
									configuration.Username,
									configuration.Password,
									configuration.AuthenticationType);

			Assert.AreEqual(de.Properties.Count,3);
			Assert.AreEqual(((PropertyValueCollection)de.Properties["dc"]).Value,"example");
			Assert.AreEqual(((PropertyValueCollection)de.Properties["description"]).Value,null);

			// ensure that properties are not accessible after removing an entry from the server
			string barakTsabariDN = configuration.ServerRoot + "cn=Barak Tsabari,ou=Human Resources,ou=people" + ((configuration.BaseDn.Length == 0) ? String.Empty : ("," + configuration.BaseDn));
			de = new DirectoryEntry(barakTsabariDN,
									configuration.Username,
									configuration.Password,
									configuration.AuthenticationType);
			
			de.DeleteTree();
			
			try {
				int i = de.Properties.Count;
				Assert.Fail("Properties should not be accessible after deleting an entry from the server");
			}
			catch(AssertionException ae) {
				throw ae;
			}
			catch(Exception e) {
				// supress exception
			}

			try {
				string s = (string)((PropertyValueCollection)de.Properties["dc"]).Value;
				Assert.Fail("Properties should not be accessible after deleting an entry from the server");
			}
			catch(AssertionException ae) {
				throw ae;
			}
			catch(Exception e) {
				// supress exception
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:49,代码来源:DirectoryServicesDirectoryEntryTest.cs

示例4: DeleteSiteVirtual

 /// <summary>
 /// 删除网站或虚拟目录
 /// </summary>
 /// <param name="virPath">地址 1/root/bbsmax</param>
 /// <returns></returns>
 public static void DeleteSiteVirtual(string path)
 {
     DirectoryEntry deDir = new DirectoryEntry(path);
     try
     {
         deDir.DeleteTree();
     }
     catch (Exception ex)
     {
         throw new Exception("删除失败:" + ex.Message);
     }
     finally
     {
         deDir.Close();
     }
 }
开发者ID:huchao007,项目名称:bbsmax,代码行数:21,代码来源:IISManager.cs

示例5: DeleteOU

        /// <summary>
        /// 删除OU
        /// </summary>
        /// <param name="ouEntry"></param>
        /// <param name="newOUName"></param>
        /// <returns></returns>
        public static bool DeleteOU(DirectoryEntry ouEntry)
        {
            //try
            //{

            //DirectoryEntry OUParent = ouEntry.Parent;
            ouEntry.DeleteTree();
            //OUParent.Children.Remove(ouEntry);
            ouEntry.CommitChanges();
            //OUParent.CommitChanges();
            return true;
            //}
            //catch (Exception ex)
            //{
            //    LogFactory.ExceptionLog.Error(ex);
            //    return false;
            //}
        }
开发者ID:zidanfei,项目名称:Dot.Utility,代码行数:24,代码来源:ADHelper.cs

示例6: RemoveVirtualDirectory

        private void RemoveVirtualDirectory(ActionEntry entry)
        {
            string fullPath, parentDir, dirName;
            GetSelectedDirectoryPath( out fullPath, out parentDir, out dirName );

            entry.LogLine( "Removing directory entry '" + fullPath + "'" );
            using( var directoryEntry = new DirectoryEntry(fullPath) )
            {
                directoryEntry.DeleteTree();
            }
        }
开发者ID:alaincao,项目名称:CommonLibs,代码行数:11,代码来源:IISWebApplication.xaml.cs

示例7: DeleteOU

        /// <summary>
        /// Deletes an OU from Active Directory
        /// </summary>
        /// <param name="distinguishedName"></param>
        public void DeleteOU(string distinguishedName)
        {
            DirectoryEntry de = null;

            try
            {
                this.logger.Debug("Deleting organizational unit " + distinguishedName);

                de = new DirectoryEntry("LDAP://" + this.domainController + "/" + distinguishedName, this.username, this.password);
                de.DeleteTree();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (de != null)
                    de.Dispose();
            }
        }
开发者ID:blinds52,项目名称:CloudPanel,代码行数:25,代码来源:ADOrganizationalUnit.cs

示例8: DeleteTree_DFS

		private void DeleteTree_DFS(DirectoryEntry de)
		{
			foreach(DirectoryEntry child in de.Children) {
				DeleteTree_DFS(child);
			}
			de.DeleteTree();
			de.CommitChanges();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:DirectoryServicesDirectoryEntryTest.cs

示例9: DeleteOUAll

        /// <summary>
        /// Deletes the OU and everything in the OU.
        /// **** DESTRUCTIVE!!! ****
        /// </summary>
        /// <param name="distinguishedName"></param>
        public void DeleteOUAll(string distinguishedName)
        {
            DirectoryEntry de = null;

            try
            {
                de = new DirectoryEntry("LDAP://" + this.domainController + "/" + distinguishedName, this.username, this.password);
                
                // Delete the OU
                de.DeleteTree();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (de != null)
                    de.Dispose();
            }
        }
开发者ID:KnowMoreIT,项目名称:CloudPanel_3.0,代码行数:26,代码来源:ADOrgUnit.cs

示例10: DeleteEntry

 public void DeleteEntry(DirectoryEntry dirEntry)
 {
     dirEntry.DeleteTree();
     dirEntry.CommitChanges();
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:5,代码来源:AdHelper.cs

示例11: DeleteSite

 public static void DeleteSite(string serverName, int siteID)
 {
     DirectoryEntry site = new DirectoryEntry(string.Format(MetabaseSiteFormat, serverName, siteID.ToString()));
     site.DeleteTree();
     site.CommitChanges();
 }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:6,代码来源:IISHelper.cs

示例12: DetTree

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="path">对象路径</param>
        public static void DetTree(string path)
        {
            try
            {
                DirectoryEntry ent = new DirectoryEntry(path, ADUser, ADPassword);
                ent.DeleteTree();

            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:kcly3027,项目名称:knowledge,代码行数:17,代码来源:ADHelp.cs

示例13: DeleteUserAccount

 public bool DeleteUserAccount(string FQDN, LogFile log)
 {
     try
     {
         FQDN = "LDAP://" + FQDN;
         DirectoryEntry ent = new DirectoryEntry(FQDN);
         ent.DeleteTree();
         ent.Close();
         ent.Dispose();
         log.addTrn("deleted user account |" + FQDN, "Transaction");
         return true;
     }
     catch (System.DirectoryServices.DirectoryServicesCOMException E)
     {
         log.addTrn(E.Message.ToString() + " error deleting user " + FQDN, "Error");
         return false;
     }
 }
开发者ID:adventistuniversity,项目名称:ldap-magic,代码行数:18,代码来源:Toolset.cs

示例14: DeleteOU

        public void DeleteOU(string ouPath, string name, LogFile log)
        {
            try
            {
                //needs parent OU present to work
                if (!DirectoryEntry.Exists("LDAP://OU=" + name + "," + ouPath))
                {

                    DirectoryEntry entry = new DirectoryEntry("LDAP://" + ouPath);
                    entry.DeleteTree();
                    entry.Close();
                    entry.Dispose();
                    log.addTrn("deleting ou | LDAP://OU=" + name + "," + ouPath + " does not exists", "Transaction");

                }
                else
                {
                    log.addTrn("error deleting ou LDAP://OU=" + name + "," + ouPath + " does not exists", "Warning");
                }
            }
            catch (Exception ex)
            {
                log.addTrn(ex.Message.ToString() + " error deleting ou LDAP://OU=" + name + "," + ouPath + "\n" + ex.StackTrace.ToString(), "Error");
            }
        }
开发者ID:adventistuniversity,项目名称:ldap-magic,代码行数:25,代码来源:Toolset.cs

示例15: DirectoryEntry_DeleteTree

		public void DirectoryEntry_DeleteTree()
		{
			string barakTsabariDN = configuration.ServerRoot + "cn=Barak Tsabari,ou=Human Resources,ou=people" + ((configuration.BaseDn.Length == 0) ? String.Empty : ("," + configuration.BaseDn));

			Assert.IsTrue(DirectoryEntry.Exists(barakTsabariDN));
			de = new DirectoryEntry(barakTsabariDN,
									configuration.Username,
									configuration.Password,
									configuration.AuthenticationType);						

			// no properties changed
			de.DeleteTree();
			de.CommitChanges();

			Assert.IsFalse(DirectoryEntry.Exists(barakTsabariDN));

			string johnSmithDN = configuration.ServerRoot + "cn=John Smith,ou=Human Resources,ou=people" + ((configuration.BaseDn.Length == 0) ? String.Empty : ("," + configuration.BaseDn));

			Assert.IsTrue(DirectoryEntry.Exists(johnSmithDN));
			de = new DirectoryEntry(johnSmithDN,
									configuration.Username,
									configuration.Password,
									configuration.AuthenticationType);

			de.Properties["telephoneNumber"].Value = "+972 3 9999999";

			// some properties changed
			de.DeleteTree();
			try {
				de.CommitChanges();					
				Assert.Fail("Object " + johnSmithDN + " was not deleted from server");
			}
			catch(AssertionException ae) {
				throw ae;
			}
			catch(Exception e) {
				// do nothing
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:39,代码来源:DirectoryServicesDirectoryEntryTest.cs


注:本文中的System.DirectoryServices.DirectoryEntry.DeleteTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。