Esempio n. 1
0
        public void Distribute(List <NotificationPayloadBase> payloads, string subscriptionContextKey, string subscriptionId)
        {
            if (payloads != null && payloads.Count > 0)
            {
                IEnumerable <IDestinationInfo> destinations = this.remoteNotificationManager.GetDestinations(subscriptionContextKey, subscriptionId);
                int num = 0;
                lock (this.syncRoot)
                {
                    foreach (IDestinationInfo destinationInfo in destinations)
                    {
                        num++;
                        this.AddToQueue(destinationInfo, payloads);
                    }
                }
                OwaServerTraceLogger.AppendToLog(new PusherLogEvent(PusherEventType.Distribute)
                {
                    OriginationUserContextKey = subscriptionContextKey,
                    DestinationCount          = num,
                    PayloadCount = payloads.Count
                });
                if (ExTraceGlobals.NotificationsCallTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    IEnumerable <string> values = from destination in destinations
                                                  select string.Format("[Destination:{0}; ChannelId:{1}]", destination.Destination, string.Join(",", destination.ChannelIds));

                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Pusher - Distribute notification from mailbox referred by user context key {0} to destinations {1}.", subscriptionContextKey, string.Join(",", values));
                }
            }
        }
Esempio n. 2
0
 public void HandleNotification(BrokerNotification notification)
 {
     try
     {
         if (!base.IsDisposed)
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 this.HandleNotificatonInternal(notification);
             });
         }
     }
     catch (GrayException handledException)
     {
         OwaServerTraceLogger.AppendToLog(new BrokerLogEvent
         {
             Principal            = this.UserContext.ExchangePrincipal,
             UserContextKey       = this.UserContext.Key.ToString(),
             SubscriptionId       = this.SubscriptionId,
             BrokerSubscriptionId = this.BrokerSubscriptionId,
             EventName            = "HandleNotification",
             HandledException     = handledException
         });
     }
 }
        // Token: 0x0600097C RID: 2428 RVA: 0x00020BB4 File Offset: 0x0001EDB4
        internal static void RecordException(RequestContext requestContext, Exception exception)
        {
            HttpContext httpContext = requestContext.HttpContext;

            ErrorHandlerUtilities.LogExceptionCodeInIIS(requestContext, exception);
            RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;

            if (getRequestDetailsLogger != null && getRequestDetailsLogger.ActivityScope != null)
            {
                getRequestDetailsLogger.ActivityScope.SetProperty(ServiceCommonMetadata.GenericErrors, exception.ToString());
            }
            else
            {
                ExTraceGlobals.CoreTracer.TraceDebug <bool, bool, Exception>(0L, "Couldn't append exception to server log. Logger is null: {0}, logger.ActivityScope is null: {1}, Exception: {2}", getRequestDetailsLogger == null, getRequestDetailsLogger != null && getRequestDetailsLogger.ActivityScope == null, exception);
            }
            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("ErrorHandlerUtilities", null, "RecordException", exception.ToString()));
            try
            {
                Exception baseException = ErrorHandlerUtilities.GetBaseException(exception);
                httpContext.Response.Headers.Add("X-OWA-Error", baseException.GetType().FullName);
                if (baseException is WrongServerException)
                {
                    string value = ((WrongServerException)baseException).RightServerToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        httpContext.Response.Headers.Add(WellKnownHeader.XDBMountedOnServer, value);
                    }
                }
            }
            catch (HttpException arg)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <HttpException, Exception>(0L, "Failed to add error headers to the response. {0}. Original exception: {1}", arg, exception);
            }
        }
