internal static WacResult ExecuteWacRequest(string wacTemplateUrl, string owaTemplateUrl, ADUser user, StringBuilder diagnosticsDetails) { string text = string.Empty; string text2 = string.Empty; string text3 = string.Empty; WacRequestState wacRequestState = new WacRequestState(); WacResult wacResult = new WacResult(); try { string text4 = user.PrimarySmtpAddress.ToString(); if (string.IsNullOrEmpty(text4)) { diagnosticsDetails.AppendLine(string.Format("Primary SMTP Address not found for user {0}", user.Alias)); wacResult.Error = wacRequestState.Error; return(wacResult); } text = WacWorker.GenerateWopiSrcUrl(owaTemplateUrl, text4); LocalTokenIssuer localTokenIssuer = new LocalTokenIssuer(user.OrganizationId); TokenResult wacCallbackToken = localTokenIssuer.GetWacCallbackToken(new Uri(text, UriKind.Absolute), text4, Guid.NewGuid().ToString()); text3 = wacCallbackToken.TokenString; text2 = WacWorker.GenerateWacIFrameUrl(text, wacTemplateUrl, text4, text3); text = string.Format("{0}&access_token={1}", text, text3); diagnosticsDetails.AppendLine("Probe Details:"); diagnosticsDetails.AppendLine("WacIFrameUrl:"); diagnosticsDetails.AppendLine(text2); diagnosticsDetails.AppendLine("ExchangeCheckFileUrl:"); diagnosticsDetails.AppendLine(text); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(text2); wacRequestState.Request = httpWebRequest; wacRequestState.WacIFrameUrl = text2; wacRequestState.WopiUrl = text; wacRequestState.Error = false; wacRequestState.DiagnosticsDetails = diagnosticsDetails; WacWorker.allDone.Reset(); WacWorker.latencyMeasurementStart = DateTime.UtcNow; IAsyncResult asyncResult = httpWebRequest.BeginGetResponse(new AsyncCallback(WacWorker.ProcessWacResponse), wacRequestState); ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(WacWorker.TimeoutCallback), httpWebRequest, 120000, true); WacWorker.allDone.WaitOne(); if (wacRequestState.Response != null) { wacRequestState.Response.Close(); } } catch (WebException ex) { diagnosticsDetails.AppendLine("Stack Trace:"); diagnosticsDetails.AppendLine(string.Format("Exception: {0}.", ex.ToString())); for (Exception innerException = ex.InnerException; innerException != null; innerException = innerException.InnerException) { diagnosticsDetails.AppendLine(string.Format("Inner Exception: {0}.", innerException.ToString())); } diagnosticsDetails.AppendLine("Diagnostic Tip: There is an unhandled exception occured while running Wac Probe. Please look into the exception details."); wacRequestState.Error = true; } wacResult.Error = wacRequestState.Error; return(wacResult); }
// Token: 0x06001AD9 RID: 6873 RVA: 0x0006615C File Offset: 0x0006435C private static TokenResult GetOAuthToken(string ewsAttachmentId, UserContext userContext, string mailboxSmtpAddress, string wopiSrcUrl) { LocalTokenIssuer localTokenIssuer = new LocalTokenIssuer(userContext.ExchangePrincipal.MailboxInfo.OrganizationId); TokenResult wacCallbackToken = localTokenIssuer.GetWacCallbackToken(new Uri(wopiSrcUrl, UriKind.Absolute), mailboxSmtpAddress, ewsAttachmentId); if (wacCallbackToken == null) { throw new InvalidOperationException("OAuth TokenResult is null."); } return(wacCallbackToken); }