示例#1
0
 protected override void InternalBeginProcessing()
 {
     base.InternalBeginProcessing();
     if (this.Organization != null)
     {
         IConfigurationSession session = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
         ADOrganizationalUnit  adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Organization, session, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString())));
         base.CurrentOrganizationId = adorganizationalUnit.OrganizationId;
     }
 }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         string     empty      = string.Empty;
         string     empty2     = string.Empty;
         int        num        = 0;
         ADObjectId adobjectId = null;
         base.OrganizationId = OrganizationId.ForestWideOrgId;
         if (base.ParameterSetName.Equals("MailboxMigrationOutlookAnywherePublicFolder"))
         {
             IConfigurationSession session = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
             if (this.Organization == null && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId)
             {
                 this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit);
             }
             if (this.Organization != null)
             {
                 ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Organization, session, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString())));
                 base.OrganizationId = adorganizationalUnit.OrganizationId;
             }
             base.RescopeToOrgId(base.OrganizationId);
             base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
         }
         else if (base.ParameterSetName.Equals("MailboxMigrationLocalPublicFolder"))
         {
             base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull);
             PublicFolderDatabase publicFolderDatabase = base.CheckDatabase <PublicFolderDatabase>(this.SourceDatabase, NewRequest <PublicFolderMailboxMigrationRequest> .DatabaseSide.Source, this.SourceDatabase, out empty, out empty2, out adobjectId, out num);
             this.sourceDatabase = publicFolderDatabase.Id;
         }
         this.recipientSession  = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.FullyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(base.OrganizationId), 408, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\PublicFolderMailboxMigrationRequest\\NewPublicFolderMailboxMigrationRequest.cs");
         this.TargetMailboxUser = (ADUser)base.GetDataObject <ADUser>(this.TargetMailbox, this.recipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.TargetMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.TargetMailbox.ToString())));
         TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.OrganizationId);
         this.PublicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(base.OrganizationId);
         if (this.PublicFolderConfiguration.HeuristicsFlags.HasFlag(HeuristicsFlags.PublicFolderMigrationComplete))
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorPublicFolderMigrationCompletedPreviously), ExchangeErrorCategory.Client, null);
         }
         if (this.PublicFolderConfiguration.GetHierarchyMailboxInformation().HierarchyMailboxGuid == Guid.Empty)
         {
             base.WriteError(new RecipientTaskException(MrsStrings.PublicFolderMailboxesNotProvisionedForMigration), ExchangeErrorCategory.ServerOperation, null);
         }
         if (this.PublicFolderConfiguration.GetLocalMailboxRecipient(this.TargetMailboxUser.ExchangeGuid) == null)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorCannotMigratePublicFolderIntoNonPublicFolderMailbox), ExchangeErrorCategory.Client, this.TargetMailboxUser);
         }
         if (base.WorkloadType == RequestWorkloadType.None)
         {
             base.WorkloadType = (((base.Flags & RequestFlags.IntraOrg) == RequestFlags.IntraOrg) ? RequestWorkloadType.Local : RequestWorkloadType.Onboarding);
         }
         base.RequestName = "PublicFolderMailboxMigration" + this.TargetMailboxUser.ExchangeGuid;
         ADObjectId          requestQueueForMailboxMigrationRequest = this.GetRequestQueueForMailboxMigrationRequest();
         DatabaseIdParameter databaseIdParameter = new DatabaseIdParameter(requestQueueForMailboxMigrationRequest);
         ADObjectId          mdbServerSite       = null;
         MailboxDatabase     mailboxDatabase     = base.CheckDatabase <MailboxDatabase>(databaseIdParameter, NewRequest <PublicFolderMailboxMigrationRequest> .DatabaseSide.RequestStorage, this.Organization, out empty, out empty2, out mdbServerSite, out num);
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.CurrentOrgConfigSession.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         base.MdbId         = mailboxDatabase.Id;
         base.MdbServerSite = mdbServerSite;
         base.RequestName   = this.CheckRequestNameAvailability(base.RequestName, null, false, MRSRequestType.PublicFolderMailboxMigration, this.TargetMailbox, false);
         if (base.CheckRequestOfTypeExists(MRSRequestType.PublicFolderMigration))
         {
             base.WriteError(new MultiplePublicFolderMigrationTypesNotAllowedException(), ExchangeErrorCategory.Client, this.Organization);
         }
         this.ValidateCSV();
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
 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();
     }
 }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         string     empty      = string.Empty;
         string     empty2     = string.Empty;
         int        num        = 0;
         ADObjectId adobjectId = null;
         if (base.ParameterSetName.Equals("MigrationOutlookAnywherePublicFolder"))
         {
             IConfigurationSession session = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
             if (this.Organization == null)
             {
                 this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit);
             }
             ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Organization, session, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString())));
             base.RescopeToOrgId(adorganizationalUnit.OrganizationId);
             base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
         }
         else if (base.ParameterSetName.Equals("MigrationLocalPublicFolder"))
         {
             base.OrganizationId = OrganizationId.ForestWideOrgId;
             base.Flags          = (RequestFlags.IntraOrg | RequestFlags.Pull);
             PublicFolderDatabase publicFolderDatabase = base.CheckDatabase <PublicFolderDatabase>(this.SourceDatabase, NewRequest <PublicFolderMigrationRequest> .DatabaseSide.Source, this.SourceDatabase, out empty, out empty2, out adobjectId, out num);
             this.sourceDatabase = publicFolderDatabase.Id;
         }
         if (base.WorkloadType == RequestWorkloadType.None)
         {
             base.WorkloadType = (((base.Flags & RequestFlags.IntraOrg) == RequestFlags.IntraOrg) ? RequestWorkloadType.Local : RequestWorkloadType.Onboarding);
         }
         if (!string.IsNullOrEmpty(this.Name))
         {
             base.ValidateName();
             base.RequestName = this.Name;
         }
         else
         {
             base.RequestName = "PublicFolderMigration";
         }
         ADObjectId          adObjectId          = this.AutoSelectRequestQueueForPFRequest(base.OrganizationId);
         DatabaseIdParameter databaseIdParameter = new DatabaseIdParameter(adObjectId);
         ADObjectId          mdbServerSite       = null;
         MailboxDatabase     mailboxDatabase     = base.CheckDatabase <MailboxDatabase>(databaseIdParameter, NewRequest <PublicFolderMigrationRequest> .DatabaseSide.RequestStorage, this.Organization, out empty, out empty2, out mdbServerSite, out num);
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.CurrentOrgConfigSession.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         base.MdbId         = mailboxDatabase.Id;
         base.MdbServerSite = mdbServerSite;
         this.CheckRequestNameAvailability(null, null, false, MRSRequestType.PublicFolderMigration, this.Organization, false);
         if (base.CheckRequestOfTypeExists(MRSRequestType.PublicFolderMailboxMigration))
         {
             base.WriteError(new MultiplePublicFolderMigrationTypesNotAllowedException(), ExchangeErrorCategory.Client, this.Organization);
         }
         this.publicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(base.OrganizationId);
         if (this.publicFolderConfiguration.HeuristicsFlags.HasFlag(HeuristicsFlags.PublicFolderMigrationComplete))
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorPublicFolderMigrationCompletedPreviously), ExchangeErrorCategory.Client, null);
         }
         this.ValidateCSV();
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
示例#5
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         if (this.Identity != null)
         {
             TIdentity identity = this.Identity;
             if (identity.OrganizationId != null)
             {
                 IDirectorySession recipSession = this.RecipSession;
                 TIdentity         identity2    = this.Identity;
                 if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(recipSession, identity2.OrganizationId))
                 {
                     IDirectorySession recipSession2 = this.RecipSession;
                     TIdentity         identity3     = this.Identity;
                     this.RecipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(recipSession2, identity3.OrganizationId, true);
                 }
                 IDirectorySession currentOrgConfigSession = this.CurrentOrgConfigSession;
                 TIdentity         identity4 = this.Identity;
                 if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(currentOrgConfigSession, identity4.OrganizationId))
                 {
                     IDirectorySession currentOrgConfigSession2 = this.CurrentOrgConfigSession;
                     TIdentity         identity5 = this.Identity;
                     this.CurrentOrgConfigSession     = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(currentOrgConfigSession2, identity5.OrganizationId, true);
                     this.indexProvider.ConfigSession = this.CurrentOrgConfigSession;
                 }
             }
             TIdentity identity6 = this.Identity;
             if (!string.IsNullOrEmpty(identity6.MailboxName))
             {
                 IRecipientSession recipSession3  = this.RecipSession;
                 IRecipientSession gcsession      = this.GCSession;
                 ADServerSettings  serverSettings = base.ServerSettings;
                 TIdentity         identity7      = this.Identity;
                 ADUser            aduser         = RequestTaskHelper.ResolveADUser(recipSession3, gcsession, 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.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   session             = 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, session, 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.indexProvider.ConfigSession = this.CurrentOrgConfigSession;
                 }
             }
             TIdentity identity13 = this.Identity;
             identity13.SetDefaultIndex(this.DefaultRequestIndexId);
         }
         base.InternalProcessRecord();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