Esempio n. 4
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);
        }
 private void ProcessKeepAlive(MapiNotificationsLogEvent logEvent)
 {
     try
     {
         if (!base.IsDisposed)
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 this.HandlePendingGetTimerCallback(logEvent);
             });
         }
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string, string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.KeepAlive for {0} encountered an exception: {1}", base.GetType().Name, ex.ToString());
         logEvent.HandledException = ex;
     }
     finally
     {
         if (this.ShouldLog(logEvent))
         {
             OwaServerTraceLogger.AppendToLog(logEvent);
         }
     }
 }
 // Token: 0x06001A00 RID: 6656 RVA: 0x0005DE80 File Offset: 0x0005C080
 protected RmsTemplateType[] GetRmsTemplates(OrganizationId organizationId, CultureInfo userCulture)
 {
     try
     {
         ExTraceGlobals.IrmTracer.TraceDebug <OrganizationId, CultureInfo>((long)this.GetHashCode(), "Getting rms templates for organization {0} with culture {1}", organizationId, userCulture);
         IEnumerable <RmsTemplate>     source  = this.AcquireRmsTemplates(organizationId);
         IEnumerable <RmsTemplateType> source2 = from mesrTemplate in source
                                                 select new RmsTemplateType(mesrTemplate.Id.ToString(), mesrTemplate.GetName(userCulture), mesrTemplate.GetDescription(userCulture)) into template
                                                 orderby template.Name
                                                 select template;
         string arg = string.Join(",", from template in source2
                                  select string.Format(userCulture, "{0}:{1}", new object[]
         {
             template.Id,
             template.Name
         }));
         ExTraceGlobals.IrmTracer.TraceDebug <string>((long)this.GetHashCode(), "Loaded templates= {0}", arg);
         return(source2.ToArray <RmsTemplateType>());
     }
     catch (OwaThrottlingException)
     {
         throw;
     }
     catch (Exception ex)
     {
         OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_RmsTemplateLoadFailure, organizationId.ToString(), new object[]
         {
             ex
         });
         OwaServerTraceLogger.AppendToLog(new RmsLoadingLogEvent(organizationId, ex));
     }
     return(null);
 }
Esempio n. 7
0
 // Token: 0x0600199F RID: 6559 RVA: 0x0005A6D4 File Offset: 0x000588D4
 internal static void SendPendingGetNotification(UserContext userContext, CreateAttachmentNotificationPayload result, string channelId)
 {
     if (!userContext.IsDisposed)
     {
         OwaServerTraceLogger.AppendToLog(new TraceLogEvent("AttachmentOperationCompletedNotification", userContext, "SendPendingGetNotification", "Attachment operation completed with result code: " + result.ResultCode.ToString()));
         CreateAttachmentNotifier createAttachmentNotifier = new CreateAttachmentNotifier(userContext, result.SubscriptionId);
         try
         {
             createAttachmentNotifier.RegisterWithPendingRequestNotifier();
             createAttachmentNotifier.Payload = result;
             if (userContext.IsGroupUserContext)
             {
                 bool flag;
                 RemoteNotificationManager.Instance.Subscribe(userContext.Key.ToString(), userContext.MailboxIdentity.PrimarySmtpAddress.ToString(), createAttachmentNotifier.SubscriptionId, channelId, userContext.LogonIdentity.GetOWAMiniRecipient().PrimarySmtpAddress.ToString(), NotificationType.CreateAttachmentNotification, out flag);
             }
             createAttachmentNotifier.PickupData();
         }
         finally
         {
             createAttachmentNotifier.UnregisterWithPendingRequestNotifier();
             if (userContext.IsGroupUserContext)
             {
                 RemoteNotificationManager.Instance.UnSubscribe(userContext.Key.ToString(), createAttachmentNotifier.SubscriptionId, channelId, userContext.LogonIdentity.GetOWAMiniRecipient().PrimarySmtpAddress.ToString());
             }
         }
     }
 }
