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();
     }
 }
예제 #2
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();
     }
 }