示例#6
0
        protected override IConfigurable PrepareDataObject()
        {
            TIdentity identity = this.Identity;

            if (identity.OrganizationId != null)
            {
                IDirectorySession writeableSession = this.WriteableSession;
                TIdentity         identity2        = this.Identity;
                if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(writeableSession, identity2.OrganizationId))
                {
                    IDirectorySession writeableSession2 = this.WriteableSession;
                    TIdentity         identity3         = this.Identity;
                    this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(writeableSession2, identity3.OrganizationId, true);
                }
                IDirectorySession currentOrgConfigSession = this.CurrentOrgConfigSession;
                TIdentity         identity4 = this.Identity;
                if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(currentOrgConfigSession, identity4.OrganizationId))
                {
                    IDirectorySession currentOrgConfigSession2 = this.CurrentOrgConfigSession;
                    TIdentity         identity5 = this.Identity;
                    this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(currentOrgConfigSession2, identity5.OrganizationId, true);
                    this.RJProvider.IndexProvider.ConfigSession = this.CurrentOrgConfigSession;
                }
            }
            TIdentity identity6 = this.Identity;

            if (!string.IsNullOrEmpty(identity6.MailboxName))
            {
                IRecipientSession writeableSession3 = this.WriteableSession;
                IRecipientSession gcsession         = this.GCSession;
                ADServerSettings  serverSettings    = base.ServerSettings;
                TIdentity         identity7         = this.Identity;
                ADUser            aduser            = RequestTaskHelper.ResolveADUser(writeableSession3, gcsession, serverSettings, new UserIdParameter(identity7.MailboxName), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true);
                if (aduser != null)
                {
                    TIdentity identity8 = this.Identity;
                    identity8.MailboxId = aduser.Id;
                    if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.WriteableSession, aduser))
                    {
                        this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.WriteableSession, 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   session             = 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, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorOrganizationNotUnique(identity12.OrganizationName)));
                if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.WriteableSession, adorganizationalUnit))
                {
                    this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.WriteableSession, 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);
            this.IndexEntry = this.GetEntry();
            this.CheckIndexEntry();
            if (this.IndexEntry == null)
            {
                return(null);
            }
            RequestJobObjectId requestJobId = this.IndexEntry.GetRequestJobId();

            if (this.IndexEntry.TargetUserId != null)
            {
                requestJobId.TargetUser = this.ResolveADUser(this.IndexEntry.TargetUserId);
            }
            if (this.IndexEntry.SourceUserId != null)
            {
                requestJobId.SourceUser = this.ResolveADUser(this.IndexEntry.SourceUserId);
            }
            return((TransactionalRequestJob)this.RJProvider.Read <TransactionalRequestJob>(requestJobId));
        }