Esempio n. 8
0
        protected override bool InternalExecute()
        {
            UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true);

            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("CancelAttachment.InternalExecute", userContext, "InternalExecute", string.Format("Attempting to cancel. CancellationId: {0}", this.cancellationId)));
            return(userContext.CancelAttachmentManager.CancelAttachment(this.cancellationId, 30000));
        }
        // Token: 0x06001BD6 RID: 7126 RVA: 0x0006BC30 File Offset: 0x00069E30
        private List <SubscriptionResponseData> InternalSubscribe(IMailboxContext userContext)
        {
            List <SubscriptionResponseData> list = new List <SubscriptionResponseData>();

            SubscriptionData[] array = this.subscriptionData;
            for (int i = 0; i < array.Length; i++)
            {
                SubscriptionData subscription   = array[i];
                string           subscriptionId = subscription.SubscriptionId;
                try
                {
                    Stopwatch notificationLatency     = Stopwatch.StartNew();
                    SubscriptionResponseData response = new SubscriptionResponseData(subscriptionId, true);
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        if (subscription.Parameters == null)
                        {
                            throw new ArgumentNullException("Subscription data parameters cannot be null");
                        }
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug(0L, string.Format("[SubscribeToNotificationBase.InternalCreateASubscription] Creating subscription of type {0}.", subscription.Parameters.NotificationType));
                        this.metricType             = SubscribeToNotificationMetadata.Other;
                        NameValueCollection headers = this.CallContext.HttpContext.Request.Headers;
                        bool flag = RemoteRequestProcessor.IsRemoteRequest(headers);
                        if (flag && string.IsNullOrWhiteSpace(subscription.Parameters.ChannelId))
                        {
                            throw new OwaInvalidRequestException("ChannelId is null or empty. ChannelId is required for remote notification subscribe requests.");
                        }
                        this.InternalCreateASubscription(userContext, subscription, flag);
                        if (flag)
                        {
                            bool subscriptionExists;
                            RemoteNotificationManager.Instance.Subscribe(userContext.Key.ToString(), userContext.ExchangePrincipal.MailboxInfo.MailboxGuid.ToString(), subscription.SubscriptionId, subscription.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(headers), subscription.Parameters.NotificationType, headers["X-OWA-Test-RemoteNotificationEndPoint"], out subscriptionExists);
                            response.SubscriptionExists = subscriptionExists;
                        }
                        if (!this.latenciesPerNotificationType.ContainsKey(this.metricType))
                        {
                            this.latenciesPerNotificationType.Add(this.metricType, 0);
                        }
                        Dictionary <SubscribeToNotificationMetadata, int> dictionary;
                        SubscribeToNotificationMetadata key;
                        (dictionary = this.latenciesPerNotificationType)[key = this.metricType] = dictionary[key] + (int)notificationLatency.ElapsedMilliseconds;
                    });
                    list.Add(response);
                }
                catch (GrayException ex)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceError <NotificationType, string, string>((long)this.GetHashCode(), "[SubscribeToNotificationBase.InternalSubscribe]: Exception thrown while creating subscription of type [{0}] with id {1}. Error: {2}", subscription.Parameters.NotificationType, subscriptionId, ex.ToString());
                    OwaServerTraceLogger.AppendToLog(new TraceLogEvent("SubErr", userContext, "SubscribeToNotificationBase.InternalSubscribe", ex.ToString()));
                    list.Add(new SubscriptionResponseData(subscriptionId, false)
                    {
                        ErrorInfo = ((ex.InnerException != null) ? ex.InnerException.Message : ex.Message)
                    });
                }
            }
            foreach (KeyValuePair <SubscribeToNotificationMetadata, int> keyValuePair in this.latenciesPerNotificationType)
            {
                base.CallContext.ProtocolLog.Set(keyValuePair.Key, keyValuePair.Value);
            }
            return(list);
        }
        // Token: 0x06000282 RID: 642 RVA: 0x000097BC File Offset: 0x000079BC
        private void ParseNetZoneData(XmlReader xmlReader, WacDiscoveryResultBase result)
        {
            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.EndElement && string.Equals("net-zone", xmlReader.Name))
                {
                    return;
                }
                if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.Equals("action"))
                {
                    string attribute  = xmlReader.GetAttribute("name");
                    string attribute2 = xmlReader.GetAttribute("requires");
                    string text       = "." + xmlReader.GetAttribute("ext");
                    string attribute3 = xmlReader.GetAttribute("urlsrc");
                    OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(string.Format(CultureInfo.InvariantCulture, "Extension: {0,-10} Verb: {1,-20} Requires {2,-30} Url: {3}", new object[]
                    {
                        text,
                        attribute,
                        attribute2,
                        attribute3
                    })));
                    if (attribute != null)
                    {
                        if (attribute.Equals("view") && string.IsNullOrEmpty(attribute2))
                        {
                            string text2;
                            if (result.TryGetViewUrlForFileExtension(text, "this parameter is not needed here", out text2))
                            {
                                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(string.Format(CultureInfo.InvariantCulture, "Overwriting {0}", new object[]
                                {
                                    text2
                                })));
                            }
                            result.AddViewMapping(text, attribute3);
                            if (text == ".doc")
                            {
                                result.AddViewMapping(".rtf", attribute3);
                            }
                        }
                        else if (attribute.Equals("edit"))
                        {
                            string text2;
                            if (result.TryGetEditUrlForFileExtension(text, "this parameter is not needed here", out text2))
                            {
                                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(string.Format(CultureInfo.InvariantCulture, "Overwriting {0}", new object[]
                                {
                                    text2
                                })));
                            }
                            result.AddEditMapping(text, attribute3);
                        }
                    }
                }
            }
            WacDiscoveryFailureException ex = new WacDiscoveryFailureException("Unexpected end of wac discovery file");

            result = new WacDiscoveryResultFailure(ex);
            throw ex;
        }
 // Token: 0x0600016B RID: 363 RVA: 0x00005B38 File Offset: 0x00003D38
 public void CreateAttachmentCancelled(string cancellationId)
 {
     OwaServerTraceLogger.AppendToLog(new TraceLogEvent("CancelAttachmentManager.CreateAttachmentCancelled", this.userContext, "CreateAttachmentCancelled", string.Format("CreateAttachment cancelled for CancellationId: {0}.", cancellationId)));
     if (cancellationId == null)
     {
         return;
     }
     this.CancellationItems[cancellationId].AttachmentCompletedEvent.Set();
 }
 // Token: 0x0600016C RID: 364 RVA: 0x00005B88 File Offset: 0x00003D88
 public void CreateAttachmentCompleted(string cancellationId, AttachmentIdType attachmentId)
 {
     OwaServerTraceLogger.AppendToLog(new TraceLogEvent("CancelAttachmentManager.CreateAttachmentCompleted", this.userContext, "CreateAttachmentCompleted", string.Format("CreateAttachment completed for AttachmentId: {0}, CancellationId: {1}.", (attachmentId == null) ? "Null" : attachmentId.Id, string.IsNullOrEmpty(cancellationId) ? "Null" : cancellationId)));
     if (cancellationId == null)
     {
         return;
     }
     this.CancellationItems[cancellationId].AttachmentId = attachmentId;
     this.CancellationItems[cancellationId].AttachmentCompletedEvent.Set();
 }
