// 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 static void UpdateRequestHeaders(HttpContext httpContext) { ArgumentValidator.ThrowIfNull("httpContext", httpContext); string fullRawUrl = httpContext.Request.GetFullRawUrl(); try { httpContext.Request.Headers[Constants.MsExchProxyUri] = fullRawUrl; } catch (ArgumentException) { httpContext.Request.Headers[Constants.MsExchProxyUri] = Uri.EscapeUriString(fullRawUrl); } httpContext.Request.Headers[Constants.XIsFromCafe] = Constants.IsFromCafeHeaderValue; httpContext.Request.Headers[Constants.XSourceCafeServer] = HttpProxyGlobals.LocalMachineFqdn.Member; httpContext.Request.Headers[CafeHelper.CafeProxyHandler] = CafeHelper.NativeHttpProxy; httpContext.Request.Headers[Constants.OriginatingClientIpHeader] = AspNetHelper.GetClientIpAsProxyHeader(httpContext.Request); httpContext.Request.Headers[Constants.OriginatingClientPortHeader] = AspNetHelper.GetClientPortAsProxyHeader(httpContext); string value; if (HttpProxyRegistry.AreGccStoredSecretKeysValid.Member && (GccUtils.TryGetGccProxyInfo(httpContext, out value) || GccUtils.TryCreateGccProxyInfo(httpContext, out value)) && !string.IsNullOrEmpty(value)) { httpContext.Request.Headers.Add("X-GCC-PROXYINFO", value); } string value2 = httpContext.Items["WLID-MemberName"] as string; if (!string.IsNullOrEmpty(value2)) { httpContext.Request.Headers[Constants.WLIDMemberNameHeaderName] = value2; httpContext.Request.Headers[Constants.LiveIdMemberName] = value2; } string text = httpContext.Request.Url.PathAndQuery; if (HttpProxyGlobals.ProtocolType == ProtocolType.RpcHttp) { RpcHttpQueryString rpcHttpQueryString = new RpcHttpQueryString(httpContext.Request.Url.Query); if (!string.IsNullOrEmpty(rpcHttpQueryString.RcaServer)) { httpContext.Request.Headers[WellKnownHeader.RpcHttpProxyServerTarget] = rpcHttpQueryString.RcaServer; } } else if (HttpProxyGlobals.ProtocolType == ProtocolType.Ews) { bool selectedNodeIsLast; string explicitLogonNode = ProtocolHelper.GetExplicitLogonNode(httpContext.Request.ApplicationPath, httpContext.Request.FilePath, ExplicitLogonNode.Second, out selectedNodeIsLast); string text2; if (ProtocolHelper.TryGetValidNormalizedExplicitLogonAddress(explicitLogonNode, selectedNodeIsLast, out text2)) { Uri clientUrlForProxy = ProtocolHelper.GetClientUrlForProxy(httpContext.Request.Url, explicitLogonNode); text = clientUrlForProxy.PathAndQuery; } } else if (HttpProxyGlobals.ProtocolType == ProtocolType.Eas) { text = text.Replace("Microsoft-Server-ActiveSync", "Microsoft-Server-ActiveSync/Proxy"); } httpContext.Request.ServerVariables["X-ProxyTargetUrlAbsPath"] = text; }
public static string GetClientPortAsProxyHeader(HttpContext httpContext) { ArgumentValidator.ThrowIfNull("httpContext", httpContext); string text = httpContext.Request.Headers[Constants.OriginatingClientPortHeader]; string text2 = GccUtils.GetClientPort(httpContext); if (!string.IsNullOrEmpty(text)) { text2 = string.Format("{0},{1}", text, text2); } return(text2); }
// Token: 0x0600191D RID: 6429 RVA: 0x000922A4 File Offset: 0x000904A4 private Folder GetFolderFromPath(string path, bool isPublicFolder) { string[] array = path.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); CultureInfo userCulture = Culture.GetUserCulture(); StoreObjectId storeObjectId = null; StoreSession storeSession = null; OwaStoreObjectIdType objectIdType = OwaStoreObjectIdType.MailBoxObject; try { if (isPublicFolder) { storeSession = PublicFolderSession.OpenAsAdmin(this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.userContext.ExchangePrincipal, Guid.Empty, null, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath", null); storeObjectId = this.userContext.PublicFolderRootId; objectIdType = OwaStoreObjectIdType.PublicStoreFolder; } else { storeSession = MailboxSession.OpenAsAdmin(this.owaContext.ExchangePrincipal, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath"); GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(storeSession, this.owaContext.HttpContext.Request); storeObjectId = this.userContext.GetRootFolderId(this.userContext.MailboxSession); } for (int i = 0; i < array.Length; i++) { object[][] folderIdByDisplayName = this.GetFolderIdByDisplayName(array[i], storeObjectId, storeSession); if (folderIdByDisplayName == null || folderIdByDisplayName.Length == 0) { return(null); } storeObjectId = ((VersionedId)folderIdByDisplayName[0][0]).ObjectId; } } finally { if (storeSession != null) { storeSession.Dispose(); storeSession = null; } } if (storeObjectId == null) { return(null); } return(this.GetFolderFromId(OwaStoreObjectId.CreateFromFolderId(storeObjectId, objectIdType))); }
internal override MailboxSession CreateWebPartMailboxSession(IExchangePrincipal mailBoxExchangePrincipal, CultureInfo cultureInfo, HttpRequest clientRequest) { MailboxSession result; using (DisposeGuard disposeGuard = default(DisposeGuard)) { MailboxSession mailboxSession = MailboxSession.OpenWithBestAccess(mailBoxExchangePrincipal, base.CreateADOrgPersonForWebPartUserBySid(), this.WindowsPrincipal, cultureInfo, "Client=OWA;Action=WebPart + Delegate"); disposeGuard.Add <MailboxSession>(mailboxSession); GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(mailboxSession, clientRequest); disposeGuard.Success(); result = mailboxSession; } return(result); }
// Token: 0x06000D66 RID: 3430 RVA: 0x00059670 File Offset: 0x00057870 internal override MailboxSession CreateMailboxSession(IExchangePrincipal exchangePrincipal, CultureInfo cultureInfo, HttpRequest clientRequest) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaClientSecurityContextIdentity.CreateMailboxSession"); MailboxSession result; try { MailboxSession mailboxSession = MailboxSession.Open(exchangePrincipal, this.clientSecurityContext, cultureInfo, "Client=OWA;Action=ViaProxy"); GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(mailboxSession, clientRequest); result = mailboxSession; } catch (AccessDeniedException innerException) { throw new OwaExplicitLogonException("User has no access rights to the mailbox", LocalizedStrings.GetNonEncoded(882888134), innerException); } return(result); }
// Token: 0x06001261 RID: 4705 RVA: 0x0006FF40 File Offset: 0x0006E140 internal static HttpWebRequest CreateHttpWebRequestForProxying(OwaContext owaContext, Uri requestUri) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUri); httpWebRequest.UnsafeAuthenticatedConnectionSharing = true; httpWebRequest.PreAuthenticate = true; httpWebRequest.AllowAutoRedirect = false; httpWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials.GetCredential(requestUri, "Kerberos"); if (httpWebRequest.Credentials == null) { throw new OwaInvalidOperationException("Can't get credentials for the proxy request"); } httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip; CertificateValidationManager.SetComponentId(httpWebRequest, requestUri.IsLoopback ? "OWA_IgnoreCertErrors" : "OWA"); GccUtils.CopyClientIPEndpointsForServerToServerProxy(owaContext.HttpContext, httpWebRequest); return(httpWebRequest); }
private HttpWebRequest CopyClientRequest(HttpRequest clientrequest, Uri proxyuri) { string b = HttpRequestHeader.Authorization.ToString(); HttpWebRequest httpWebRequest = this.CreateWebRequest(proxyuri); httpWebRequest.Method = clientrequest.HttpMethod; for (int i = 0; i < clientrequest.Headers.Count; i++) { string text = clientrequest.Headers.Keys[i]; if ((!(text == b) || !this.proxyInfo.CanImpersonate) && !WebHeaderCollection.IsRestricted(text)) { httpWebRequest.Headers[text] = clientrequest.Headers[text]; } } CertificateValidationManager.SetComponentId(httpWebRequest, "AirSync"); foreach (string text2 in this.proxyInfo.AdditionalHeaders.Keys) { httpWebRequest.Headers[text2] = this.proxyInfo.AdditionalHeaders[text2]; } if (GlobalSettings.IsGCCEnabled) { if (GlobalSettings.AreGccStoredSecretKeysValid) { string text3 = httpWebRequest.Headers["x-gcc-proxyinfo"]; if (string.IsNullOrEmpty(text3) || (!string.IsNullOrEmpty(text3) && !ProxyHandler.HasValidAuthString(text3))) { StringBuilder stringBuilder = new StringBuilder(GccUtils.GetAuthStringForThisServer()); stringBuilder.Append(", "); stringBuilder.Append(clientrequest.ServerVariables["REMOTE_ADDR"]); stringBuilder.Append(", "); stringBuilder.Append(clientrequest.ServerVariables["LOCAL_ADDR"]); httpWebRequest.Headers["x-gcc-proxyinfo"] = stringBuilder.ToString(); } } else { AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_NoGccStoredSecretKey, "NoGccStoredSecretKey", new string[0]); AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "No gcc stored secret key"); } } httpWebRequest.Referer = clientrequest.Url.AbsoluteUri; httpWebRequest.ContentType = clientrequest.ContentType; httpWebRequest.UserAgent = clientrequest.UserAgent; return(httpWebRequest); }
private static bool HasValidAuthString(string gccHeaderValue) { int num = gccHeaderValue.IndexOf(','); return(num > 0 && GccUtils.IsValidAuthString(gccHeaderValue.Substring(0, num).Trim())); }