// Token: 0x0600014F RID: 335 RVA: 0x00008B30 File Offset: 0x00006D30
 private void LogDiscoveryQueryLoadFailure(IExchangePrincipal mailboxOwner, ExEventLog.EventTuple message)
 {
     Globals.Logger.LogEvent(message, null, new object[]
     {
         mailboxOwner
     });
 }
예제 #2
0
        public static void SaveWithUniqueDisplayName(this IFolder folder, int maxSuffix = 50)
        {
            IStoreSession      session      = folder.Session;
            IExchangePrincipal mailboxOwner = session.MailboxOwner;
            string             displayName  = folder.DisplayName;
            string             text         = displayName;
            int num = 1;

            try
            {
IL_1A:
                FolderSaveResult folderSaveResult = folder.Save();
                if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                {
                    ExTraceGlobals.StorageTracer.TraceError <IExchangePrincipal, string, FolderSaveResult>(0L, "{0}: Failed to create folder {1} due to {2}.", mailboxOwner, text, folderSaveResult);
                    throw folderSaveResult.ToException(ServerStrings.ExCannotCreateFolder(folderSaveResult.ToString()));
                }
            }
            catch (ObjectExistedException)
            {
                if (num > maxSuffix)
                {
                    throw;
                }
                text = ServerStrings.SharingFolderNameWithSuffix(displayName, num++);
                folder.DisplayName = text;
                ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, string>(0L, "{0}: Folder exists. Recalculated folder name: {1}.", mailboxOwner, text);
                goto IL_1A;
            }
        }
예제 #3
0
        // Token: 0x06002476 RID: 9334 RVA: 0x000D3DEC File Offset: 0x000D1FEC
        internal void SendNotificationMessage()
        {
            string text = this.CapturePrintMeetingMarkup();

            text = string.Format("<div style=\"font-size: 70%; font-family:'{0}'\">{1}</div><br>{2}", Utilities.GetDefaultFontName(), LocalizedStrings.GetHtmlEncoded(PrincipalNotificationMessage.NotificationMessages[(int)this.messageType]), text);
            using (MessageItem messageItem = MessageItem.Create(this.userContext.MailboxSession, this.userContext.DraftsFolderId))
            {
                messageItem.Subject = LocalizedStrings.GetNonEncoded(PrincipalNotificationMessage.NotificationMessageTitles[(int)this.titleType]);
                BodyConversionUtilities.SetBody(messageItem, text, Markup.Html, StoreObjectType.Message, this.userContext);
                messageItem[ItemSchema.ConversationIndexTracking] = true;
                IExchangePrincipal folderOwnerExchangePrincipal = Utilities.GetFolderOwnerExchangePrincipal(this.folderId, this.userContext);
                Participant        participant = new Participant(folderOwnerExchangePrincipal);
                messageItem.Recipients.Add(participant, RecipientItemType.To);
                try
                {
                    messageItem.SendWithoutSavingMessage();
                }
                catch
                {
                    ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "Error sending principal notification message.");
                    throw;
                }
            }
            if (Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.ItemsCreated.Increment();
                OwaSingleCounters.MessagesSent.Increment();
            }
        }
        // Token: 0x06000D67 RID: 3431 RVA: 0x000596D8 File Offset: 0x000578D8
        internal override MailboxSession CreateWebPartMailboxSession(IExchangePrincipal mailBoxExchangePrincipal, CultureInfo cultureInfo, HttpRequest clientRequest)
        {
            MailboxSession mailboxSession = MailboxSession.OpenWithBestAccess(mailBoxExchangePrincipal, base.CreateADOrgPersonForWebPartUserBySid(), this.clientSecurityContext, cultureInfo, "Client=OWA;Action=WebPart + Delegate + ViaProxy");

            GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(mailboxSession, clientRequest);
            return(mailboxSession);
        }
        public void Delete(IExchangePrincipal principal)
        {
            this.CheckDisposed();
            MailboxManagementDataAdapter <TObject> .CheckPrincipal(principal);

            this.InternalDelete(principal);
        }
        public TObject Read(IExchangePrincipal principal)
        {
            this.CheckDisposed();
            MailboxManagementDataAdapter <TObject> .CheckPrincipal(principal);

            return(this.InternalRead(principal));
        }