Esempio n. 13
0
        public void ProcessRequest(HttpContext context)
        {
            Exception ex = null;

            this.Initialize(context.Response);
            try
            {
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("GrEsProcReq", null, "GroupSubscriptionHandler.ProcessRequest", "Started processing request: " + context.Request.RawUrl));
                OWAService         owaservice  = new OWAService();
                CallContext        callContext = GroupSubscriptionHandler.CreateAndSetCallContext(context);
                IExchangePrincipal mailboxIdentityPrincipal = callContext.MailboxIdentityPrincipal;
                try
                {
                    this.SetPreferredCulture(mailboxIdentityPrincipal);
                    this.ValidateRequestMadeToGroupMailbox(callContext);
                    string action = this.ValidateAndGetActionString(context);
                    this.ParseEscalateOperationType(action);
                    if (this.RedirectToOwaGroupPageIfPossible(mailboxIdentityPrincipal, callContext, context.Response))
                    {
                        return;
                    }
                    this.BuildGroupHeaderDiv(mailboxIdentityPrincipal);
                    SetModernGroupMembershipJsonRequest modernGroupMembership = new SetModernGroupMembershipJsonRequest
                    {
                        GroupSmtpAddress = mailboxIdentityPrincipal.MailboxInfo.PrimarySmtpAddress.ToString(),
                        OperationType    = this.operationType.Value
                    };
                    SetModernGroupMembershipJsonResponse ewsresponse = owaservice.SetModernGroupMembership(modernGroupMembership);
                    this.ValidateEwsResponse(ewsresponse);
                    this.WriteSuccessfulResponse(context);
                }
                finally
                {
                    GroupSubscriptionHandler.DisposeContext(callContext);
                }
            }
            catch (ExceededMaxSubscribersException)
            {
                this.WriteErrorResponse(context, ClientStrings.GroupSubscriptionPageSubscribeFailedMaxSubscribers(this.encodedGroupDisplayName));
            }
            catch (NotAMemberException)
            {
                this.WriteErrorResponse(context, ClientStrings.GroupSubscriptionPageSubscribeFailedNotAMember(this.encodedGroupDisplayName));
            }
            catch (Exception ex2)
            {
                this.WriteErrorResponse(context, ClientStrings.GroupSubscriptionPageRequestFailedInfo);
                ex = ex2;
            }
            if (ex != null)
            {
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("GrEsProcReq", null, "GroupSubscriptionHandler.ProcessRequest", "Error processing request: " + ex.ToString()));
            }
        }
