Beispiel #1
0
 private void RemoveADReplicationSite(ADObject directoryObj)
 {
     using (ADActiveObject aDActiveObject = new ADActiveObject(base.CmdletSessionInfo.ADSessionInfo, directoryObj))
     {
         aDActiveObject.DeleteTree(false);
     }
 }
Beispiel #2
0
        private bool ADRemoveCmdletBaseProcessCSRoutine()
        {
            bool flag;
            bool hasValue;
            O    item = (O)this._cmdletParameters["Identity"];

            this.SetPipelinedSessionInfo(item.SessionInfo);
            CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo();

            this._factory.SetCmdletSessionInfo(cmdletSessionInfo);
            this.ValidateParameters();
            string defaultPartitionPath = this._cmdletParameters["Partition"] as string;

            if (defaultPartitionPath == null)
            {
                defaultPartitionPath = this.GetDefaultPartitionPath();
                if (defaultPartitionPath == null && !item.IsSearchResult)
                {
                    object[] objArray = new object[1];
                    objArray[0] = "Partition";
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray));
                }
            }
            if (this._showDeleted)
            {
                hasValue = true;
            }
            else
            {
                if (!item.Contains("Deleted"))
                {
                    hasValue = false;
                }
                else
                {
                    bool?value = (bool?)(item.GetValue("Deleted") as bool?);
                    if (!value.GetValueOrDefault())
                    {
                        hasValue = false;
                    }
                    else
                    {
                        hasValue = value.HasValue;
                    }
                }
            }
            bool     flag1 = hasValue;
            ADObject directoryObjectFromIdentity = this._factory.GetDirectoryObjectFromIdentity(item, defaultPartitionPath, flag1);

            using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity))
            {
                bool flag2 = this._cmdletParameters.Contains("Recursive");
                if (!flag2)
                {
                    if (!base.ShouldProcessOverride(directoryObjectFromIdentity.DistinguishedName, "Remove"))
                    {
                        flag = false;
                        return(flag);
                    }
                }
                else
                {
                    object[] distinguishedName = new object[1];
                    distinguishedName[0] = directoryObjectFromIdentity.DistinguishedName;
                    string str = string.Format(CultureInfo.CurrentCulture, StringResources.PerformingRecursiveRemove, distinguishedName);
                    if (!base.ShouldProcessOverride(str, str, StringResources.PromptForRecursiveRemove))
                    {
                        flag = false;
                        return(flag);
                    }
                }
                O o = default(O);
                if (this._factory.PreCommitProcesing(ADFactory <O> .DirectoryOperation.Delete, o, this._cmdletParameters, directoryObjectFromIdentity))
                {
                    aDActiveObject.Update();
                }
                if (!flag2)
                {
                    aDActiveObject.Delete(flag1);
                }
                else
                {
                    aDActiveObject.DeleteTree(flag1);
                }
                O o1 = default(O);
                this._factory.PostCommitProcesing(ADFactory <O> .DirectoryOperation.Delete, o1, this._cmdletParameters, directoryObjectFromIdentity);
                return(true);
            }
            return(flag);
        }