예제 #7
0
        internal static void TryGetEHAHiddenFolderCleanupWatermarkInStore(IExchangePrincipal exchangePrincipal, string clientString, out ElcMailboxHelper.ConfigState state, out Exception exception)
        {
            Func <string, KeyValuePair <string, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value)
            {
                ElcMailboxHelper.ConfigState value2;
                if (!string.IsNullOrEmpty(value))
                {
                    if (!value.Equals("EHAHiddenFolderCleanupWatermark"))
                    {
                        value2 = ElcMailboxHelper.ConfigState.Invalid;
                    }
                    else
                    {
                        value2 = ElcMailboxHelper.ConfigState.Found;
                    }
                }
                else
                {
                    value2 = ElcMailboxHelper.ConfigState.Empty;
                }
                return(new KeyValuePair <string, ElcMailboxHelper.ConfigState>(value, value2));
            };
            string text = null;

            ElcMailboxHelper.TryGetExistingValueInStore <string>(exchangePrincipal, clientString, "EHAHiddenFolderCleanupWatermark", valueFunction, out text, out state, out exception);
        }
예제 #8
0
        internal static void TryGetExistingHoldDurationInStore(IExchangePrincipal exchangePrincipal, string clientString, out Unlimited <EnhancedTimeSpan> existingHoldDuration, out ElcMailboxHelper.ConfigState state, out Exception exception)
        {
            Func <string, KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value)
            {
                Unlimited <EnhancedTimeSpan> key = default(Unlimited <EnhancedTimeSpan>);
                ElcMailboxHelper.ConfigState value2;
                double value3;
                if (string.Compare(value, Globals.UnlimitedHoldDuration, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    key    = Unlimited <EnhancedTimeSpan> .UnlimitedValue;
                    value2 = ElcMailboxHelper.ConfigState.Found;
                }
                else if (double.TryParse(value.ToString(), out value3))
                {
                    EnhancedTimeSpan fromValue = EnhancedTimeSpan.FromMilliseconds(value3);
                    key    = fromValue;
                    value2 = ElcMailboxHelper.ConfigState.Found;
                }
                else
                {
                    value2 = ElcMailboxHelper.ConfigState.Corrupt;
                }
                return(new KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState>(key, value2));
            };

            ElcMailboxHelper.TryGetExistingValueInStore <Unlimited <EnhancedTimeSpan> >(exchangePrincipal, clientString, "LitigationHoldDuration", valueFunction, out existingHoldDuration, out state, out exception);
        }
예제 #9
0
        private bool ShouldProcessRuleInTransport(StoreDriverDeliveryEventArgsImpl deliveryEventArguments)
        {
            MailboxSession     mailboxSession = deliveryEventArguments.MailboxSession;
            IExchangePrincipal mailboxOwner   = mailboxSession.MailboxOwner;
            int serverVersion = mailboxOwner.MailboxInfo.Location.ServerVersion;

            if (serverVersion < Server.E14MinVersion)
            {
                this.evaluationContext.TraceDebug <int>("Will not process rules in transport for old server with version number {0}.", serverVersion);
                return(false);
            }
            if (string.IsNullOrEmpty(mailboxOwner.MailboxInfo.Location.ServerFqdn))
            {
                this.evaluationContext.TraceError("Server Fqdn is empty.");
                return(false);
            }
            DeliverableMailItem mailItem = deliveryEventArguments.MailItem;
            Header header  = mailItem.Message.MimeDocument.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-Unjournal-Processed");
            Header header2 = mailItem.Message.MimeDocument.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-Unjournal-ProcessedNdr");

            if (header != null || header2 != null)
            {
                this.evaluationContext.TraceError("This is an unwrapped message from legacy archive journals {0},{1}.");
                return(false);
            }
            if (MailboxRulesAgent.IsJournalNdrWithSkipRulesStamped(mailItem))
            {
                this.evaluationContext.TraceError("Message is destined to journal ndr mailbox. We dont journal messages to journal ndr mailbox as there is a potential of a loop PS 685340, skipping.");
                return(false);
            }
            return(true);
        }
