Home > other >  The great god, please come in, c # AD domain delete domain organization unit, quote, "a directo
The great god, please come in, c # AD domain delete domain organization unit, quote, "a directo

Time:11-28


DirectoryEntry domian=null;
IsConnected (" dachkj.com ", "liubq", "road!" , out domian);
If (domian!=null)
{

DirectorySearcher deSearch=new DirectorySearcher ();
DeSearch. SearchRoot=domian;
DeSearch. Filter="(& amp; (objectClass=organizationalUnit) (OU=technology)) ";
SearchResultCollection results=deSearch. The.findall ();
If (the Count & gt; 0)
{
DirectoryEntry parentOuEntry=results. [0] GetDirectoryEntry ();


DirectoryEntries dentrys=parentOuEntry. Children;
DirectoryEntry organizeEntry=dentrys. Find (" OU=technology group ", "organizationalUnit");
Dentrys. Remove (organizeEntry);
OrganizeEntry.Com mitChanges ();

//ouEntry UsePropertyCache=true;
//ouEntry. Rename (" OU=technology group 1 ");
//DirectoryEntry OU=ouEntry. Children. The Add (" OU=technology group ", "organizationalUnit");
//OU.Com mitChanges ();
//ouEntry.Com mitChanges ();
}
}

In execution Remove abnormal, object can be used in normal, very strange, ask the great spirit guide!

CodePudding user response:

To find the problem, find the words to ask