Пример #1
0
        protected override OrganizationId ResolveCurrentOrganization()
        {
            ADUser aduser = Utils.FindById <ADUser>(this.Identity, base.TenantGlobalCatalogSession);

            if (aduser == null)
            {
                ExTraceGlobals.SearchLibraryTracer.TraceError <MailboxIdParameter>((long)this.GetHashCode(), "Could not lookup user specified in MailboxIdParameter: {0}", this.Identity);
            }
            else
            {
                this.trackedMailbox = TrackedUser.Create(aduser);
            }
            if (this.trackedMailbox == null || this.trackedMailbox.ADRecipient == null)
            {
                this.trackedMailbox = null;
                ExTraceGlobals.SearchLibraryTracer.TraceError <MailboxIdParameter>((long)this.GetHashCode(), "Error, could not resolve user specified in Identity: {0}", this.Identity);
                return(base.ResolveCurrentOrganization());
            }
            OrganizationId organizationId = this.trackedMailbox.ADRecipient.OrganizationId;

            if (!base.ExecutingUserOrganizationId.Equals(OrganizationId.ForestWideOrgId) && !base.ExecutingUserOrganizationId.Equals(organizationId) && !organizationId.OrganizationalUnit.IsDescendantOf(base.ExecutingUserOrganizationId.OrganizationalUnit))
            {
                ExTraceGlobals.SearchLibraryTracer.TraceError <MailboxIdParameter>((long)this.GetHashCode(), "Error, executing user is not parent of tracked mailbox: {0}", this.Identity);
                throw new ManagementObjectNotFoundException(Strings.ErrorManagementObjectNotFound(this.Identity.ToString()));
            }
            return(organizationId);
        }
Пример #2
0
        protected override OrganizationId ResolveCurrentOrganization()
        {
            ADObjectId entryId;

            if (base.TryGetExecutingUserId(out entryId))
            {
                this.executingUser = base.TenantGlobalCatalogSession.ReadADRawEntry(entryId, new PropertyDefinition[]
                {
                    ADRecipientSchema.EmailAddresses,
                    ADRecipientSchema.PrimarySmtpAddress,
                    ADUserSchema.Languages
                });
            }
            this.trackedUser = TrackedUser.Create(this.Identity.UserGuid, base.TenantGlobalCatalogSession);
            if (this.trackedUser == null || this.trackedUser.ADRecipient == null)
            {
                ExTraceGlobals.SearchLibraryTracer.TraceError <MessageTrackingReportId>((long)this.GetHashCode(), "Identity {0} could not be resolved to an ADRecipient or was an invalid ADRecipient. Search will fail", this.Identity);
                this.trackedUser = null;
                return(base.ResolveCurrentOrganization());
            }
            OrganizationId organizationId = this.trackedUser.ADRecipient.OrganizationId;

            if (!base.ExecutingUserOrganizationId.Equals(OrganizationId.ForestWideOrgId) && !base.ExecutingUserOrganizationId.Equals(organizationId) && !organizationId.OrganizationalUnit.IsDescendantOf(base.ExecutingUserOrganizationId.OrganizationalUnit))
            {
                ExTraceGlobals.SearchLibraryTracer.TraceError <MessageTrackingReportId>((long)this.GetHashCode(), "Error, executing user is not parent of tracked mailbox: {0}", this.Identity);
                throw new ManagementObjectNotFoundException(Strings.ErrorManagementObjectNotFound(this.Identity.ToString()));
            }
            return(organizationId);
        }
Пример #3
0
        protected override void InternalValidate()
        {
            if (this.Identity == null || this.trackedMailbox == null)
            {
                this.HandleError((this.Identity == null) ? "Null identity in Search" : "null trackedmailbox in search", Strings.TrackingPermanentError, CoreStrings.InvalidIdentityForAdmin, null, ErrorCategory.InvalidData);
            }
            if (this.IsOwaJumpOffPointRequest)
            {
                this.SetSenderAndMessageId(this.trackedMailbox.ADUser);
            }
            if (base.Fields.Contains("Sender") && this.Sender != null && !this.Sender.Value.IsValidAddress)
            {
                base.WriteError(new ArgumentException(CoreStrings.InvalidSender, "Sender"), ErrorCategory.InvalidArgument, this.Sender.Value);
            }
            if (this.Recipients != null && this.Recipients.Length > 0)
            {
                foreach (SmtpAddress smtpAddress in this.Recipients)
                {
                    if (!smtpAddress.IsValidAddress)
                    {
                        base.WriteError(new ArgumentException(Strings.InvalidRecipient), ErrorCategory.InvalidArgument, smtpAddress);
                    }
                }
            }
            if (this.Sender != null)
            {
                this.trackedSender = TrackedUser.Create(this.Sender.Value.ToString(), base.TenantGlobalCatalogSession);
                if (this.trackedSender == null)
                {
                    this.HandleError("Null trackedSender", Strings.TrackingPermanentError, CoreStrings.InvalidSenderForAdmin, null, ErrorCategory.InvalidData);
                }
                else if (!this.trackedSender.IsSupportedForTrackingAsSender)
                {
                    this.HandleError("trackedSender type is unsupported.", CoreStrings.UnsupportedSenderForTracking, CoreStrings.UnsupportedSenderForTracking, null, ErrorCategory.InvalidData);
                }
            }
            if (this.Recipients != null && this.Recipients.Length > 0)
            {
                this.trackedRecipients = new TrackedUser[this.Recipients.Length];
                for (int j = 0; j < this.Recipients.Length; j++)
                {
                    this.trackedRecipients[j] = TrackedUser.Create(this.Recipients[j].ToString(), base.TenantGlobalCatalogSession);
                    if (this.trackedRecipients[j] == null)
                    {
                        this.HandleError(string.Format("Null trackedRecipient for recipient: {0}", this.Recipients[j]), Strings.TrackingPermanentError, CoreStrings.InvalidRecipientForAdmin(this.Recipients[j].ToString()), null, ErrorCategory.InvalidData);
                    }
                }
            }
            bool       flag = this.BypassDelegateChecking.IsPresent && this.BypassDelegateChecking.ToBool();
            ADObjectId executingUserId;

            base.TryGetExecutingUserId(out executingUserId);
            string debugMessage;

            if (!flag && !Utils.AccessCheck((ADObjectId)this.trackedMailbox.ADUser.Identity, executingUserId, base.TenantGlobalCatalogSession, out debugMessage))
            {
                this.HandleError(debugMessage, CoreStrings.TrackingSearchNotAuthorized, CoreStrings.TrackingSearchNotAuthorized, null, ErrorCategory.PermissionDenied);
            }
            if (!string.IsNullOrEmpty(this.MessageId))
            {
                string messageId = this.MessageId;
                if (messageId.StartsWith("<") && messageId.EndsWith(">"))
                {
                    this.MessageId = messageId.Substring(1, messageId.Length - 2);
                }
            }
            base.InternalValidate();
        }