internal void CheckIndexEntryTargetUserNotNull(IRequestIndexEntry index) { if (index.TargetUserId == null) { base.WriteError(new ManagementObjectNotFoundException(Strings.RequestIndexEntryIsMissingLocalUserData(index.ToString())), ErrorCategory.InvalidArgument, this.Identity); } }
public IConfigurable Read <T>(ObjectId identity) where T : IConfigurable, new() { if (identity == null) { throw new ArgumentNullException("identity"); } RequestIndexEntryObjectId requestIndexEntryObjectId = identity as RequestIndexEntryObjectId; if (requestIndexEntryObjectId == null) { throw new ArgumentException("This provider only supports RequestIndexEntryObjectIds", "identity"); } Type typeFromHandle = typeof(T); if (!typeFromHandle.IsSubclassOf(typeof(RequestBase)) && !typeof(IRequestIndexEntry).IsAssignableFrom(typeFromHandle)) { throw new ArgumentException("This provider only supports reading types of RequestBase or IRequestIndexEntry"); } IRequestIndexEntry requestIndexEntry = this.Read(requestIndexEntryObjectId); if (requestIndexEntry == null || requestIndexEntry is T) { return(requestIndexEntry); } if (!typeFromHandle.IsSubclassOf(typeof(RequestBase))) { return(null); } return(RequestIndexEntryProvider.CreateRequest <T>(requestIndexEntry)); }
internal virtual void Initialize(IRequestIndexEntry index) { if (index == null) { throw new ArgumentNullException("index"); } this[SimpleProviderObjectSchema.Identity] = index.GetRequestIndexEntryId(this); this.Name = index.Name; this.Status = index.Status; this.Flags = index.Flags; this.RemoteHostName = index.RemoteHostName; this.SourceDatabase = index.SourceMDB; this.TargetDatabase = index.TargetMDB; this.FilePath = index.FilePath; this.SourceMailbox = index.SourceUserId; this.TargetMailbox = index.TargetUserId; this.RequestGuid = index.RequestGuid; this.RequestQueue = index.StorageMDB; this.OrganizationId = index.OrganizationId; this.BatchName = index.BatchName; this.Type = index.Type; this.WhenChanged = index.WhenChanged; this.WhenCreated = index.WhenCreated; this.WhenChangedUTC = index.WhenChangedUTC; this.WhenCreatedUTC = index.WhenCreatedUTC; }
public void Save(IConfigurable instance) { IRequestIndexEntry requestIndexEntry = RequestIndexEntryProvider.ValidateInstance(instance); RequestIndexEntryProvider.Handle(requestIndexEntry.GetType(), delegate(IRequestIndexEntryHandler handler) { handler.Save(this, requestIndexEntry); }); }
internal RequestJobObjectId(Guid requestGuid, Guid mdbGuid, IRequestIndexEntry indexEntry = null) { this.requestGuid = requestGuid; this.mdbGuid = mdbGuid; this.messageId = null; this.adUser = null; this.sourceUser = null; this.targetUser = null; this.indexEntry = indexEntry; }
private static IRequestIndexEntry ValidateInstance(IConfigurable instance) { if (instance == null) { throw new ArgumentNullException("instance"); } IRequestIndexEntry requestIndexEntry = instance as IRequestIndexEntry; if (requestIndexEntry == null) { throw new ArgumentException(string.Format("This provider only supports IRequestIndexEntrys but was provided {0}.", instance.GetType().Name), "instance"); } return(requestIndexEntry); }
internal static T CreateRequest <T>(IRequestIndexEntry requestIndexEntry) where T : IConfigurable, new() { if (requestIndexEntry == null) { throw new ArgumentNullException("requestIndexEntry"); } T t = (default(T) == null) ? Activator.CreateInstance <T>() : default(T); RequestBase requestBase = t as RequestBase; if (requestBase == null) { throw new ArgumentException(string.Format("Type [{0}] not supported. Must specify a derivative of RequestBase.", typeof(T).Name)); } requestBase.Initialize(requestIndexEntry); return(t); }
public static void CreateAndPopulateRequestIndexEntries(RequestJobBase requestJobBase, RequestIndexId requestIndexId) { if (requestJobBase == null) { throw new ArgumentNullException("requestJobBase"); } if (requestJobBase.IndexEntries == null) { requestJobBase.IndexEntries = new List <IRequestIndexEntry>(); } if (requestJobBase.IndexIds == null) { requestJobBase.IndexIds = new List <RequestIndexId>(); } RequestIndexEntryProvider.Handle(requestIndexId.RequestIndexEntryType, delegate(IRequestIndexEntryHandler handler) { IRequestIndexEntry item = handler.CreateRequestIndexEntryFromRequestJob(requestJobBase, requestIndexId); requestJobBase.IndexIds.Add(requestIndexId); requestJobBase.IndexEntries.Add(item); }); }
private static void UpdateIndexEntryData(IRequestIndexEntry indexEntry, TransactionalRequestJob requestJob) { if (indexEntry != null && requestJob != null) { indexEntry.Status = requestJob.Status; indexEntry.Flags = requestJob.Flags; indexEntry.SourceMDB = requestJob.SourceDatabase; indexEntry.StorageMDB = requestJob.WorkItemQueueMdb; indexEntry.TargetMDB = requestJob.TargetDatabase; indexEntry.SourceUserId = requestJob.SourceUserId; indexEntry.TargetUserId = requestJob.TargetUserId; indexEntry.FilePath = requestJob.FilePath; indexEntry.RemoteHostName = requestJob.RemoteHostName; indexEntry.BatchName = requestJob.BatchName; indexEntry.RequestGuid = requestJob.Identity.RequestGuid; AggregatedAccountConfigurationWrapper aggregatedAccountConfigurationWrapper = indexEntry as AggregatedAccountConfigurationWrapper; if (aggregatedAccountConfigurationWrapper != null) { aggregatedAccountConfigurationWrapper.UpdateData(requestJob); } } }
public static void CreateAndPopulateRequestIndexEntries(RequestJobBase requestJobBase, IConfigurationSession session) { if (requestJobBase == null) { throw new ArgumentNullException("requestJobBase"); } if (requestJobBase.IndexEntries == null) { requestJobBase.IndexEntries = new List <IRequestIndexEntry>(); } if (requestJobBase.IndexIds == null) { requestJobBase.IndexIds = new List <RequestIndexId>(); } RequestIndexId indexId = new RequestIndexId(RequestIndexLocation.AD); RequestIndexEntryProvider.Handle(indexId.RequestIndexEntryType, delegate(IRequestIndexEntryHandler handler) { IRequestIndexEntry item = handler.CreateRequestIndexEntryFromRequestJob(requestJobBase, session); requestJobBase.IndexIds.Add(indexId); requestJobBase.IndexEntries.Add(item); }); }
internal PublicFolderMigrationRequest(IRequestIndexEntry index) : base(index) { }
internal override string GenerateIndexEntryString(IRequestIndexEntry entry) { return(new PublicFolderMailboxMigrationRequest(entry).ToString()); }
internal override string GenerateIndexEntryString(IRequestIndexEntry entry) { return(new MailboxRestoreRequest(entry).ToString()); }
internal RequestBase(IRequestIndexEntry index) : this() { this.Initialize(index); }
internal MailboxExportRequest(IRequestIndexEntry index) : base(index) { }
void IRequestIndexEntryHandler.Save(RequestIndexEntryProvider requestIndexEntryProvider, IRequestIndexEntry instance) { if (instance == null) { throw new ArgumentNullException("instance"); } this.Save(requestIndexEntryProvider, (T)((object)instance)); }
public IConfigurable Read <T>(ObjectId identity, ReadJobFlags readJobFlags) where T : IConfigurable, new() { if (identity == null) { throw new ArgumentNullException("identity", "The identity of the object to be read must be specified."); } if (!(identity is RequestJobObjectId)) { throw new ArgumentException("RequestJobProvider can only identify RequestJobs based on RequestJobObjectIds.", "identity"); } if (!typeof(T).Equals(typeof(TransactionalRequestJob)) && !RequestJobProvider.IsRequestStatistics(typeof(T), true)) { throw new ArgumentException("RequestJobProvider can only Read *RequestStatistics or TransactionalRequestJob objects."); } bool flag = false; if (typeof(T).Equals(typeof(TransactionalRequestJob))) { flag = true; } RequestJobObjectId requestJobObjectId = (RequestJobObjectId)identity; Guid requestGuid = requestJobObjectId.RequestGuid; Guid mdbGuid = requestJobObjectId.MdbGuid; byte[] messageId = requestJobObjectId.MessageId; ADUser aduser = requestJobObjectId.User; ADUser aduser2 = requestJobObjectId.SourceUser; ADUser aduser3 = requestJobObjectId.TargetUser; IRequestIndexEntry indexEntry = requestJobObjectId.IndexEntry; List <IRequestIndexEntry> list = new List <IRequestIndexEntry>(); if (requestGuid == Guid.Empty || mdbGuid == Guid.Empty) { throw new NotEnoughInformationToFindMoveRequestPermanentException(); } this.EnsureStoreConnectionExists(mdbGuid); MoveObjectInfo <RequestJobXML> moveObjectInfo = null; IConfigurable result; try { moveObjectInfo = new MoveObjectInfo <RequestJobXML>(mdbGuid, this.store, messageId, RequestJobXML.RequestJobsFolderName, RequestJobXML.RequestJobsMessageClass, RequestJobXML.CreateMessageSubject(requestGuid), RequestJobXML.CreateMessageSearchKey(requestGuid)); RequestJobXML requestJobXML = null; if (moveObjectInfo.OpenMessage()) { if (moveObjectInfo.CheckObjectType(new MoveObjectInfo <RequestJobXML> .IsSupportedObjectTypeDelegate(RequestJobXML.IsMessageTypeSupported))) { requestJobXML = moveObjectInfo.ReadObject(ReadObjectFlags.DontThrowOnCorruptData); } else { MrsTracer.Common.Warning("Found unexpected JobType for move job {0}", new object[] { requestJobObjectId.ToString() }); } if (requestJobXML == null) { if (!this.AllowInvalid) { return(null); } requestJobXML = RequestJobBase.CreateDummyObject <RequestJobXML>(); requestJobXML.RequestGuid = requestGuid; requestJobXML.ExchangeGuid = requestGuid; } requestJobXML.OriginatingMDBGuid = mdbGuid; if (requestJobXML.Identity == null) { requestJobXML.Identity = requestJobObjectId; } requestJobXML.Identity.MessageId = moveObjectInfo.MessageId; RequestJobProvider.FixTenantInfo(requestJobXML); if (!requestJobXML.IsFake) { using (this.IndexProvider.RescopeTo(requestJobXML.DomainControllerToUpdate, requestJobXML.OrganizationId)) { if (aduser == null && requestJobXML.UserId != null) { aduser = this.IndexProvider.ReadADUser(requestJobXML.UserId, requestJobXML.ExchangeGuid); } if (aduser2 == null && requestJobXML.SourceUserId != null) { aduser2 = this.IndexProvider.ReadADUser(requestJobXML.SourceUserId, requestJobXML.SourceExchangeGuid); } if (aduser3 == null && requestJobXML.TargetUserId != null) { aduser3 = this.IndexProvider.ReadADUser(requestJobXML.TargetUserId, requestJobXML.TargetExchangeGuid); } if (!typeof(T).Equals(typeof(MoveRequestStatistics)) && requestJobXML.RequestType != MRSRequestType.Move && requestJobXML.IndexIds != null && requestJobXML.IndexIds.Count > 0) { int capacity = requestJobXML.IndexIds.Count - 1; bool flag2 = false; List <RequestIndexEntryObjectId> list2 = new List <RequestIndexEntryObjectId>(capacity); foreach (RequestIndexId requestIndexId in requestJobXML.IndexIds) { if (indexEntry != null && requestIndexId.Equals(indexEntry.RequestIndexId)) { if (!flag2) { list.Add(indexEntry); } flag2 = true; } else if (readJobFlags.HasFlag(ReadJobFlags.SkipReadingMailboxRequestIndexEntries) && requestIndexId.Location == RequestIndexLocation.Mailbox) { MrsTracer.Common.Debug("Skipping loading of an IRequestIndexEntry found in a mailbox.", new object[0]); } else { list2.Add(new RequestIndexEntryObjectId(requestJobXML.RequestGuid, requestJobXML.TargetExchangeGuid, requestJobXML.RequestType, requestJobXML.OrganizationId, requestIndexId, null)); } } foreach (RequestIndexEntryObjectId objectId in list2) { IRequestIndexEntry requestIndexEntry = this.IndexProvider.Read(objectId); if (requestIndexEntry != null) { list.Add(requestIndexEntry); } } } if (this.IndexProvider.DomainController == null && !string.IsNullOrEmpty(requestJobXML.DomainControllerToUpdate)) { requestJobXML.DomainControllerToUpdate = null; } } } requestJobXML.User = aduser; requestJobXML.SourceUser = aduser2; requestJobXML.TargetUser = aduser3; requestJobXML.IndexEntries = list; if (!readJobFlags.HasFlag(ReadJobFlags.SkipValidation)) { requestJobXML.ValidateRequestJob(); } if (this.AllowInvalid) { ValidationError[] array = requestJobXML.Validate(); if (array != null && array.Length > 0) { requestJobXML.IsFake = true; } } if (flag) { TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML); requestJobXML.Retire(); transactionalRequestJob.Provider = this; transactionalRequestJob.MoveObject = moveObjectInfo; moveObjectInfo = null; result = transactionalRequestJob; } else { RequestStatisticsBase requestStatisticsBase = RequestJobProvider.CreateRequestStatistics(typeof(T), requestJobXML, true); if (requestStatisticsBase == null) { requestStatisticsBase = new MoveRequestStatistics(requestJobXML); requestJobXML.Retire(); } if (this.LoadReport) { ReportData reportData = new ReportData(requestStatisticsBase.IdentifyingGuid, requestStatisticsBase.ReportVersion); reportData.Load(this.SystemMailbox); requestStatisticsBase.Report = reportData.ToReport(); } result = requestStatisticsBase; } } else { result = null; } } finally { if (moveObjectInfo != null) { moveObjectInfo.Dispose(); moveObjectInfo = null; } } return(result); }
internal override void CheckIndexEntry(IRequestIndexEntry index) { base.CheckIndexEntry(index); base.CheckIndexEntryLocalUserNotNull(index); }
internal MergeRequest(IRequestIndexEntry index) : base(index) { }
internal virtual void CheckIndexEntry(IRequestIndexEntry index) { }
internal MailboxRelocationRequest(IRequestIndexEntry index) : base(index) { }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { if (base.ParameterSetName.Equals("Identity")) { TIdentity identity = this.Identity; if (identity.OrganizationId != null) { IDirectorySession dataSession = this.recipSession; TIdentity identity2 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(dataSession, identity2.OrganizationId)) { IDirectorySession session = this.recipSession; TIdentity identity3 = this.Identity; this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(session, identity3.OrganizationId, true); } IDirectorySession dataSession2 = this.currentOrgConfigSession; TIdentity identity4 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(dataSession2, identity4.OrganizationId)) { IDirectorySession session2 = this.currentOrgConfigSession; TIdentity identity5 = this.Identity; this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(session2, identity5.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } ADUser aduser = null; TIdentity identity6 = this.Identity; if (!string.IsNullOrEmpty(identity6.MailboxName)) { IRecipientSession dataSession3 = this.recipSession; IRecipientSession globalCatalogSession = this.gcSession; ADServerSettings serverSettings = base.ServerSettings; TIdentity identity7 = this.Identity; aduser = RequestTaskHelper.ResolveADUser(dataSession3, globalCatalogSession, serverSettings, new MailboxOrMailUserIdParameter(identity7.MailboxName), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); if (aduser != null) { TIdentity identity8 = this.Identity; identity8.MailboxId = aduser.Id; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.recipSession, aduser)) { this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.recipSession, aduser.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.currentOrgConfigSession, aduser)) { this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.currentOrgConfigSession, aduser.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } } TIdentity identity9 = this.Identity; if (!string.IsNullOrEmpty(identity9.OrganizationName)) { IConfigurationSession configurationSession = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId); TIdentity identity10 = this.Identity; IIdentityParameter id = new OrganizationIdParameter(identity10.OrganizationName); IConfigDataProvider session3 = configurationSession; ObjectId rootID = null; TIdentity identity11 = this.Identity; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorOrganizationNotFound(identity11.OrganizationName)); TIdentity identity12 = this.Identity; ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(id, session3, rootID, notFoundError, new LocalizedString?(Strings.ErrorOrganizationNotUnique(identity12.OrganizationName))); if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.recipSession, adorganizationalUnit)) { this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.recipSession, adorganizationalUnit.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.currentOrgConfigSession, adorganizationalUnit)) { this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.currentOrgConfigSession, adorganizationalUnit.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } TIdentity identity13 = this.Identity; identity13.SetDefaultIndex(this.DefaultRequestIndexId); IRequestIndexEntry entry = this.GetEntry(); RequestJobObjectId requestJobId = entry.GetRequestJobId(); if (entry.TargetUserId != null) { if (aduser != null && aduser.Id.Equals(entry.TargetUserId)) { requestJobId.TargetUser = aduser; } else { requestJobId.TargetUser = RequestTaskHelper.ResolveADUser(this.recipSession, this.gcSession, base.ServerSettings, new MailboxOrMailUserIdParameter(entry.TargetUserId), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); } } if (entry.SourceUserId != null) { if (aduser != null && aduser.Id.Equals(entry.SourceUserId)) { requestJobId.SourceUser = aduser; } else { requestJobId.SourceUser = RequestTaskHelper.ResolveADUser(this.recipSession, this.gcSession, base.ServerSettings, new MailboxOrMailUserIdParameter(entry.SourceUserId), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); } } this.CheckIndexEntry(entry); TDataObject tdataObject = (TDataObject)((object)this.rjProvider.Read <TDataObject>(requestJobId)); if (tdataObject == null || tdataObject.Status == RequestStatus.None) { TIdentity identity14 = this.Identity; base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorCouldNotFindRequest(identity14.ToString())), ErrorCategory.InvalidArgument, this.Identity); } else if (tdataObject.RequestType != this.RequestType) { base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorNotEnoughInformationToFindRequest), ErrorCategory.InvalidArgument, this.Identity); } else { this.WriteResult(tdataObject); } } else if (base.ParameterSetName.Equals("MigrationRequestQueue")) { if (this.RequestQueue != null) { MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.RequestQueue, this.configSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(this.RequestQueue.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(this.RequestQueue.ToString()))); this.fromMdb = mailboxDatabase.Id; } this.rjProvider.AllowInvalid = true; base.InternalProcessRecord(); } } finally { TaskLogger.LogExit(); } }
internal MailboxRestoreRequest(IRequestIndexEntry index) : base(index) { }
internal SyncRequest(IRequestIndexEntry index) : base(index) { }
internal override string GenerateIndexEntryString(IRequestIndexEntry entry) { return(new SyncRequest(entry).ToString()); }
internal PublicFolderMoveRequest(IRequestIndexEntry index) : base(index) { }
internal abstract string GenerateIndexEntryString(IRequestIndexEntry entry);