예제 #10
0
        private static Uri GetFrontEndHttpServiceUrl <ServiceType>(IExchangePrincipal exchangePrincipal) where ServiceType : HttpService
        {
            if (exchangePrincipal == null)
            {
                throw new ArgumentNullException("exchangePrincipal");
            }
            if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && FrontEndLocator.IsDatacenter)
            {
                return(GlobalServiceUrls.GetExternalUrl <ServiceType>());
            }
            ServiceTopology     serviceTopology = FrontEndLocator.IsDatacenter ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 276);
            ServerVersion       serverVersion   = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion);
            int                 majorversion    = serverVersion.Major;
            IList <ServiceType> services        = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.External, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 281);
            Uri                 uri             = FrontEndLocator.FindServiceInList <ServiceType>(services);

            if (uri == null)
            {
                services = serviceTopology.FindAll <ServiceType>(exchangePrincipal, ClientAccessType.Internal, (ServiceType service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\FrontEndLocator.cs", "GetFrontEndHttpServiceUrl", 285);
                uri      = FrontEndLocator.FindServiceInList <ServiceType>(services);
            }
            if (uri != null)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <string>(0L, "[FrontEndLocator.GetFrontEndHttpServiceUrl] Found HTTP service for the specified back end server {0}.", exchangePrincipal.MailboxInfo.Location.ServerFqdn);
                return(uri);
            }
            throw new ServerNotFoundException("Unable to find proper HTTP service.");
        }
        private Uri GetE15MultitenancyOwaServiceUrl(IExchangePrincipal exchangePrincipal, IFrontEndLocator frontEndLocator)
        {
            Uri       result = null;
            Exception ex     = null;

            try
            {
                result = frontEndLocator.GetOwaUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    throw new NoExternalOwaAvailableException(ex);
                }
            }
            return(result);
        }
예제 #12
0
        public static MailboxUrls GetOwaMailboxUrls(IExchangePrincipal exchangePrincipal)
        {
            string smtpAddress = exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            string owaUrl      = MailboxUrls.GetOwaUrl(exchangePrincipal, true);

            return(new MailboxUrls(smtpAddress, owaUrl, null));
        }
예제 #13
0
 public EscalationLinkBuilder(IExchangePrincipal groupExchangePrincipal, IMailboxUrls mailboxUrls)
 {
     Util.ThrowOnNullArgument(groupExchangePrincipal, "groupExchangePrincipal");
     Util.ThrowOnNullArgument(mailboxUrls, "mailboxUrls");
     this.groupExchangePrincipal = groupExchangePrincipal;
     this.mailboxUrls            = mailboxUrls;
 }
