Пример #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
        private async Task RefreshUser(TrackedUser user)
        {
            user.Data = await _searcher.GetUser(user.UserId, user.PlatForm);

            user.LastUpdate = DateTime.Now;
            System.Diagnostics.Debug.WriteLine($"Refreshed user {user.Data.PlatformInfo.PlatformUserHandle}");
        }
Пример #4
0
        static List <TrackedUser> GetTrackedUsers()
        {
            var              ToReturn = new List <TrackedUser>();
            string           sql      = "select * from trackedusers where banned = 0";
            SQLiteCommand    command  = new SQLiteCommand(sql, DBConnection);
            SQLiteDataReader reader   = command.ExecuteReader();

            while (reader.Read())
            {
                var NewUser = new TrackedUser(reader["steamid"].ToString(), reader["steamname"].ToString(), reader["addedby"].ToString(), bool.Parse(reader["banned"].ToString()));
                ToReturn.Add(NewUser);
            }
            return(ToReturn);
        }
Пример #5
0
        /// <summary>
        /// Track a new user
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="platform"></param>
        public async void Add(string userId, string platform)
        {
            var plat = RlTracker.GetPlatform(platform);

            var trackedUser = new TrackedUser()
            {
                PlatForm = plat,
                UserId   = long.Parse(userId)
            };

            await RefreshUser(trackedUser);

            if (!_users.Any(x => x.UserId == trackedUser.UserId))
            {
                trackedUser.SortOrder = this._users.Count;
                _users.Add(trackedUser);
            }

            Save();
        }
Пример #6
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();
        }