// Token: 0x0600004C RID: 76 RVA: 0x00002C74 File Offset: 0x00000E74
        public string GetHostNameFromVdir(ADObjectId serverSiteId, string protocol)
        {
            SupportedProtocol supportedProtocol;

            Enum.TryParse <SupportedProtocol>(protocol, true, out supportedProtocol);
            Uri externalUrl;

            switch (supportedProtocol)
            {
            case SupportedProtocol.Unknown:
                throw AutoDiscoverResponseException.BadRequest("InvalidProtocol", string.Format("The given protocol value '{0}' is invalid. Supported values are '{1}'", protocol, "ActiveSync, Ews"), null);

            case SupportedProtocol.Rest:
                throw AutoDiscoverResponseException.NotFound("MailboxNotEnabledForRESTAPI", "REST API is not yet supported for this mailbox.", null);

            case SupportedProtocol.ActiveSync:
                externalUrl = GlobalServiceUrls.GetExternalUrl <MobileSyncService>();
                break;

            case SupportedProtocol.Ews:
                externalUrl = GlobalServiceUrls.GetExternalUrl <WebServicesService>();
                break;

            default:
                throw new ArgumentException("Invalid Protocol specified", protocol);
            }
            return(externalUrl.Host);
        }
Exemple #2
0
 // Token: 0x0600000D RID: 13 RVA: 0x000023D1 File Offset: 0x000005D1
 public override bool Validate(HttpContextBase context)
 {
     if (context.Request.Url.AbsolutePath.EndsWith("v1.0", StringComparison.OrdinalIgnoreCase))
     {
         throw AutoDiscoverResponseException.BadRequest(HttpStatusCode.BadRequest.ToString(), "Id segment is missing in the URL", null);
     }
     return(true);
 }
Exemple #3
0
        // Token: 0x0600000B RID: 11 RVA: 0x00002324 File Offset: 0x00000524
        internal void EmitErrorResponse(HttpContextBase context, AutoDiscoverResponseException exception)
        {
            context.Response.ContentType          = "application/json";
            context.Response.Headers["jsonerror"] = "true";
            context.Response.StatusCode           = exception.HttpStatusCodeValue;
            JsonErrorResponse jsonErrorResponse = new JsonErrorResponse
            {
                ErrorMessage = exception.Message,
                ErrorCode    = exception.ErrorCode
            };
            string text = jsonErrorResponse.SerializeToJson(jsonErrorResponse);

            this.Logger.AppendGenericInfo("EmitErrorResponseJsonString", text);
            context.Response.Write(text);
        }
Exemple #4
0
 // Token: 0x0600003F RID: 63 RVA: 0x00002A6C File Offset: 0x00000C6C
 internal void ValidateRequest(string emailAddress, string protocol, uint redirectCount, RequestDetailsLogger logger)
 {
     if (string.IsNullOrWhiteSpace(protocol))
     {
         throw AutoDiscoverResponseException.BadRequest("MandatoryParameterMissing", "A valid value must be provided for the query parameter 'Protocol'", null);
     }
     if (string.IsNullOrWhiteSpace(emailAddress))
     {
         throw AutoDiscoverResponseException.BadRequest("MandatoryParameterMissing", "A valid smtp address must be provided", null);
     }
     logger.Set(ServiceCommonMetadata.AuthenticatedUser, emailAddress);
     logger.AppendGenericInfo("RequestedProtocol", protocol);
     if (!SmtpAddress.IsValidSmtpAddress(emailAddress))
     {
         throw AutoDiscoverResponseException.BadRequest("InvalidUserId", string.Format("The given SMTP address is invalid '{0}'", emailAddress), null);
     }
     if (redirectCount >= 10U)
     {
         logger.AppendGenericError("RedirectCountExceeded", "Redirect count exceeded for the given user");
         throw AutoDiscoverResponseException.NotFound();
     }
 }
        // Token: 0x06000043 RID: 67 RVA: 0x00002BCC File Offset: 0x00000DCC
        private static string GetResourceUrlSuffixForProtocol(string protocol, string hostName)
        {
            SupportedProtocol supportedProtocol;

            Enum.TryParse <SupportedProtocol>(protocol, true, out supportedProtocol);
            switch (supportedProtocol)
            {
            case SupportedProtocol.Unknown:
                throw AutoDiscoverResponseException.BadRequest("InvalidProtocol", string.Format("The given protocol value '{0}' is invalid. Supported values are '{1}'", protocol, "ActiveSync, Ews"), null);

            case SupportedProtocol.Rest:
                throw AutoDiscoverResponseException.NotFound("MailboxNotEnabledForRESTAPI", "REST API is not yet supported for this mailbox.", null);

            case SupportedProtocol.ActiveSync:
                return("/Microsoft-Server-ActiveSync");

            case SupportedProtocol.Ews:
                return("/EWS/Exchange.asmx");

            default:
                return(null);
            }
        }
Exemple #6
0
 // Token: 0x06000009 RID: 9 RVA: 0x00002210 File Offset: 0x00000410
 internal void ProcessRequest(HttpContextBase context)
 {
     try
     {
         Common.SendWatsonReportOnUnhandledException(delegate
         {
             this.Logger.Set(ActivityStandardMetadata.Action, "AutoDiscoverV2");
             FlightSettingRepository flightSettings = new FlightSettingRepository();
             try
             {
                 if (this.Validate(context))
                 {
                     AutoDiscoverV2 autoDiscoverV  = new AutoDiscoverV2(this.Logger, flightSettings, new TenantRepository(this.Logger));
                     string emailAddressFromUrl    = this.GetEmailAddressFromUrl(context);
                     AutoDiscoverV2Request request = autoDiscoverV.CreateRequestFromContext(context, emailAddressFromUrl);
                     AutoDiscoverV2Response autoDiscoverV2Response = autoDiscoverV.ProcessRequest(request, flightSettings);
                     if (autoDiscoverV2Response != null)
                     {
                         this.EmitResponse(context, autoDiscoverV2Response);
                     }
                     else
                     {
                         this.LogAndEmitErrorResponse(context, AutoDiscoverResponseException.NotFound());
                     }
                 }
             }
             catch (AutoDiscoverResponseException exception)
             {
                 this.LogAndEmitErrorResponse(context, exception);
             }
         });
     }
     catch (Exception innerException)
     {
         this.EmitErrorResponse(context, AutoDiscoverResponseException.InternalServerError("InternalServerError", innerException));
     }
 }
Exemple #7
0
 // Token: 0x0600000C RID: 12 RVA: 0x000023B1 File Offset: 0x000005B1
 private void LogAndEmitErrorResponse(HttpContextBase context, AutoDiscoverResponseException exception)
 {
     this.Logger.AppendGenericError("AutoDiscoverResponseException", exception.ToString());
     this.EmitErrorResponse(context, exception);
 }