예제 #14
0
        private void BuildGroupHeaderDiv(IExchangePrincipal groupExchangePrincipal)
        {
            this.encodedGroupDisplayName = AntiXssEncoder.HtmlEncode(groupExchangePrincipal.MailboxInfo.DisplayName, false);
            string arg = string.Format("<div style=\"font-size:21px;margin-left:19px;position:absolute;top:0px;left:0px;text-overflow: ellipsis;overflow:hidden;white-space:nowrap;max-width:95%\">{0}</div><div style=\"font-size:12px;color:#666666;margin-top:24px;margin-left:20px\">{1}</div>", this.encodedGroupDisplayName, this.GetGroupTypeMessage(groupExchangePrincipal.ModernGroupType));

            this.groupHeaderDiv = string.Format("<table cellspacing=\"0\"cellpadding=\"0\"border=\"0\" style=\"width:100%; max-width:600px\"><tbody><tr><td style=\"width:50px;height:50px;position:relative\"><div><img style=\"top: 0px; display: inline; width:50px\" src=\"{0}\"></div><div style=\"position:absolute;top:0px\"><img style=\"top: 0px; display: inline; width:50px\"src=\"service.svc/s/GetUserPhoto?email={1}&UA=0&size=HR64x64\"onerror=\"this.style.display='none'\"></div></td><td style=\"color:#333333;position:relative\">{2}</td></tr></tbody></table>", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAUpSURBVHhe7Zu9ctswEIT5/o+TmbyG0zlFZpQihYoUKlKoSMFwEUGGoQWIw99BInZmC8si8fMd7w6Ms3z98nWd1vMEoOwJQNkTgLInAGVPAMqeAJQ9ASh7AlD2BKDsCUDZE4CyJwBlTwDKngCUPQEoewJQ9gSg7AlA2ROAsicAZU8Ayp4AlD0BKHsCUPYEoOynAXD6eVovl8t6vV5XX/gMv8N32LUje3gA51/ndf172+lEXX5f6L1G9LAA3r+/izfe1zM8EUMCMFFfSdc/VzrGKB4OQM3NtxoZwlAATj9Oty2rr1EhDAWgNOfv6Xw+03E1PQwAdC499PbtjY6v5SQAmDSiJ9aDo2th16a6lzBfNr7UqFVIaw9P7fYzPsfv2XW+owCwqWzTg9oGRx5n94q5V/Rb5czRWjrXvTNJEEDJpkgLXuvc7yunICMLZM9zuy6UISgA82iVahuU3du3OXApiM0l5FpzZGnpAUCVzb8pJdJQWzSUmqPhmvJP558AtMjFe61fTeASpaYhUQ1MlNuJ3QGYHNdIdgzm3vn/roQU2eJUDrmd2B1AC9JWsU5AU2w+rlsGh02BBkCPQuguzLWm2Hysm+/J7Qk0AHrk4dCrYU3FzgM4XLYWIBsAPYQF+YvsNXZIMQA9ahP2ZOnVh4deAagV4U1RAD20rX1BaugltlCtNhQKAcDnvbS06P1DYovVOohBbD7woQC0PH9EdetCmLsC6JkC2GLhlmeQkGIn4ZcEECrCcKsTZ0x774J6qVsKCrWh1r27ITYH173ms/SKPrS7bKHWPR/72KsR6x4HMWjpUgQjBc91r3TIxvbd43yEtPz/JNz4cdvLt66bz0XwlxGtmwPMxQBomoYSo9+6ZeTFOh/m1mkR2ccAgFtFHhbhLirFTU7nwkCwbpUWbVNyB9CC9l7nE3PNJ0Ea+b6rywmGOwC4akuaGXG+SyNQkvNDrp0W3Y7wEwC4yiNXafOt8XRKC2LJ08dcC4K7+fADALikKNdeuGsULUS0CRK/Zm0/43NJxyW1geCPm6rtOn/zYQoAxmIlTwMiVFJwcX98H2kP1vjPFBhfMmdraaqOHfyCAKzvUUdSAD7DzRlZZtzLnDADUYT74Tvs2lrGXGlgbXPC3CTjI2hKn8YFi65RqPYseZpyojLFWGeKpE9zjm0wLrcxgzmq1FhIjmKPbY4lAWCFa9i9Su2msA8AN9UsYsUn7C0oSiPRBICfIoSqGZh+IDwAgGpEX/HmO8pJCfg+rqulUghIOSwQKACjgujDZJtomxPyJoqfvyFYIOYbK/KlcseT2E05vsIArLbFoHj5MGLdQs3IG0mpNcEEwxYkJhh2tA8gIjZ4zdQzokJZIVfZABDlbCKvGv1WoXXnpr1sAKxQm0JzALH0m5JumLIBsFcHqQedZxc7uOam3mwALApyDjvPKFaMURtylA3AnwB8GG35vtb6swCwQnSU/G/lrx/OKcRZAFgBRk04klg7mtMBZgFg74tip71XVK09yAJQi/4zi2WBnC4wC4A/MNzq/cuoqtUJ1QNwMLFGJOclpBwAacFye+Bnl78PsFRiAIz80TogK38fYKnkAEjuO1oHZFWjGREDYNX/sADI+7DmANiLqKO8A/JVIxjFAOYZ4EPDADjaGcCKNSTS19JiAP6A8FFFO0JhSz4BFMrfC+lhTAaAHMKa/QnKk8jfD1giEYAaj9yrif3LoEQTQKFKmxIRgBpt16uJAZC05RNAodie9AWQ+fcwr6KyoFzXf8jAL38D/RRdAAAAAElFTkSuQmCC", groupExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), arg);
        }
        internal MailboxSession GetMailboxSession(IExchangePrincipal principal)
        {
            if (principal == null)
            {
                throw new ArgumentNullException("principal");
            }
            MailboxSession mailboxSession = null;

            if (principal.MailboxInfo.IsArchive || principal.MailboxInfo.IsAggregated)
            {
                this.alternateMailboxSessions.TryGetValue(principal.MailboxInfo.MailboxGuid, out mailboxSession);
                if (mailboxSession == null)
                {
                    if (this.alternateMailboxSessions.Count == 5)
                    {
                        Guid key = Guid.Empty;
                        using (Dictionary <Guid, MailboxSession> .Enumerator enumerator = this.alternateMailboxSessions.GetEnumerator())
                        {
                            if (enumerator.MoveNext())
                            {
                                KeyValuePair <Guid, MailboxSession> keyValuePair = enumerator.Current;
                                key = keyValuePair.Key;
                            }
                        }
                        this.alternateMailboxSessions.Remove(key);
                    }
                    mailboxSession = this.CreateMailboxSession(principal);
                    this.alternateMailboxSessions.Add(principal.MailboxInfo.MailboxGuid, mailboxSession);
                }
                Utilities.ReconnectStoreSession(mailboxSession, this.userContext);
                return(mailboxSession);
            }
            throw new ArgumentException("principal is not for archive or alternate mailbox");
        }
        // Token: 0x060014AF RID: 5295 RVA: 0x0007726C File Offset: 0x0007546C
        public string GetUrl(IExchangePrincipal userIdentity, IRecipientSession recipientSession)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            string    url       = this.adUrl.GetUrl(userIdentity, recipientSession);

            this.LogTenantIdAction(this.logger, userIdentity, recipientSession);
            if (string.IsNullOrWhiteSpace(url))
            {
                this.logger.LogInfo("No SharePoint URL available in AD, using local dictionary as fallback", new object[0]);
                stopwatch.Restart();
                url = this.fallbackUrl.GetUrl(userIdentity, recipientSession);
                if (string.IsNullOrWhiteSpace(url))
                {
                    this.logger.LogInfo("No SharePoint URL available, skipping processing", new object[0]);
                    return(null);
                }
                this.logger.LogInfo("Retrieved SharePoint Url from local dictionary (used {0} seconds)", new object[]
                {
                    stopwatch.Elapsed.TotalSeconds
                });
            }
            else
            {
                this.logger.LogInfo("Retrieved SharePoint Url from AD (used {0} seconds)", new object[]
                {
                    stopwatch.Elapsed.TotalSeconds
                });
            }
            return(url);
        }
