public ADCmdletBase() { this._cmdletParameters = Activator.CreateInstance <P>(); this._connectedStore = null; this._recordExceptionHandler = new ADRecordExceptionHandler(); this._beginProcessPipeline = new CmdletSubroutinePipeline(); this._processRecordPipeline = new CmdletSubroutinePipeline(); this._endProcessPipeline = new CmdletSubroutinePipeline(); ADExceptionFilter aDExceptionFilter = new ADExceptionFilter(); aDExceptionFilter.Add(this._recordExceptionHandler); aDExceptionFilter.Add(new ADPipelineExceptionHandler(this)); aDExceptionFilter.Add(new ADSystemExceptionHandler()); this._exceptionFilter = aDExceptionFilter; ADCmdletBase <P> aDCmdletBase = this; this.RegisterDisposeCallback(new ADCmdletBase <P> .CmdletDispose(aDCmdletBase.Dispose)); this._cmdletSessionCache = new ADCmdletCache(); this._warningBuffer = new List <string>(); this._errorBuffer = new List <ErrorRecord>(); }
private bool ADMoveCmdletBaseProcessCSRoutine() { bool flag; O item = (O)this._cmdletParameters["Identity"]; this.SetPipelinedSessionInfo(item.SessionInfo); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); this.ValidateParameters(); string defaultPartitionPath = this.GetDefaultPartitionPath(); ADObject directoryObjectFromIdentity = this._factory.GetDirectoryObjectFromIdentity(item, defaultPartitionPath); using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity)) { if (base.ShouldProcessOverride(directoryObjectFromIdentity.DistinguishedName, "Move")) { O o = default(O); if (this._factory.PreCommitProcesing(ADFactory <O> .DirectoryOperation.Move, o, this._cmdletParameters, directoryObjectFromIdentity)) { aDActiveObject.Update(); } string str = this._cmdletParameters["TargetPath"] as string; string childName = ADPathModule.GetChildName(directoryObjectFromIdentity.DistinguishedName, ADPathFormat.X500); string item1 = null; if (!this._cmdletParameters.Contains("TargetServer")) { aDActiveObject.Move(str, childName); } else { item1 = this._cmdletParameters["TargetServer"] as string; aDActiveObject.CrossDomainMove(str, childName, item1); } O o1 = default(O); this._factory.PostCommitProcesing(ADFactory <O> .DirectoryOperation.Move, o1, this._cmdletParameters, directoryObjectFromIdentity); if (this._cmdletParameters.GetSwitchParameterBooleanValue("PassThru")) { ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo; if (this._cmdletParameters.Contains("TargetServer")) { aDSessionInfo.Server = item1; } string str1 = ADPathModule.MakePath(str, childName, ADPathFormat.X500); F f = Activator.CreateInstance <F>(); using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo)) { ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(); ADCmdletCache aDCmdletCache = new ADCmdletCache(); aDSessionInfo.ServerType = Utils.ADServerTypeFromRootDSE(rootDSE); CmdletSessionInfo cmdletSessionInfo1 = new CmdletSessionInfo(aDSessionInfo, rootDSE, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, aDSessionInfo.ServerType, aDCmdletCache, this, this, this._cmdletParameters); f.SetCmdletSessionInfo(cmdletSessionInfo1); O extendedObjectFromDN = this._factory.GetExtendedObjectFromDN(str1); base.WriteObject(extendedObjectFromDN); aDCmdletCache.Clear(); } } return(true); } else { flag = false; } } return(flag); }
private bool SyncADObjectProcessCSRoutine() { CmdletSessionInfo cmdletSessionInfo; ADRootDSE rootDSE; ADObject directoryObjectFromIdentity; bool flag; string empty; this.ValidateParameters(); ADObject obj = this._cmdletParameters.Object; string destination = this._cmdletParameters.Destination; if (this.sourceServer == null) { if (!obj.IsSearchResult) { if (this.currentADDriveServer == null) { object[] objArray = new object[1]; objArray[0] = "Source"; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray)); } else { this.sourceServer = this.currentADDriveServer; } } else { this.sourceServer = obj.SessionInfo.Server; } } try { cmdletSessionInfo = this.GetCmdletSessionInfo(); } catch (ADServerDownException aDServerDownException1) { ADServerDownException aDServerDownException = aDServerDownException1; object[] objArray1 = new object[1]; objArray1[0] = destination; throw new ADServerDownException(string.Format(CultureInfo.CurrentCulture, StringResources.DestinationServerDown, objArray1), aDServerDownException.InnerException, destination); } if (!cmdletSessionInfo.ADRootDSE.IsWritable() || !this._cmdletParameters.GetSwitchParameterBooleanValue("PasswordOnly")) { string dSServiceName = null; ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo.Copy(); aDSessionInfo.Server = this.sourceServer; string distinguishedName = null; using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo)) { try { rootDSE = aDObjectSearcher.GetRootDSE(); dSServiceName = rootDSE.DSServiceName; } catch (ADIdentityNotFoundException aDIdentityNotFoundException) { object[] objArray2 = new object[1]; objArray2[0] = this.sourceServer; throw new ADServerDownException(string.Format(CultureInfo.CurrentCulture, StringResources.SourceServerDown, objArray2), this.sourceServer); } if (!obj.IsSearchResult) { ADCmdletCache aDCmdletCache = new ADCmdletCache(); aDSessionInfo.ServerType = Utils.ADServerTypeFromRootDSE(rootDSE); CmdletSessionInfo cmdletSessionInfo1 = new CmdletSessionInfo(aDSessionInfo, rootDSE, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, aDSessionInfo.ServerType, aDCmdletCache, this, null, this._cmdletParameters); this._adObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo1); try { directoryObjectFromIdentity = this._adObjectFactory.GetDirectoryObjectFromIdentity(obj, cmdletSessionInfo1.DefaultPartitionPath); distinguishedName = directoryObjectFromIdentity.DistinguishedName; } catch (ADIdentityNotFoundException aDIdentityNotFoundException2) { this._adObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); try { directoryObjectFromIdentity = this._adObjectFactory.GetDirectoryObjectFromIdentity(obj, cmdletSessionInfo.DefaultPartitionPath); Guid?objectGuid = directoryObjectFromIdentity.ObjectGuid; distinguishedName = string.Concat("<GUID=", objectGuid.ToString(), ">"); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { object[] str = new object[1]; str[0] = obj.ToString(); throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectToReplicateNotFoundOnSource, str)); } } aDCmdletCache.Clear(); } else { distinguishedName = obj.DistinguishedName; } } ADObject aDObject = new ADObject(); aDObject.DistinguishedName = ""; string str1 = string.Concat(dSServiceName, ":", distinguishedName); if (this._cmdletParameters.GetSwitchParameterBooleanValue("PasswordOnly")) { str1 = string.Concat(str1, ":SECRETS_ONLY"); } aDObject.Add("replicateSingleObject", str1); aDObject.TrackChanges = false; using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, aDObject)) { if (base.ShouldProcessOverride(obj.IdentifyingString, "Sync")) { try { aDActiveObject.Update(); } catch (ADIdentityNotFoundException aDIdentityNotFoundException3) { object[] objArray3 = new object[2]; objArray3[0] = this.sourceServer; objArray3[1] = destination; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.SourceServerObjNotFoundOrObjToReplicateNotFound, objArray3)); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; Win32Exception win32Exception = new Win32Exception(0x200a); if (string.Compare(win32Exception.Message, 0, argumentException.Message, 0, win32Exception.Message.Length, StringComparison.OrdinalIgnoreCase) != 0 || string.Compare("replicateSingleObject", argumentException.ParamName, StringComparison.OrdinalIgnoreCase) != 0) { throw argumentException; } else { object[] objArray4 = new object[1]; objArray4[0] = destination; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.DestinationServerDoesNotSupportSynchronizingObject, objArray4)); } } if (this._cmdletParameters.GetSwitchParameterBooleanValue("PassThru")) { this._adObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADObject extendedObjectFromDN = this._adObjectFactory.GetExtendedObjectFromDN(distinguishedName); base.WriteObject(extendedObjectFromDN); } return(false); } else { flag = false; } } return(flag); } else { CultureInfo currentCulture = CultureInfo.CurrentCulture; string passwordOnlySwitchAllowedOnlyOnRODC = StringResources.PasswordOnlySwitchAllowedOnlyOnRODC; object[] objArray5 = new object[1]; object[] objArray6 = objArray5; int num = 0; string dNSHostName = cmdletSessionInfo.ADRootDSE.DNSHostName; int? portLDAP = cmdletSessionInfo.ADRootDSE.PortLDAP; if (!portLDAP.HasValue) { empty = string.Empty; } else { int?nullable = cmdletSessionInfo.ADRootDSE.PortLDAP; empty = string.Concat(":", nullable.ToString()); } objArray6[num] = string.Concat(dNSHostName, empty); throw new ArgumentException(string.Format(currentCulture, passwordOnlySwitchAllowedOnlyOnRODC, objArray5)); } }