Esempio n. 14
0
        public AttachmentDataProvider GetProvider(CallContext callContext, string id)
        {
            this.EnsureAttachmentDataProviders(callContext);
            if (this.dataProviders.ContainsKey(id))
            {
                return(this.dataProviders[id]);
            }
            ExTraceGlobals.DocumentsTracer.TraceDebug <string>((long)this.GetHashCode(), "Provider with id {0} was not found, getting the default upload provider", id);
            UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);

            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("ADPM.GP", userContext, "GetProvider", string.Format("Provider with id {0} was not found", id)));
            return(this.GetDefaultUploadDataProvider(callContext));
        }
        // Token: 0x06000281 RID: 641 RVA: 0x00009758 File Offset: 0x00007958
        private bool ParseUntilExternalHttpsNetZoneNode(XmlReader xmlReader)
        {
            string text = "external-https";

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element && string.Equals("net-zone", xmlReader.Name) && string.Equals(text, xmlReader.GetAttribute("name")))
                {
                    return(true);
                }
            }
            OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent("Did not find a Net-Zone element with name=" + text));
            return(false);
        }
Esempio n. 16
0
 private static async Task SendRequest(HttpWebRequest webRequest, string payload, string destination, int payloadCount)
 {
     OwaServerTraceLogger.AppendToLog(new PusherLogEvent(PusherEventType.Push)
     {
         Destination  = destination,
         PayloadCount = payloadCount
     });
     byte[] payloadBytes = Encoding.UTF8.GetBytes(payload);
     using (Stream requestStream = await webRequest.GetRequestStreamAsync())
     {
         requestStream.Write(payloadBytes, 0, payloadBytes.Length);
         requestStream.Close();
     }
 }
Esempio n. 17
0
        private static void HandleWebException(WebException webException, PusherQueue queue)
        {
            OwaServerTraceLogger.AppendToLog(new PusherLogEvent(PusherEventType.PushFailed)
            {
                Destination      = queue.DestinationUrl,
                HandledException = webException
            });
            HttpWebResponse httpWebResponse = webException.Response as HttpWebResponse;

            if (httpWebResponse != null)
            {
                httpWebResponse.Close();
            }
        }
        // Token: 0x06001158 RID: 4440 RVA: 0x000426A0 File Offset: 0x000408A0
        internal override void Initialize()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtml loading begin");
            IntPtr value = NativeMethods.LoadLibrary(Path.GetFullPath(Path.Combine(ExchangeSetupContext.BinPath, "SafeHtmlNativeWrapper.dll")));

            if (value == IntPtr.Zero)
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceError(0L, "OwaApplication.Initialize: Failed to load SafeHtmlNativeWrapper.");
                Global.SafeHtmlLoaded = false;
            }
            else
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtmlNativeWrapper loaded successfully.");
                Global.SafeHtmlLoaded = true;
            }
            SafeHtml.Initialize(ExchangeSetupContext.BinPath + Path.DirectorySeparatorChar);
            ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtml loading finished");
            Global.InitializeSettingsFromWebConfig();
            int workerThreads;
            int num;

            ThreadPool.GetMinThreads(out workerThreads, out num);
            int configIntValue = AppConfigLoader.GetConfigIntValue("ThreadPoolMinIOCPThreads", 0, int.MaxValue, 3 * Environment.ProcessorCount);

            ThreadPool.SetMinThreads(workerThreads, configIntValue);
            OwaApplication.InitializeApplicationCaches();
            RequestDetailsLogger.ApplicationType = LoggerApplicationType.Owa;
            OwaClientLogger.Initialize();
            OwaClientTraceLogger.Initialize();
            OwaServerLogger.Initialize();
            OwaServerTraceLogger.Initialize();
            SettingOverrideSync.Instance.Start(true);
            LoggerSettings.MaxAppendableColumnLength   = null;
            LoggerSettings.ErrorMessageLengthThreshold = null;
            Global.ResponseShapeResolver = new OwaResponseShapeResolver();
            Global.EwsClientMailboxSessionCloningHandler = new EwsClientMailboxSessionCloningHandler(UserContextManager.GetClonedMailboxSession);
            Global.DefaultMapiClientType             = "Client=OWA";
            MailboxSession.DefaultFoldersToForceInit = OwaApplication.foldersToForceInitialize;
            UserContextManager.Initialize();
            if (Globals.OwaIsNoRecycleEnabled)
            {
                OwaVersionId.InitializeOwaVersionReadingTimer();
            }
            KillBitTimer.Singleton.Start();
            KillbitWatcher.TryWatch(new KillbitWatcher.ReadKillBitFromFileCallback(KillBitHelper.ReadKillBitFromFile));
            OwaServerLogger.AppendToLog(new OwaAppStartLogEvent((double)stopwatch.ElapsedMilliseconds));
        }
Esempio n. 19
0
 internal void RetireMailboxSessionForGroupMailbox()
 {
     if (!this.IsGroupUserContext)
     {
         throw new InvalidOperationException("RetireMailboxSessionForGroupMailbox is only supported for group mailbox");
     }
     try
     {
         base.InternalRetireMailboxSession();
     }
     catch (LocalizedException ex)
     {
         OwaServerTraceLogger.AppendToLog(new TraceLogEvent("RetUcMbSess", this, "UserContext.RetireMailboxSessionForGroupMailbox", ex.ToString()));
     }
 }
        // Token: 0x06001BFB RID: 7163 RVA: 0x0006D404 File Offset: 0x0006B604
        private static GetMailTipsResponseMessage InvokeGetMailTipsSynchronous(UserContext userContext, GetMailTipsRequest request)
        {
            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UpdateAttachmentPermissions-GetMailTipsBegin", userContext, "InvokeGetMailTipsSynchronous", "Starting Synchronous call to GetMailTips"));
            GetMailTipsJsonRequest getMailTipsJsonRequest = new GetMailTipsJsonRequest();

            getMailTipsJsonRequest.Body = request;
            OWAService   owaservice  = new OWAService();
            IAsyncResult asyncResult = owaservice.BeginGetMailTips(getMailTipsJsonRequest, null, null);

            asyncResult.AsyncWaitHandle.WaitOne();
            GetMailTipsResponseMessage body = owaservice.EndGetMailTips(asyncResult).Body;

            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UpdateAttachmentPermissions-GetMailTipsEnd", userContext, "InvokeGetMailTipsSynchronous", "Ending Synchronous call to GetMailTips"));
            return(body);
        }
Esempio n. 21
0
        private static object InvokeMethod(HttpRequest request, MethodInfo methodInfo, object obj, params object[] parameters)
        {
            object result;

            try
            {
                result = methodInfo.Invoke(obj, parameters);
            }
            catch (ArgumentException ex)
            {
                string arg = OwaServiceMethodDispatcher.TryGetJsonContentFromStream(request.InputStream, 2048);
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OwaServiceMethodDispatcher", null, "InvokeMethod", string.Format("Method: {0} Exception: {1}, JSON: {2}", methodInfo.Name, ex.Message, arg)));
                throw new OwaMethodArgumentException(string.Format("Invalid argument used to call method {0}", methodInfo.Name), ex);
            }
            return(result);
        }
 internal virtual void HandleConnectionDroppedNotification(Notification notification)
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.HandleConnectionDroppedNotification. Type: {0}", base.GetType().Name);
     lock (this.syncRoot)
     {
         MapiNotificationsLogEvent logEvent = new MapiNotificationsLogEvent(this.UserContext.ExchangePrincipal, this.UserContext.Key.ToString(), this, this.EventPrefix + "HandleConnectionDroppedNotification");
         if (!this.IsDisposed_Reentrant)
         {
             this.needReinitSubscriptions = true;
         }
         if (this.ShouldLog(logEvent))
         {
             OwaServerTraceLogger.AppendToLog(logEvent);
         }
     }
 }
Esempio n. 23
0
        private static object ReadJsonObject(Type objectType, Stream stream)
        {
            object result;

            try
            {
                DataContractJsonSerializer dataContractJsonSerializer = OwaServiceMethodDispatcher.CreateJsonSerializer(objectType);
                result = dataContractJsonSerializer.ReadObject(stream);
            }
            catch (SerializationException ex)
            {
                string arg = OwaServiceMethodDispatcher.TryGetJsonContentFromStream(stream, 2048);
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OwaServiceMethodDispatcher", null, "ReadJsonObject", string.Format("Type: {0} Exception: {1}, JSON: {2}", objectType.Name, ex.Message, arg)));
                throw new OwaSerializationException(string.Format("Cannot deserialize object of type {0}", objectType.Name), ex);
            }
            return(result);
        }
Esempio n. 24
0
        private void DecrementInTransit()
        {
            int num = Interlocked.Decrement(ref this.totalInTrasitRequests);

            if (num < 50)
            {
                if (!this.underRequestLimitEvent.IsSet)
                {
                    OwaServerTraceLogger.AppendToLog(new PusherLogEvent(PusherEventType.ConcurrentLimit)
                    {
                        OverLimit      = false,
                        InTransitCount = num
                    });
                }
                this.underRequestLimitEvent.Set();
            }
        }
Esempio n. 25
0
        // Token: 0x060019A0 RID: 6560 RVA: 0x0005A7F8 File Offset: 0x000589F8
        internal static void SendFailureNotification(UserContext userContext, string subscriptionId, string operationId, AttachmentResultCode code, string channelId, Exception ex)
        {
            if (ex != null)
            {
                OwaServerTraceLogger.AppendToLog(new TraceLogEvent("CreateAttachmentExceptionTrace", userContext, "SendFailureNotification", "Attachment operation failed. Stack Trace:\n" + ex.ToString()));
            }
            CreateAttachmentNotificationPayload result = new CreateAttachmentNotificationPayload
            {
                SubscriptionId = subscriptionId,
                Id             = operationId,
                Bytes          = null,
                Item           = null,
                ResultCode     = code
            };

            CreateAttachmentHelper.SendPendingGetNotification(userContext, result, channelId);
        }
Esempio n. 26
0
        protected override string InternalExecute()
        {
            Item   item  = null;
            Item   item2 = null;
            string result;

            try
            {
                MailboxSession mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
                item  = Item.Bind(mailboxIdentityMailboxSession, this.ndrMessageId, ItemBindOption.None);
                item2 = ((ReportMessage)item).CreateSendAgain(this.draftFolderId);
                if (this.IrmDecryptIfRestricted(item2, UserContextManager.GetUserContext(base.CallContext.HttpContext)))
                {
                    ((RightsManagedMessageItem)item2).PrepareAcquiredLicensesBeforeSave();
                }
                StoreId storeId = null;
                if (item2 is MessageItem)
                {
                    item2.Save(SaveMode.NoConflictResolutionForceSave);
                    item2.Load();
                    storeId = item2.Id;
                }
                result = StoreId.StoreIdToEwsId(base.CallContext.AccessingPrincipal.MailboxInfo.MailboxGuid, storeId);
            }
            catch (Exception ex)
            {
                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent("Exception generating CreateResendDraft", ex));
                result = string.Empty;
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
                if (item2 != null)
                {
                    item2.Dispose();
                    item2 = null;
                }
            }
            return(result);
        }
        protected void InitSubscription()
        {
            MapiNotificationsLogEvent logEvent = new MapiNotificationsLogEvent(this.UserContext.ExchangePrincipal, this.UserContext.Key.ToString(), this, this.EventPrefix + "InitSubscription");

            if (this.IsDisposed_Reentrant)
            {
                return;
            }
            try
            {
                this.userContext.LockAndReconnectMailboxSession(3000);
                this.NeedRefreshPayload = false;
                if (this.NeedToReinitSubscriptions)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <Type>((long)this.GetHashCode(), "MapiNotificationHandlerBase.InitSubscription need to cleanup subscription before reinit for type: {0}", base.GetType());
                    this.CleanupSubscriptions();
                    this.NeedRefreshPayload = true;
                }
                if (this.Subscription == null)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <Type, SmtpAddress>((long)this.GetHashCode(), "Notification Handler type: {0} needs to init subscriptions. User: {1}", base.GetType(), this.UserContext.PrimarySmtpAddress);
                    if (this.QueryResult != null)
                    {
                        MapiNotificationHandlerBase.DisposeXSOObjects(this.QueryResult, this.UserContext);
                    }
                    this.QueryResult = null;
                    this.InitSubscriptionInternal();
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <Type>((long)this.GetHashCode(), "MapiNotificationHandlerBase.InitSubscription subscription successfully initialized for type: {0}", base.GetType());
                }
                this.NeedToReinitSubscriptions = false;
            }
            finally
            {
                if (this.userContext.MailboxSessionLockedByCurrentThread())
                {
                    this.userContext.UnlockAndDisconnectMailboxSession();
                }
                if (this.ShouldLog(logEvent))
                {
                    OwaServerTraceLogger.AppendToLog(logEvent);
                }
            }
        }