예제 #17
0
        private bool RedirectToOwaGroupPageIfPossible(IExchangePrincipal groupExchangePrincipal, CallContext callContext, HttpResponse response)
        {
            if (callContext.AccessingADUser.RecipientType != RecipientType.UserMailbox)
            {
                return(false);
            }
            IMailboxUrls mailboxUrls = new MailboxUrls(groupExchangePrincipal, false);
            string       text        = mailboxUrls.OwaUrl;

            if (string.IsNullOrEmpty(text))
            {
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("GrEsRedir", null, "GroupSubscriptionHandler.RedirectToOwaGroupPageIfPossible", string.Format("Redirection attempt failed for user {0}: couldn't obtain Owa url", callContext.AccessingADUser.PrimarySmtpAddress)));
                return(false);
            }
            if (!text.EndsWith("/"))
            {
                text += "/";
            }
            string domain = callContext.AccessingADUser.PrimarySmtpAddress.Domain;
            string text2  = text + string.Format("?realm={0}&exsvurl=1&path=/group/{1}/action/", domain, groupExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString());

            if (this.operationType == ModernGroupMembershipOperationType.Escalate)
            {
                text2 += "subscribe";
            }
            else
            {
                text2 += "unsubscribe";
            }
            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("GrEsRedir", null, "GroupSubscriptionHandler.RedirectToOwaGroupPageIfPossible", string.Format("Redirecting user {0} to Group page. Url:{1}", callContext.AccessingADUser.PrimarySmtpAddress, text2)));
            response.Redirect(text2);
            return(true);
        }
        public static string LookupEmailAddressString(Participant participant, IExchangePrincipal exchangePrincipal, bool addBrackets)
        {
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "Calling EmailAddressConverter.LookupEmailAddressString()");
            if (null == participant)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant is null.");
                throw new ArgumentNullException("participant null");
            }
            if (exchangePrincipal == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "value of exchange principal is null.");
                throw new ArgumentNullException("exchangePrincipal null");
            }
            if (string.IsNullOrEmpty(participant.EmailAddress))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant's emailAddress is null. Returning Display name instead.");
                return(EmailAddressConverter.AddBrackets(participant.DisplayName, "<{0}>", addBrackets));
            }
            if (participant.RoutingType == "EX")
            {
                Participant cachedParticipant = EmailAddressConverter.GetCachedParticipant(participant.EmailAddress);
                if (cachedParticipant != null)
                {
                    participant = cachedParticipant;
                }
            }
            if (participant.RoutingType == "SMTP")
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant's is already of Routing Type SMTP. return participant's email address.");
                return(EmailAddressConverter.AddBrackets(participant.EmailAddress, "<{0}>", addBrackets));
            }
            Participant participant2 = null;

            try
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "Fetching SmtpAddress property from MAPI");
                object obj = participant.TryGetProperty(ParticipantSchema.SmtpAddress);
                if (obj != null && obj is string)
                {
                    return(EmailAddressConverter.AddBrackets((string)obj, "<{0}>", addBrackets));
                }
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "calling TryConveryTo to convert Participant to SMTP");
                participant2 = EmailAddressConverter.DoADLookup(exchangePrincipal, participant);
            }
            catch (StoragePermanentException)
            {
                AirSyncDiagnostics.TraceError(ExTraceGlobals.CommonTracer, null, "StorePermanentException during ADLookUp while converting Participant to SMTP");
            }
            if (participant2 != null)
            {
                AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.CommonTracer, null, "Convert to SMTP successful. Returned EmailAddress {0} , Format {1}", participant2.EmailAddress, "<{0}>");
                if (participant.RoutingType == "EX")
                {
                    EmailAddressConverter.CacheParticipant(participant.EmailAddress, participant2);
                }
                return(EmailAddressConverter.AddBrackets(participant2.EmailAddress, "<{0}>", addBrackets));
            }
            AirSyncDiagnostics.TraceDebug <string, string, string>(ExTraceGlobals.CommonTracer, null, "Could not convert participant to SMTP routing type. Returned RoutingType:{0}, EmailAddress:{1} and Format: {2}", participant.RoutingType, participant.EmailAddress, "[{0}]");
            return(EmailAddressConverter.AddBrackets(participant.RoutingType + ":" + participant.EmailAddress, "[{0}]", addBrackets));
        }
예제 #19
0
        private static CobaltStore CreateCobaltStore(IExchangePrincipal exchangePrincipal, Attachment attachment, WacRequest wacRequest, CachedAttachmentInfo attachmentInfo)
        {
            if (exchangePrincipal == null)
            {
                throw new ArgumentException("exchangePrincipal");
            }
            if (exchangePrincipal.MailboxInfo.IsRemote)
            {
                throw new OwaInvalidRequestException("Remote mailboxes are not supported.");
            }
            Guid        objectGuid         = exchangePrincipal.MailboxInfo.MailboxDatabase.ObjectGuid;
            bool        diagnosticsEnabled = WacConfiguration.Instance.DiagnosticsEnabled;
            MdbCache    instance           = MdbCache.GetInstance();
            string      path          = instance.GetPath(objectGuid);
            string      correlationId = HttpContext.Current.Request.Headers["X-WOPI-CorrelationID"];
            CobaltStore store         = new CobaltStore(path, objectGuid.ToString(), correlationId, diagnosticsEnabled, WacConfiguration.Instance.BlobStoreMemoryBudget);

            using (Stream contentStream = ((StreamAttachment)attachment).GetContentStream(PropertyOpenMode.ReadOnly))
            {
                store.Save(contentStream);
            }
            store.Saver.Initialize((string)wacRequest.MailboxSmtpAddress, wacRequest.ExchangeSessionId, WacConfiguration.Instance.AutoSaveInterval, delegate
            {
                using (Stream documentStream = store.GetDocumentStream())
                {
                    WacRequestHandler.ReplaceAttachmentContent(documentStream, wacRequest);
                }
                return(true);
            }, delegate(Exception exception)
            {
                store.SaveFailed(exception);
            });
            return(store);
        }
