Exemplo n.º 1
0
        protected override IConfigDataProvider CreateSession()
        {
            IConfigurationSession configurationSession;

            if (!MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
            {
                configurationSession = (IConfigurationSession)base.CreateSession();
            }
            else
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, sessionSettings, 133, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AirSync\\RemoveMobileDevice.cs");
            }
            configurationSession.UseConfigNC      = false;
            configurationSession.UseGlobalCatalog = (base.DomainController == null && base.ServerSettings.ViewEntireForest);
            return(configurationSession);
        }
Exemplo n.º 2
0
        protected override IConfigDataProvider CreateSession()
        {
            IConfigurationSession configurationSession;

            if (!this.IgnoreDehydratedFlag && SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId))
            {
                configurationSession = SharedConfiguration.CreateScopedToSharedConfigADSession(base.CurrentOrganizationId);
                return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, configurationSession.SessionSettings, 527, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxPolicies\\RetentionPolicyTasks.cs"));
            }
            if (!MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
            {
                configurationSession = (IConfigurationSession)base.CreateSession();
            }
            else
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, sessionSettings, 546, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxPolicies\\RetentionPolicyTasks.cs");
            }
            return(configurationSession);
        }
Exemplo n.º 3
0
        protected override void InternalValidate()
        {
            MailboxIdParameter mailboxIdParameter = null;

            try
            {
                base.InternalValidate();
            }
            catch (ManagementObjectNotFoundException)
            {
                if (this.Identity == null || !this.TryGetMailboxIdFromIdentity(this.Identity.ToString(), out mailboxIdParameter))
                {
                    throw;
                }
                this.deviceExistsinAD = false;
            }
            if (base.HasErrors)
            {
                return;
            }
            if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
            {
                ADObjectId adobjectId;
                if (!base.TryGetExecutingUserId(out adobjectId))
                {
                    throw new ExecutingUserPropertyNotFoundException("executingUserid");
                }
                if (!base.DataObject.Id.Parent.Parent.Equals(adobjectId) || (mailboxIdParameter != null && !mailboxIdParameter.Equals(adobjectId)))
                {
                    base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
                }
            }
            Exception ex = null;

            if (mailboxIdParameter == null)
            {
                mailboxIdParameter = this.Identity.GetMailboxId();
            }
            if (mailboxIdParameter == null && base.DataObject != null)
            {
                this.Identity      = new MobileDeviceIdParameter(base.DataObject);
                mailboxIdParameter = this.Identity.GetMailboxId();
            }
            if (mailboxIdParameter == null)
            {
                base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
            }
            this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, this.CreateTenantGlobalCatalogSession(base.SessionSettings), mailboxIdParameter, "Remove-MobileDevice", out ex);
            if (ex != null)
            {
                base.WriteError(ex, ErrorCategory.InvalidArgument, null);
            }
            if (DeviceInfo.IsThrottlingLimitsExceeded((IConfigurationSession)base.DataSession, this.principal, out this.activeSyncDevices))
            {
                uint maxDeviceDeleteCount = 0U;
                using (IBudget budget = StandardBudget.Acquire(this.principal.Sid, BudgetType.Eas, this.principal.MailboxInfo.OrganizationId.ToADSessionSettings()))
                {
                    IThrottlingPolicy throttlingPolicy = budget.ThrottlingPolicy;
                    maxDeviceDeleteCount = throttlingPolicy.EasMaxDeviceDeletesPerMonth.Value;
                }
                base.WriteError(new LocalizedException(Strings.MaxDeviceDeletesPerMonthReached(this.activeSyncDevices.ObjectsDeletedThisPeriod, maxDeviceDeleteCount)), ErrorCategory.WriteError, null);
            }
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         if (base.ParameterSetName == "Identity")
         {
             base.InternalValidate();
             if (base.HasErrors)
             {
                 return;
             }
             if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
             {
                 ADObjectId id;
                 if (!base.TryGetExecutingUserId(out id))
                 {
                     throw new ExecutingUserPropertyNotFoundException("executingUserid");
                 }
                 TDataObject dataObject = this.DataObject;
                 if (!dataObject.Id.Parent.Parent.Equals(id))
                 {
                     TIdentity identity = this.Identity;
                     base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(identity.ToString())), ErrorCategory.InvalidArgument, null);
                 }
             }
         }
         IRecipientSession recipientSession = this.CreateTenantGlobalCatalogSession(base.SessionSettings);
         this.GetExchangePrincipal(recipientSession);
         if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
         {
             ADObjectId id2;
             if (!base.TryGetExecutingUserId(out id2))
             {
                 throw new ExecutingUserPropertyNotFoundException("executingUserid");
             }
             if (!this.principal.ObjectId.Equals(id2))
             {
                 base.WriteError(new RecipientNotFoundException(this.Mailbox.ToString()), ErrorCategory.InvalidArgument, null);
             }
         }
         if (this.GetMailboxLog)
         {
             IList <LocalizedString> list = null;
             ADObjectId executingUserId   = null;
             base.TryGetExecutingUserId(out executingUserId);
             this.validatedAddresses = MobileDeviceTaskHelper.ValidateAddresses(recipientSession, executingUserId, this.NotificationEmailAddresses, out list);
             if (list != null)
             {
                 foreach (LocalizedString text in list)
                 {
                     this.WriteWarning(text);
                 }
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Exemplo n.º 5
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         base.InternalValidate();
         if (!base.HasErrors)
         {
             if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings))
             {
                 ADObjectId id;
                 if (!base.TryGetExecutingUserId(out id))
                 {
                     throw new ExecutingUserPropertyNotFoundException("executingUserid");
                 }
                 if (!this.DataObject.Id.Parent.Parent.Equals(id))
                 {
                     base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
                 }
             }
             IRecipientSession  recipientSession = this.CreateTenantGlobalCatalogSession(base.SessionSettings);
             Exception          ex        = null;
             MailboxIdParameter mailboxId = this.Identity.GetMailboxId();
             if (mailboxId == null && this.DataObject != null)
             {
                 this.Identity = new MobileDeviceIdParameter(this.DataObject);
                 mailboxId     = this.Identity.GetMailboxId();
             }
             if (mailboxId == null)
             {
                 base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
             }
             ADUser adObject = null;
             this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, mailboxId, "Clear-MobileDevice", out ex, out adObject);
             if (ex != null)
             {
                 base.WriteError(ex, ErrorCategory.InvalidArgument, null);
             }
             IList <LocalizedString> list = null;
             ADObjectId adobjectId        = null;
             base.TryGetExecutingUserId(out adobjectId);
             this.validatedAddresses = MobileDeviceTaskHelper.ValidateAddresses(recipientSession, adobjectId, this.NotificationEmailAddresses, out list);
             if (list != null)
             {
                 foreach (LocalizedString text in list)
                 {
                     this.WriteWarning(text);
                 }
             }
             base.VerifyIsWithinScopes((IDirectorySession)base.DataSession, adObject, true, new DataAccessTask <MobileDevice> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
             if (adobjectId != null)
             {
                 ExchangePrincipal exchangePrincipal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, new MailboxIdParameter(adobjectId), "Clear-MobileDevice", out ex);
                 if (ex != null)
                 {
                     base.WriteWarning(ex.ToString());
                 }
                 if (exchangePrincipal != null)
                 {
                     this.wipeRequestorSMTP = exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
                 }
                 else
                 {
                     this.wipeRequestorSMTP = null;
                 }
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }