// Token: 0x060019E6 RID: 6630 RVA: 0x000963F0 File Offset: 0x000945F0
        private static bool BindExchangePrincipal(OwaContext owaContext)
        {
            bool          result        = false;
            PublishingUrl publishingUrl = (PublishingUrl)owaContext.HttpContext.Items["AnonymousUserContextPublishedUrl"];

            try
            {
                using (PublishedCalendar publishedCalendar = (PublishedCalendar)PublishedFolder.Create(publishingUrl))
                {
                    owaContext.ExchangePrincipal = publishedCalendar.CreateExchangePrincipal();
                    HttpContext.Current.Items["AnonymousUserContextExchangePrincipalKey"]     = owaContext.ExchangePrincipal;
                    HttpContext.Current.Items["AnonymousUserContextTimeZoneKey"]              = publishedCalendar.TimeZone;
                    HttpContext.Current.Items["AnonymousUserContextSharingDetailsKey"]        = publishedCalendar.DetailLevel;
                    HttpContext.Current.Items["AnonymousUserContextPublishedCalendarNameKey"] = publishedCalendar.DisplayName;
                    HttpContext.Current.Items["AnonymousUserContextPublishedCalendarIdKey"]   = publishedCalendar.FolderId;
                }
            }
            catch (WrongServerException ex)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <WrongServerException>(0L, "CalendarVDirRequestDispatcher.BindExchangePrincipal: Returns 500 due to wrong BE server. Exception = {0}.", ex);
                owaContext.HttpContext.Response.AppendHeader("X-BEServerException", CalendarVDirRequestDispatcher.BEServerExceptionHeaderValue);
                string value = ex.RightServerToString();
                if (!string.IsNullOrEmpty(value))
                {
                    owaContext.HttpContext.Response.AppendHeader(WellKnownHeader.XDBMountedOnServer, value);
                }
                owaContext.HttpContext.Response.TrySkipIisCustomErrors = true;
                Utilities.EndResponse(owaContext.HttpContext, HttpStatusCode.InternalServerError);
                result = true;
            }
            catch (PublishedFolderAccessDeniedException arg)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <PublishedFolderAccessDeniedException>(0L, "CalendarVDirRequestDispatcher.BindExchangePrincipal: Returns 404 due to access is denied. Exception = {0}.", arg);
                Utilities.EndResponse(owaContext.HttpContext, HttpStatusCode.NotFound);
                result = true;
            }
            catch (FolderNotPublishedException arg2)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <FolderNotPublishedException>(0L, "CalendarVDirRequestDispatcher.BindExchangePrincipal: Returns 404 due to Folder not published. Exception = {0}.", arg2);
                Utilities.EndResponse(owaContext.HttpContext, HttpStatusCode.NotFound);
                result = true;
            }
            catch (OverBudgetException ex2)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <OverBudgetException>(0L, "CalendarVDirRequestDispatcher.BindExchangePrincipal: User is throttled. Exception = {0}.", ex2);
                Utilities.HandleException(owaContext, ex2);
                result = true;
            }
            return(result);
        }
        // Token: 0x060019E5 RID: 6629 RVA: 0x000963A0 File Offset: 0x000945A0
        private static bool ValidateAndCapturePublishingUrl(HttpContext context, string url)
        {
            bool result = false;

            try
            {
                context.Items["AnonymousUserContextPublishedUrl"] = PublishingUrl.Create(url);
                result = true;
            }
            catch (ArgumentException)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "CalendarVDirRequestDispatcher.CreateAndCapturePublishingUrl: Invalid PublishingUrl - {0}", url);
            }
            return(result);
        }
Ejemplo n.º 3
0
        // Token: 0x06001A0B RID: 6667 RVA: 0x000966F0 File Offset: 0x000948F0
        public void ProcessRequest(HttpContext context)
        {
            if (Globals.OwaVDirType == OWAVDirType.OWA)
            {
                ExTraceGlobals.CoreCallTracer.TraceError((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Returns 400 since OWA vdir doesn't support.");
                Utilities.EndResponse(context, HttpStatusCode.BadRequest);
                return;
            }
            PublishingUrl publishingUrl = (PublishingUrl)context.Items["AnonymousUserContextPublishedUrl"];

            if (publishingUrl == null)
            {
                ExTraceGlobals.CoreCallTracer.TraceError((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Missing publishing url,");
                Utilities.EndResponse(context, HttpStatusCode.BadRequest);
                return;
            }
            if (publishingUrl.DataType != SharingDataType.Calendar && publishingUrl.DataType != SharingDataType.ReachCalendar)
            {
                ExTraceGlobals.CoreCallTracer.TraceError <SharingDataType>((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Returns 400 due to invalid data type '{0}'.", publishingUrl.DataType);
                Utilities.EndResponse(context, HttpStatusCode.BadRequest);
                return;
            }
            if (!Utilities.IsGetRequest(context.Request))
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug <string>((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Stop process if it is not GET request. HttpMethod = {0}.", context.Request.HttpMethod);
                return;
            }
            try
            {
                using (PublishedCalendar publishedCalendar = (PublishedCalendar)PublishedFolder.Create(publishingUrl))
                {
                    publishedCalendar.WriteInternetCalendar(context.Response.OutputStream, "utf-8");
                }
                context.Response.ContentType = "text/calendar; charset=utf-8";
            }
            catch (FolderNotPublishedException arg)
            {
                ExTraceGlobals.CoreCallTracer.TraceError <FolderNotPublishedException>((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Returns 404 due to folder is not published. Exception = {0}.", arg);
                Utilities.EndResponse(context, HttpStatusCode.NotFound);
            }
            catch (PublishedFolderAccessDeniedException arg2)
            {
                ExTraceGlobals.CoreCallTracer.TraceError <PublishedFolderAccessDeniedException>((long)this.GetHashCode(), "HttpHandlerICal.ProcessRequest: Returns 404 due to access is denied. Exception = {0}.", arg2);
                Utilities.EndResponse(context, HttpStatusCode.NotFound);
            }
        }
Ejemplo n.º 4
0
        internal static object PublishedUrlGetter(IPropertyBag propertyBag, SimpleProviderPropertyDefinition propertyDefinition)
        {
            string text = (string)propertyBag[propertyDefinition];

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }
            PublishingUrl publishingUrl = PublishingUrl.Create(text);
            ObscureUrl    obscureUrl    = publishingUrl as ObscureUrl;

            if (obscureUrl == null)
            {
                return(text);
            }
            return(obscureUrl.ChangeToKind(ObscureKind.Normal).ToString());
        }
Ejemplo n.º 5
0
        internal static void PublishedUrlSetter(object value, IPropertyBag propertyBag, SimpleProviderPropertyDefinition propertyDefinition)
        {
            string text = (string)value;

            if (string.IsNullOrEmpty(text))
            {
                propertyBag[propertyDefinition] = null;
                return;
            }
            PublishingUrl publishingUrl = PublishingUrl.Create(text);
            ObscureUrl    obscureUrl    = publishingUrl as ObscureUrl;

            if (obscureUrl == null)
            {
                propertyBag[propertyDefinition] = text;
                return;
            }
            propertyBag[propertyDefinition] = obscureUrl.ChangeToKind(ObscureKind.Restricted).ToString();
        }
        private void SaveSharingAnonymous(MailboxCalendarFolder mailboxCalendarFolder, StoreObjectId folderId)
        {
            Util.ThrowOnNullArgument(mailboxCalendarFolder, "mailboxCalendarFolder");
            Util.ThrowOnNullArgument(folderId, "folderId");
            IRecipientSession adrecipientSession = base.MailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent);
            ADRecipient       adrecipient        = adrecipientSession.Read(base.MailboxSession.MailboxOwner.ObjectId);

            if (adrecipient == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <ADRecipient>((long)this.GetHashCode(), "This is not an ADUser so SharingAnonymousIdentities doesn't apply. Recipient = {0}.", adrecipient);
                return;
            }
            if (mailboxCalendarFolder.PublishEnabled)
            {
                PublishingUrl publishingUrl = PublishingUrl.Create(mailboxCalendarFolder.PublishedCalendarUrl);
                ExTraceGlobals.SharingTracer.TraceDebug <ADUser, string, StoreObjectId>((long)this.GetHashCode(), "Publish is enabled and trying to add or update SharingAnonymousIdentities. User={0}; Url Identity={1}; Folder={2}.", aduser, publishingUrl.Identity, folderId);
                aduser.SharingAnonymousIdentities.AddOrUpdate(publishingUrl.DataType.ExternalName, publishingUrl.Identity, folderId.ToBase64String());
            }
            else
            {
                PublishingUrl publishingUrl2 = PublishingUrl.Create(mailboxCalendarFolder.PublishedCalendarUrl);
                ExTraceGlobals.SharingTracer.TraceDebug <ADUser, string, StoreObjectId>((long)this.GetHashCode(), "Publish is NOT enabled and trying to remove SharingAnonymousIdentities. User={0}; Url Identity={1}; Folder={2}.", aduser, publishingUrl2.Identity, folderId);
                aduser.SharingAnonymousIdentities.Remove(publishingUrl2.Identity);
            }
            if (aduser.SharingAnonymousIdentities.Changed)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <ADUser>((long)this.GetHashCode(), "Save SharingAnonymousIdentities on user {0}.", aduser);
                adrecipientSession.Save(aduser);
            }
        }
Ejemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            string parameter = base.GetParameter("id", true);

            try
            {
                StoreObjectId itemId        = Utilities.CreateStoreObjectId(parameter);
                PublishingUrl publishingUrl = ((AnonymousSessionContext)base.SessionContext).PublishingUrl;
                using (PublishedCalendar publishedCalendar = (PublishedCalendar)PublishedFolder.Create(publishingUrl))
                {
                    this.detailLevel = publishedCalendar.DetailLevel;
                    if (this.detailLevel == DetailLevelEnumType.AvailabilityOnly)
                    {
                        Utilities.EndResponse(OwaContext.Current.HttpContext, HttpStatusCode.Forbidden);
                    }
                    this.item = publishedCalendar.GetItemData(itemId);
                }
            }
            catch (FolderNotPublishedException)
            {
                Utilities.EndResponse(OwaContext.Current.HttpContext, HttpStatusCode.NotFound);
            }
            catch (OwaInvalidIdFormatException innerException)
            {
                throw new OwaInvalidRequestException("Invalid id param", innerException);
            }
            catch (PublishedFolderAccessDeniedException innerException2)
            {
                throw new OwaInvalidRequestException("Cannot access this published folder", innerException2);
            }
            catch (ObjectNotFoundException innerException3)
            {
                throw new OwaInvalidRequestException("Cannot open this item", innerException3);
            }
        }