예제 #20
0
        protected override bool InternalValidateCompatibility(Folder folderToShare)
        {
            IExchangePrincipal mailboxOwner    = folderToShare.Session.MailboxOwner;
            SharingDataType    sharingDataType = SharingDataType.FromContainerClass(folderToShare.ClassName);

            return(sharingDataType == SharingDataType.Calendar && mailboxOwner is IUserPrincipal && ((IUserPrincipal)mailboxOwner).NetId != null && mailboxOwner.GetConfiguration().DataStorage.XOWAConsumerSharing.Enabled);
        }
 // Token: 0x06000158 RID: 344 RVA: 0x000092F8 File Offset: 0x000074F8
 private bool NeedToLoadCache(IExchangePrincipal mailboxOwner, Dictionary <OrganizationId, bool> orgsToRefresh)
 {
     if (!this.allInPlaceHoldConfiguration.ContainsKey(mailboxOwner.MailboxInfo.OrganizationId))
     {
         this.TraceInformation("Need to load cache because org not found in cache " + mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
         DiscoveryHoldQueryCache.Tracer.TraceDebug <DiscoveryHoldQueryCache, OrganizationId, string>((long)this.GetHashCode(), "{0}: Need to load discoveryhold cache because orgsLoaded doesn't contain this org. OrgId: {1}. Mailbox: {2}", this, mailboxOwner.MailboxInfo.OrganizationId, mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
         return(true);
     }
     if (orgsToRefresh.ContainsKey(mailboxOwner.MailboxInfo.OrganizationId) && orgsToRefresh[mailboxOwner.MailboxInfo.OrganizationId])
     {
         this.TraceInformation("Need to load cache because orgsToRefresh was marked as true " + mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
         DiscoveryHoldQueryCache.Tracer.TraceDebug <DiscoveryHoldQueryCache, OrganizationId, string>((long)this.GetHashCode(), "{0}: Need to load discoveryhold cache because orgsToRefresh says so. OrgId: {1}. Mailbox: {2}", this, mailboxOwner.MailboxInfo.OrganizationId, mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
         return(true);
     }
     lock (this.runNowMailboxesLock)
     {
         if (this.runNowCalled && this.runNowMailboxes.Contains(mailboxOwner.MailboxInfo.MailboxGuid))
         {
             this.TraceInformation("Need to load cache because runnow was called for " + mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
             DiscoveryHoldQueryCache.Tracer.TraceDebug <DiscoveryHoldQueryCache, OrganizationId, string>((long)this.GetHashCode(), "{0}: Need to load discoveryhold cache because Run now was called for this mailbox. OrgId: {1}. Mailbox: {2}", this, mailboxOwner.MailboxInfo.OrganizationId, mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
             return(true);
         }
     }
     return(false);
 }
 private string GetEcpUrl()
 {
     if (AsyncOperationNotificationEmail.ecpUrl == null)
     {
         Uri uri = null;
         IExchangePrincipal mailbox = this.provider.Mailbox;
         try
         {
             if (AsyncOperationNotificationEmail.discoveryEcpExternalUrl == null)
             {
                 AsyncOperationNotificationEmail.discoveryEcpExternalUrl = (Func <IExchangePrincipal, Uri>)Delegate.CreateDelegate(typeof(Func <IExchangePrincipal, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.FrontEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetFrontEndEcpUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                 {
                     typeof(IExchangePrincipal)
                 }, null));
             }
             uri = AsyncOperationNotificationEmail.discoveryEcpExternalUrl(mailbox);
         }
         catch (Exception)
         {
         }
         if (uri != null && uri.IsAbsoluteUri)
         {
             AsyncOperationNotificationEmail.ecpUrl = uri.AbsoluteUri;
         }
     }
     return(AsyncOperationNotificationEmail.ecpUrl ?? string.Empty);
 }
예제 #23
0
 internal bool TryUpdateSourceLocation(IExchangePrincipal exchangePrincipal, string elementName, ExtensionData extensionData, out Exception exception, ExtensionDataHelper.TryModifySourceLocationDelegate tryModifySourceLocationDelegate)
 {
     exception = null;
     foreach (object obj in this.xmlDoc.SelectNodes(this.GetOweXpath(elementName), this.namespaceManager))
     {
         XmlNode      xmlNode      = (XmlNode)obj;
         XmlAttribute xmlAttribute = xmlNode.Attributes["DefaultValue"];
         if (!tryModifySourceLocationDelegate(exchangePrincipal, xmlAttribute, extensionData, out exception))
         {
             return(false);
         }
         if (xmlNode.ChildNodes != null)
         {
             foreach (object obj2 in xmlNode.ChildNodes)
             {
                 XmlNode xmlNode2 = (XmlNode)obj2;
                 if (this.IsExpectedOweNamespace(xmlNode2.NamespaceURI) && string.Equals(xmlNode2.LocalName, "Override", StringComparison.Ordinal))
                 {
                     xmlAttribute = xmlNode2.Attributes["Value"];
                     if (!tryModifySourceLocationDelegate(exchangePrincipal, xmlAttribute, extensionData, out exception))
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }
예제 #24
0
        public EncryptionResults Encrypt(IExchangePrincipal mailboxOwner, ExternalUserCollection externalUserCollection, string[] recipients, string sender, string containerClass, string folderId, IFrontEndLocator frontEndLocator, string domainController = null)
        {
            IRecipientSession session = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(domainController, true, ConsistencyMode.IgnoreInvalid, null, mailboxOwner.MailboxInfo.OrganizationId.ToADSessionSettings(), ConfigScopes.TenantSubTree, 121, "Encrypt", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs");

            ValidRecipient[] recipients2 = Array.ConvertAll <string, ValidRecipient>(recipients, (string recipient) => new ValidRecipient(recipient, session.FindByProxyAddress(new SmtpProxyAddress(recipient, false))));
            return(this.Encrypt(mailboxOwner, session, externalUserCollection, recipients2, sender, containerClass, folderId, frontEndLocator));
        }
        private string GetE15MultitenancyOwaServiceUrl(IExchangePrincipal exchangePrincipal)
        {
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                uri = FrontEndLocator.GetFrontEndOwaUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    throw new NoExternalOwaAvailableException(ex);
                }
            }
            return(uri.ToString());
        }
예제 #26
0
        private static bool TryProcessUnprotectedAttachment(IExchangePrincipal exchangePrincipal, Item item, StreamAttachment streamAttachment, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            if (openMode == PropertyOpenMode.Modify)
            {
                item.OpenAsReadWrite();
            }
            bool result;

            using (Stream contentStream = streamAttachment.GetContentStream(openMode))
            {
                bool flag = WacUtilities.IsContentProtected(streamAttachment.FileName, contentStream);
                if (flag)
                {
                    result = false;
                }
                else
                {
                    attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, false);
                    if (openMode == PropertyOpenMode.Modify)
                    {
                        item.Save(SaveMode.NoConflictResolution);
                    }
                    result = true;
                }
            }
            return(result);
        }
예제 #27
0
        public static string DiscoverEwsUrl(IExchangePrincipal mailbox)
        {
            Uri uri;

            if (!EwsHelper.IsDatacenter)
            {
                EwsHelper.Tracer.TraceDebug(0L, "Not running in DC. Will use ServiceTopology to discover the url");
                ServerVersion mailboxVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                IList <WebServicesService> list;
                try
                {
                    ClientAccessType clientAccessType = EwsHelper.ClientAccessType;
                    EwsHelper.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType);
                    ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 119);
                    list = currentServiceTopology.FindAll <WebServicesService>(mailbox, clientAccessType, delegate(WebServicesService service)
                    {
                        ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                        return(mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor <= serverVersion.Minor && !service.IsOutOfService);
                    }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 121);
                }
                catch (LocalizedException arg)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailbox, arg);
                    return(null);
                }
                if (list.Count == 0)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailbox);
                    return(null);
                }
                WebServicesService webServicesService;
                if ((webServicesService = list.FirstOrDefault((WebServicesService service) => string.Equals(service.ServerFullyQualifiedDomainName, mailbox.MailboxInfo.Location.ServerFqdn, StringComparison.OrdinalIgnoreCase) && service.Url != null)) == null && (webServicesService = list.FirstOrDefault(delegate(WebServicesService service)
                {
                    ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                    return(service.Url != null && mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor == serverVersion.Minor);
                })) == null)
                {
                    webServicesService = list.FirstOrDefault((WebServicesService service) => service.Url != null);
                }
                WebServicesService webServicesService2 = webServicesService;
                uri = ((webServicesService2 == null) ? null : webServicesService2.Url);
                goto IL_1EA;
            }
            EwsHelper.Tracer.TraceDebug(0L, "Running in DC. Will use BackEndLocator to discover the url");
            if (EwsHelper.discoveryEwsInternalUrl == null)
            {
                EwsHelper.discoveryEwsInternalUrl = (Func <IMailboxInfo, Uri>)Delegate.CreateDelegate(typeof(Func <IMailboxInfo, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetBackEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                {
                    typeof(IMailboxInfo)
                }, null));
            }
            uri = EwsHelper.discoveryEwsInternalUrl(mailbox.MailboxInfo);
IL_1EA:
            if (!(uri == null))
            {
                return(uri.ToString());
            }
            return(null);
        }
예제 #28
0
        public MailboxUrls(IExchangePrincipal exchangePrincipal, bool failOnError = false)
        {
            string smtpAddress = exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            string owaUrl      = MailboxUrls.GetOwaUrl(exchangePrincipal, failOnError);
            string ewsUrl      = MailboxUrls.GetEwsUrl(exchangePrincipal, failOnError);

            this.InitializeUrls(smtpAddress, owaUrl, ewsUrl);
        }
 // Token: 0x06000152 RID: 338 RVA: 0x00008BC0 File Offset: 0x00006DC0
 private void LogDiscoveryQueryLoadFailure(IExchangePrincipal mailboxOwner, ExEventLog.EventTuple message, Exception ex)
 {
     Globals.Logger.LogEvent(message, null, new object[]
     {
         mailboxOwner,
         (ex == null) ? string.Empty : ex.ToString()
     });
 }
 private string GetOwaServiceUrl(IExchangePrincipal exchangePrincipal)
 {
     if (exchangePrincipal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && this.IsMultitenancyEnabled)
     {
         return(this.GetE15MultitenancyOwaServiceUrl(exchangePrincipal));
     }
     return(this.GetEnterpriseOrE14OwaServiceUrl(exchangePrincipal));
 }