Esempio n. 28
0
 private void Unsubscribe()
 {
     try
     {
         this.Gateway.Unsubscribe(this.GetBrokerSubscription());
     }
     catch (NotificationsBrokerException handledException)
     {
         OwaServerTraceLogger.AppendToLog(new BrokerLogEvent
         {
             Principal            = this.UserContext.ExchangePrincipal,
             UserContextKey       = this.UserContext.Key.ToString(),
             SubscriptionId       = this.SubscriptionId,
             BrokerSubscriptionId = this.BrokerSubscriptionId,
             EventName            = "Unsubscribe",
             HandledException     = handledException
         });
     }
 }
Esempio n. 29
0
 public void Subscribe()
 {
     try
     {
         this.SubscribeInternal();
     }
     catch (NotificationsBrokerException handledException)
     {
         OwaServerTraceLogger.AppendToLog(new BrokerLogEvent
         {
             Principal            = this.UserContext.ExchangePrincipal,
             UserContextKey       = this.UserContext.Key.ToString(),
             SubscriptionId       = this.SubscriptionId,
             BrokerSubscriptionId = this.BrokerSubscriptionId,
             EventName            = "Subscribe",
             HandledException     = handledException
         });
         throw;
     }
 }
        // Token: 0x06001057 RID: 4183 RVA: 0x0003EB70 File Offset: 0x0003CD70
        public virtual IEnumerable <IDestinationInfo> GetDestinations(string contextKey, string subscriptionId)
        {
            ArgumentValidator.ThrowIfNullOrWhiteSpace("contextKey", contextKey);
            ArgumentValidator.ThrowIfNullOrWhiteSpace("subscriptionId", subscriptionId);
            Dictionary <Uri, IDestinationInfo> dictionary = new Dictionary <Uri, IDestinationInfo>();

            foreach (RemoteChannelInfo remoteChannelInfo in this.GetChannels(contextKey, subscriptionId))
            {
                Uri uri;
                if (string.IsNullOrEmpty(remoteChannelInfo.EndpointTestOverride))
                {
                    uri = this.GetDestinationUri(remoteChannelInfo.User);
                }
                else
                {
                    uri = new Uri(remoteChannelInfo.EndpointTestOverride);
                }
                IDestinationInfo destinationInfo;
                if (uri == null)
                {
                    string message = string.Format("Could not resolve url. User - {0}, Subscription Id - {1}, UserContextKey - {2}, Channel - {3}.", new object[]
                    {
                        remoteChannelInfo.User,
                        subscriptionId,
                        contextKey,
                        remoteChannelInfo.ChannelId
                    });
                    OwaServerTraceLogger.AppendToLog(new TraceLogEvent("RemoteNotificationManager", null, "GetDestinations", message));
                    this.UnSubscribe(contextKey, subscriptionId, remoteChannelInfo.ChannelId, remoteChannelInfo.User);
                }
                else if (!dictionary.TryGetValue(uri, out destinationInfo))
                {
                    dictionary[uri] = new RemoteDestinationInfo(uri, remoteChannelInfo.ChannelId);
                }
                else
                {
                    destinationInfo.AddChannel(remoteChannelInfo.ChannelId);
                }
            }
            return(dictionary.Values);
        }