// Token: 0x0600064D RID: 1613 RVA: 0x000129FC File Offset: 0x00010BFC public ADRecipient CreateADRecipientBySid() { IRecipientSession recipientSession = (this.UserOrganizationId == null) ? UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, this.DomainName, null) : UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, null, this.UserOrganizationId); ADRecipient adrecipient = recipientSession.FindBySid(this.UserSid); if (adrecipient == null) { throw new OwaADUserNotFoundException(this.SafeGetRenderableName()); } return(adrecipient); }
private SmimeSettingsData ReadAggregatedSmimeData(UserConfigurationManager.IAggregationContext ctx, OrganizationId organizationId) { return(UserContextUtilities.ReadAggregatedType <SmimeSettingsData>(ctx, "OWA.SMIME", delegate { SmimeSettingsData result = null; ISmimeSettingsProvider smimeSettingsProvider = SmimeAdminSettingsType.ReadSmimeSettingsFromAd(organizationId); if (smimeSettingsProvider != null) { result = new SmimeSettingsData(SmimeAdminSettingsType.ReadSmimeSettingsFromAd(organizationId)); } return result; })); }
private void RefreshMailboxSession(EcpUserSettings userSettings) { base.UserContextDiposeGraph.Append(".ur1"); if ((userSettings & EcpUserSettings.Regional) == EcpUserSettings.Regional) { ExTimeZone exTimeZone = null; try { if (this.mailboxSessionLock.LockWriterElastic(3000)) { base.UserContextDiposeGraph.Append(".ur2"); if (base.NotificationManager != null) { base.UserContextDiposeGraph.Append(".ur3"); base.NotificationManager.CleanupSubscriptions(); } if (this.mailboxSession != null) { base.UserContextDiposeGraph.Append(".ur4"); base.DisposeMailboxSession(); } this.mailboxSession = this.CreateMailboxSession(); this.isMailboxSessionCreated = true; UserContextUtilities.ReconnectStoreSession(this.mailboxSession, this); exTimeZone = TimeZoneHelper.GetUserTimeZone(this.mailboxSession); } } finally { if (this.mailboxSessionLock.IsWriterLockHeld) { if (this.mailboxSession != null) { base.UserContextDiposeGraph.Append(".ur5"); base.UnlockAndDisconnectMailboxSession(); } else { base.UserContextDiposeGraph.Append(".ur6"); this.mailboxSessionLock.ReleaseWriterLock(); } } } if (exTimeZone != null && base.NotificationManager != null) { base.NotificationManager.RefreshSubscriptions(exTimeZone); } } base.UserContextDiposeGraph.Append(".ur7"); }
private static UserContextKey GetUserContextKey(HttpContext httpContext, ClientSecurityContext overrideClientSecurityContext, out UserContextCookie userContextCookie) { UserContextKey userContextKey = null; string explicitLogonUser = UserContextUtilities.GetExplicitLogonUser(httpContext); if (string.IsNullOrEmpty(explicitLogonUser)) { userContextCookie = UserContextCookie.GetUserContextCookie(httpContext); if (userContextCookie != null) { ExTraceGlobals.UserContextCallTracer.TraceDebug <UserContextCookie>(0L, "Found cookie in the request: {0}", userContextCookie); if (overrideClientSecurityContext == null) { userContextKey = UserContextKey.CreateFromCookie(userContextCookie, httpContext); } else { userContextKey = UserContextKey.CreateFromCookie(userContextCookie, overrideClientSecurityContext.UserSid); } } } else { userContextCookie = null; if (UserContextManager.RequestRequiresSharedContext(httpContext)) { userContextKey = UserContextKey.Create("D894745CADD64DB9B00309200288E1E7", "SharedAdmin", explicitLogonUser); } else { SecurityIdentifier securityIdentifier = httpContext.User.Identity.GetSecurityIdentifier(); if (securityIdentifier == null) { ExTraceGlobals.UserContextCallTracer.TraceDebug <IIdentity>(0L, "UserContextManager.GetUserContextKey: current user has no security identifier - '{0}'", httpContext.User.Identity); ExWatson.SendReport(new InvalidOperationException(string.Format("UserContextManager.GetUserContextKey: current user has no security identifier - '{0}'", httpContext.User.Identity)), ReportOptions.None, null); return(null); } string logonUniqueKey = securityIdentifier.ToString(); string text = httpContext.Request.Headers["X-OWA-Test-ExplicitLogonUserId"]; if (string.IsNullOrEmpty(text) || !AppConfigLoader.GetConfigBoolValue("Test_OwaAllowHeaderOverride", false)) { text = "B387FD19C8C4416694EB79909BED70B5"; } userContextKey = UserContextKey.Create(text, logonUniqueKey, explicitLogonUser); ExTraceGlobals.UserContextCallTracer.TraceDebug <UserContextKey>(0L, "Cookie not found but this is explicit logon. Generated Key: {0}", userContextKey); } } return(userContextKey); }
// Token: 0x060007C6 RID: 1990 RVA: 0x00019760 File Offset: 0x00017960 public static bool IsValidGuid(string guid) { if (guid == null || guid.Length != 32) { return(false); } for (int i = 0; i < 32; i++) { if (!UserContextUtilities.IsHexChar(guid[i])) { return(false); } } return(true); }
// Token: 0x06000792 RID: 1938 RVA: 0x000182F4 File Offset: 0x000164F4 internal static bool TryParseCookieName(string cookieName, out string cookieId) { cookieId = null; if (!cookieName.StartsWith(UserContextCookie.UserContextCookiePrefix, StringComparison.OrdinalIgnoreCase)) { return(false); } int length = UserContextCookie.UserContextCookiePrefix.Length; if (cookieName.Length == length) { return(true); } cookieId = cookieName.Substring(length + 1, cookieName.Length - length - 1); return(UserContextUtilities.IsValidGuid(cookieId)); }
// Token: 0x060007D4 RID: 2004 RVA: 0x00019E0C File Offset: 0x0001800C public static bool IsPublicLogon(OrganizationId organizationId, HttpContext httpContext) { bool result; try { OwaOrgConfigData orgConfigTypeFromAd = UserContextUtilities.GetOrgConfigTypeFromAd(organizationId); result = (UserContextUtilities.IsPublicRequest(httpContext.Request) || (orgConfigTypeFromAd.PublicComputersDetectionEnabled && UserContextUtilities.IsPublicComputerSession(httpContext))); } catch (Exception ex) { ExTraceGlobals.CoreTracer.TraceError <string, string>(0L, "Failed to Get IsPublicLogon. Error: {0}. Stack: {1}.", ex.Message, ex.StackTrace); throw; } return(result); }
public void UnlockAndDisconnectMailboxSession() { if (this.mailboxSessionLock.IsWriterLockHeld) { try { if (this.mailboxSession != null) { UserContextUtilities.DisconnectStoreSession(this.mailboxSession); } } finally { this.mailboxSessionLock.ReleaseWriterLock(); } } }
// Token: 0x06000988 RID: 2440 RVA: 0x000221E0 File Offset: 0x000203E0 private static bool IsSharePointAppRequest(RequestContext requestContext, out DateTime?whenMailboxCreated) { bool result = false; whenMailboxCreated = null; if (requestContext != null) { if (requestContext.UserContext != null && requestContext.UserContext.ExchangePrincipal != null) { result = (requestContext.UserContext.ExchangePrincipal.RecipientTypeDetails == RecipientTypeDetails.TeamMailbox); whenMailboxCreated = requestContext.UserContext.ExchangePrincipal.MailboxInfo.WhenMailboxCreated; } else if (requestContext.HttpContext != null) { result = UserContextUtilities.IsSharePointAppRequest(requestContext.HttpContext.Request); } } return(result); }
public OWAMiniRecipient CreateOWAMiniRecipientBySid() { IRecipientSession recipientSession = (this.UserOrganizationId == null) ? UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, this.DomainName, null) : UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, null, this.UserOrganizationId); bool flag = false; bool enabled = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).OwaServer.OwaClientAccessRulesEnabled.Enabled; if (enabled) { ClientAccessRuleCollection collection = ClientAccessRulesCache.Instance.GetCollection(this.UserOrganizationId ?? OrganizationId.ForestWideOrgId); flag = (collection.Count > 0); } OWAMiniRecipient owaminiRecipient = recipientSession.FindMiniRecipientBySid <OWAMiniRecipient>(this.UserSid, flag ? OWAMiniRecipientSchema.AdditionalPropertiesWithClientAccessRules : OWAMiniRecipientSchema.AdditionalProperties); if (owaminiRecipient == null) { ExTraceGlobals.CoreTracer.TraceDebug <SecurityIdentifier>(0L, "OwaIdentity.CreateOWAMiniRecipientBySid: got null OWAMiniRecipient for Sid: {0}", this.UserSid); throw new OwaADUserNotFoundException(this.SafeGetRenderableName()); } return(owaminiRecipient); }
private UMSettingsData ReadAggregatedUMSettingsData(UserConfigurationManager.IAggregationContext ctx, ExchangePrincipal exchangePrincipal) { return(UserContextUtilities.ReadAggregatedType <UMSettingsData>(ctx, "OWA.UMSettings", delegate { UMSettingsData umsettingsData = new UMSettingsData(); try { using (UMClientCommon umclientCommon = new UMClientCommon(exchangePrincipal)) { umsettingsData.PlayOnPhoneDialString = umclientCommon.GetPlayOnPhoneDialString(); umsettingsData.IsRequireProtectedPlayOnPhone = umclientCommon.IsRequireProtectedPlayOnPhone(); umsettingsData.IsUMEnabled = umclientCommon.IsUMEnabled(); } } catch (LocalizedException arg) { ExTraceGlobals.CoreTracer.TraceWarning <LocalizedException>((long)this.GetHashCode(), "Failed to initialize UM settings due to exception: {0}", arg); } return umsettingsData; })); }
// Token: 0x06000793 RID: 1939 RVA: 0x0001834C File Offset: 0x0001654C internal static UserContextCookie GetUserContextCookie(HttpContext httpContext) { HttpRequest request = httpContext.Request; for (int i = 0; i < request.Cookies.Count; i++) { HttpCookie httpCookie = request.Cookies[i]; if (httpCookie.Name != null && httpCookie.Name.StartsWith(UserContextCookie.UserContextCookiePrefix, StringComparison.OrdinalIgnoreCase)) { UserContextCookie userContextCookie = UserContextCookie.TryCreateFromHttpCookie(httpCookie); if (userContextCookie == null) { ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(0L, "Invalid user context cookie received. Name={0}, Value={1}, httpContext.Request.RawUrl={2}", httpCookie.Name, httpCookie.Value, request.RawUrl); return(null); } if (userContextCookie.MailboxUniqueKey == null) { if (!UserContextUtilities.IsDifferentMailbox(httpContext)) { return(userContextCookie); } } else { string explicitLogonUser = UserContextUtilities.GetExplicitLogonUser(httpContext); if (!string.IsNullOrEmpty(explicitLogonUser)) { using (OwaIdentity owaIdentity = OwaIdentity.CreateOwaIdentityFromExplicitLogonAddress(explicitLogonUser)) { if (string.Equals(userContextCookie.MailboxUniqueKey, owaIdentity.UniqueId, StringComparison.Ordinal)) { return(userContextCookie); } } } } } } return(null); }
internal OWAMiniRecipient FixCorruptOWAMiniRecipientCultureEntry() { if (ExTraceGlobals.CoreTracer.IsTraceEnabled(TraceType.DebugTrace)) { ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "User {0} has corrupt culture, setting client culture to empty", this.SafeGetRenderableName()); } IRecipientSession recipientSession = (this.UserOrganizationId == null) ? UserContextUtilities.CreateScopedRecipientSession(false, ConsistencyMode.PartiallyConsistent, this.DomainName, null) : UserContextUtilities.CreateScopedRecipientSession(false, ConsistencyMode.PartiallyConsistent, null, this.UserOrganizationId); ADUser aduser = recipientSession.FindBySid(this.UserSid) as ADUser; if (aduser != null) { aduser.Languages = new MultiValuedProperty <CultureInfo>(); if (ExTraceGlobals.CoreTracer.IsTraceEnabled(TraceType.DebugTrace)) { ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "Saving culture for User {0}, setting client culture to empty", this.SafeGetRenderableName()); } recipientSession.Save(aduser); return(recipientSession.FindMiniRecipientBySid <OWAMiniRecipient>(this.UserSid, OWAMiniRecipientSchema.AdditionalProperties)); } ExTraceGlobals.CoreTracer.TraceDebug <SecurityIdentifier>(0L, "OwaIdentity.FixCorruptOWAMiniRecipientCultureEntry: got null adUser for Sid: {0}", this.UserSid); return(null); }
internal static CultureInfo GetUserCultureFromEcpCookie(RequestContext requestContext, EcpUserSettings settingToReload) { CultureInfo cultureInfo = null; if (UserContextUtilities.IsFlagSet((int)settingToReload, 32)) { HttpCookie httpCookie = HttpContext.Current.Request.Cookies["mkt"]; if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value)) { CultureInfo cultureInfo2 = CultureInfo.GetCultureInfo(httpCookie.Value); if (ClientCultures.IsSupportedCulture(cultureInfo2)) { cultureInfo = cultureInfo2; } } if (cultureInfo == null) { ExTraceGlobals.UserContextCallTracer.TraceDebug(0L, "UserContext.ReloadUserSettings: The culture cookie doesn't have a valid value."); } } return(cultureInfo); }
internal static UserContextKey CreateNew(OwaIdentity logonIdentity, OwaIdentity mailboxIdentity, HttpContext httpContext) { if (logonIdentity == null) { throw new ArgumentNullException("logonIdentity"); } string uniqueId = logonIdentity.UniqueId; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("userContextLogonIdentityName=<PII>{0}</PII>", logonIdentity.SafeGetRenderableName()); if (logonIdentity.UserSid != null) { stringBuilder.AppendFormat("userContextLogonIdentitySid=<PII>{0}</PII>", logonIdentity.UserSid.ToString()); } string text = null; if (mailboxIdentity != null) { text = mailboxIdentity.UniqueId; stringBuilder.AppendFormat("userContextMbIdentityName=<PII>{0}</PII>", mailboxIdentity.SafeGetRenderableName()); if (mailboxIdentity.UserSid != null) { stringBuilder.AppendFormat("userContextMbIdentitySid=<PII>{0}</PII>", mailboxIdentity.UserSid.ToString()); } } try { string text2 = stringBuilder.ToString(); if (LiveIdAuthenticationModule.IdentityTracingEnabled && !string.IsNullOrWhiteSpace(text2)) { httpContext.Response.AppendToLog(text2); } } catch (Exception) { } return(UserContextKey.Create(UserContextUtilities.GetNewGuid(), uniqueId, text)); }
internal static OAuthCredentials GetOAuthCredential(string sipUri) { ProxyAddress proxyAddress = ProxyAddress.Parse(sipUri); string sipDomain = OnlineMeetingHelper.GetSipDomain(sipUri); if (string.IsNullOrEmpty(sipDomain)) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] Unable to determine domain from sip uri: {0}", sipUri); throw new OwaException(string.Format("Unable to determine domain from sip uri: {0}", sipUri)); } MiniRecipient miniRecipient = null; IRecipientSession recipientSession = null; try { recipientSession = UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, sipDomain, null); } catch (OwaADObjectNotFoundException innerException) { throw new OwaException(string.Format("Couldn't create a scoped recipient session for {0}", sipDomain), innerException); } try { miniRecipient = recipientSession.FindByProxyAddress <MiniRecipient>(proxyAddress); if (miniRecipient == null) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] IRecipientSession.FindByProxyAddress() unable to find to recipient with address: {0}", sipUri); throw new OwaException(string.Format("Couldn't find a match for {0}", proxyAddress.ToString())); } } catch (NonUniqueRecipientException innerException2) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] Couldn't find a unique match for: {0}", sipUri); throw new OwaException(string.Format("Couldn't find a unique match for {0}", proxyAddress.ToString()), innerException2); } return(OAuthCredentials.GetOAuthCredentialsForAppActAsToken(miniRecipient.OrganizationId, miniRecipient, sipDomain)); }
// Token: 0x06000791 RID: 1937 RVA: 0x00018254 File Offset: 0x00016454 internal static bool TryParseCookieValue(string cookieValue, out string userContextId, out string mailboxUniqueKey) { userContextId = null; mailboxUniqueKey = null; if (cookieValue.Length == 32) { userContextId = cookieValue; } else { if (cookieValue.Length < 34) { return(false); } int num = cookieValue.IndexOf('&'); if (num != 32) { return(false); } num++; userContextId = cookieValue.Substring(0, num - 1); string tokenValidBase64String = cookieValue.Substring(num, cookieValue.Length - num); byte[] bytes = null; try { bytes = UserContextUtilities.ValidTokenBase64Decode(tokenValidBase64String); } catch (FormatException) { return(false); } UTF8Encoding utf8Encoding = new UTF8Encoding(); mailboxUniqueKey = utf8Encoding.GetString(bytes); } return(UserContextCookie.IsValidUserContextId(userContextId)); }
private MobileDevicePolicyData ReadAggregatedMobileDevicePolicyData(UserConfigurationManager.IAggregationContext ctx, ExchangePrincipal principal) { return(UserContextUtilities.ReadAggregatedType <MobileDevicePolicyData>(ctx, "OWA.MobileDevicePolicy", () => MobileDevicePolicyDataFactory.GetPolicyData(principal))); }
// Token: 0x060007CF RID: 1999 RVA: 0x00019A94 File Offset: 0x00017C94 internal static IRecipientSession CreateScopedRecipientSession(bool readOnly, ConsistencyMode consistencyMode, string domain, OrganizationId orgId) { ADSessionSettings sessionSettings = UserContextUtilities.CreateScopedSessionSettings(domain, orgId); return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, CultureInfo.InvariantCulture.LCID, readOnly, consistencyMode, null, sessionSettings, 350, "CreateScopedRecipientSession", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\common\\UserContextUtilities.cs")); }
private OwaOrgConfigData ReadAggregatedOrgConfigData(UserConfigurationManager.IAggregationContext ctx, OrganizationId organizationId) { return(UserContextUtilities.ReadAggregatedType <OwaOrgConfigData>(ctx, "OWA.OrgConfig", () => UserContextUtilities.GetOrgConfigTypeFromAd(organizationId))); }
private static DispatchStepResult HandleLanguagePost(RequestContext requestContext, CultureInfo culture, string timeZoneKeyName, bool isOptimized, string destination) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::HandleLanguagePost] entry."); if (requestContext.UserContext == null) { throw new OwaInvalidOperationException("UserContext should be created by the time language post is handled"); } requestContext.LanguagePostUserCulture = culture; requestContext.HttpContext.Response.Cookies.Set(new HttpCookie("mkt", culture.Name)); if (!string.IsNullOrWhiteSpace(destination) && (destination.StartsWith("/ecp/", StringComparison.OrdinalIgnoreCase) || destination.StartsWith("/owa/", StringComparison.OrdinalIgnoreCase))) { requestContext.DestinationUrl = destination; } else { requestContext.DestinationUrl = string.Empty; } Culture.InternalSetThreadPreferredCulture(culture); MailboxSession mailboxSession = null; try { ExTraceGlobals.CoreCallTracer.TraceDebug <string, bool>(0L, "[RequestDispatcher::HandleLanguagePost] Attempting to save the timeZoneKeyName (tzid={0}) and isOptimized={1} in the mailbox.", timeZoneKeyName, isOptimized); OwaIdentity logonIdentity = requestContext.UserContext.LogonIdentity; mailboxSession = logonIdentity.CreateMailboxSession(requestContext.UserContext.ExchangePrincipal, culture); if (requestContext.UserContext.IsExplicitLogon && !mailboxSession.CanActAsOwner) { throw new OwaExplicitLogonException("User has no access rights to the mailbox", "ErrorExplicitLogonAccessDenied"); } try { ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "[RequestDispatcher::HandleLanguagePost] Trying to save the culture to the AD (lcid={0})", culture.LCID); PreferredCultures preferredCultures = new PreferredCultures(requestContext.UserContext.ExchangePrincipal.PreferredCultures); preferredCultures.AddSupportedCulture(culture, new Predicate <CultureInfo>(ClientCultures.IsSupportedCulture)); Culture.SetPreferredCulture(requestContext.UserContext.ExchangePrincipal, preferredCultures, mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent)); requestContext.UserContext.ExchangePrincipal = requestContext.UserContext.ExchangePrincipal.WithPreferredCultures(preferredCultures); } catch (Exception ex) { if (!(ex is ADOperationException) && !(ex is InvalidOperationException)) { throw; } requestContext.FailedToSaveUserCulture = true; if (ExTraceGlobals.CoreCallTracer.IsTraceEnabled(TraceType.ErrorTrace)) { StringBuilder stringBuilder = new StringBuilder("Failed to save user's culture in the AD."); stringBuilder.Append("\n\nException: "); stringBuilder.Append(ex.GetType().ToString()); stringBuilder.Append("\n"); stringBuilder.Append(ex.Message); stringBuilder.Append(")"); if (!string.IsNullOrEmpty(ex.StackTrace)) { stringBuilder.Append("\n\nCallstack:\n"); stringBuilder.Append(ex.StackTrace); } ExTraceGlobals.CoreCallTracer.TraceError(0L, stringBuilder.ToString()); } } UserOptionsType userOptionsType = new UserOptionsType(); bool flag = true; try { userOptionsType.Load(mailboxSession, false, false); } catch (QuotaExceededException ex2) { ExTraceGlobals.UserContextCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::HandleLanguagePost] UserOptions.LoadAll failed. Exception: {0}.", ex2.Message); flag = false; } userOptionsType.TimeZone = timeZoneKeyName; userOptionsType.IsOptimizedForAccessibility = isOptimized; userOptionsType.UserOptionsMigrationState = UserOptionsMigrationState.WorkingHoursTimeZoneFixUp; if (flag) { UserConfigurationPropertyDefinition propertyDefinition = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.TimeZone); UserConfigurationPropertyDefinition propertyDefinition2 = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.IsOptimizedForAccessibility); UserConfigurationPropertyDefinition propertyDefinition3 = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.UserOptionsMigrationState); userOptionsType.Commit(mailboxSession, new UserConfigurationPropertyDefinition[] { propertyDefinition, propertyDefinition2, propertyDefinition3 }); } RequestDispatcher.InitializeFavorites(mailboxSession); } finally { if (mailboxSession != null) { UserContextUtilities.DisconnectStoreSession(mailboxSession); mailboxSession.Dispose(); mailboxSession = null; } } return(DispatchStepResult.Continue); }
// Token: 0x06000794 RID: 1940 RVA: 0x00018444 File Offset: 0x00016644 private static bool IsValidUserContextId(string userContextId) { return(UserContextUtilities.IsValidGuid(userContextId)); }
private void InternalAfterReceiveRequest(HttpRequest httpRequest, string methodName, object request) { try { ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] called for method name: {0}", methodName); CallContext.ClearCallContextForCurrentThread(); Globals.UpdateErrorTracingConfiguration(); OwaApplication.GetRequestDetailsLogger.ActivityScope.SetProperty(ExtensibleLoggerMetadata.EventId, methodName); OwaServiceMessage message = new OwaServiceMessage(httpRequest, request); message.Headers.Action = methodName; message.Properties["HttpOperationName"] = methodName; OwaMessageHeaderProcessor messageHeaderProcessor = new OwaMessageHeaderProcessor(); bool flag = OWAMessageInspector.RequestNeedsHeaderProcessing(methodName); bool flag2 = OWAMessageInspector.RequestNeedsQueryStringProcessing(methodName); bool flag3 = OWAMessageInspector.RequestNeedsHttpHeaderProcessing(methodName); ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] processing message headers"); if (flag || flag2 || flag3) { if (flag) { messageHeaderProcessor.ProcessMessageHeaders(message); messageHeaderProcessor.ProcessEwsVersionFromHttpHeaders(message); } else if (flag2) { messageHeaderProcessor.ProcessMessageHeadersFromQueryString(message); } else if (flag3) { messageHeaderProcessor.ProcessHttpHeaders(message, ExchangeVersion.Exchange2013); } } message.Properties["MessageHeaderProcessor"] = messageHeaderProcessor; message.Properties["ConnectionCostType"] = 0; WebMethodEntry jsonWebMethodEntry; if (!OWAMessageInspector.MethodNameToWebMethodEntryMap.Member.TryGetValue(methodName, out jsonWebMethodEntry)) { jsonWebMethodEntry = WebMethodEntry.JsonWebMethodEntry; } message.Properties["WebMethodEntry"] = jsonWebMethodEntry; ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] creating CallContext"); CallContext callContext = OwaApplication.GetRequestDetailsLogger.TrackLatency <CallContext>(ServiceLatencyMetadata.CallContextInitLatency, () => CallContextUtilities.CreateCallContext(message, messageHeaderProcessor, true, "")); callContext.IsOwa = true; ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] CallContext created"); callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsMowaClient, OfflineClientRequestUtilities.IsRequestFromMOWAClient(callContext.HttpContext.Request, callContext.HttpContext.Request.UserAgent) ? 1 : 0); bool?flag4 = new bool?(OfflineClientRequestUtilities.IsRequestFromOfflineClient(callContext.HttpContext.Request)); if (flag4 != null) { callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsOfflineEnabled, flag4.Value ? 1 : 0); } callContext.OwaExplicitLogonUser = UserContextUtilities.GetExplicitLogonUser(HttpContext.Current); if (string.IsNullOrEmpty(callContext.OwaExplicitLogonUser)) { OWAMessageInspector.CheckThatUserProvisionedDevice(methodName, callContext); OWAMessageInspector.CheckMowaRemoteWipe(methodName, callContext); OWAMessageInspector.CheckClientVersion(callContext); OWAMessageInspector.CheckMowaDisabled(callContext); OWAMessageInspector.CheckMobileDevicePolicyIsCorrect(methodName, callContext); } OWAMessageInspector.MarkResponseNonCacheable(methodName); callContext.WorkloadType = WorkloadType.Owa; callContext.UsingWcfDispatcher = false; callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.UsingWcfHttpHandler, 0); if (ExchangeVersion.Current == ExchangeVersion.Exchange2007) { ExchangeVersion.Current = ExchangeVersion.Exchange2013; } if (OWAMessageInspector.ShouldCreateUserContext(callContext)) { UserContext userContext = UserContextManager.GetMailboxContext(callContext.HttpContext, callContext.EffectiveCaller, true) as UserContext; if (userContext != null) { callContext.OwaCulture = userContext.UserCulture; if (userContext.FeaturesManager != null) { callContext.FeaturesManager = userContext.FeaturesManager; if (userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled) { callContext.OwaUserContextKey = userContext.Key.ToString(); } } } } } catch (LocalizedException ex) { ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, LocalizedException>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] Caught localized exception trying to process message. Type: {0} Exception: {1}", ex.GetType().Name, ex); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OWAMessageInspector", null, "InternalAfterReceiveRequest", string.Format("OwaServiceFaultException_InnerException - {0}", ex))); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex, "OwaServiceFaultException_InnerException"); throw OwaFaultExceptionUtilities.CreateFault(ex); } catch (Exception ex2) { ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, Exception>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] Caught exception trying to process message. Type: {0} Exception: {1}", ex2.GetType().Name, ex2); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex2, "OwaServiceFaultException_InnerException"); throw; } ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] completed"); }
// Token: 0x06001058 RID: 4184 RVA: 0x0003EC98 File Offset: 0x0003CE98 public virtual Uri GetDestinationUri(string user) { Uri result; if (HttpProxyBackEndHelper.TryGetBackEndWebServicesUrlFromSmtp(user, (SmtpAddress address) => UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, address.Domain, null), out result)) { return(result); } return(null); }
private object InternalAfterReceiveRequest(ref Message request, RequestDetailsLogger logger) { try { Globals.UpdateErrorTracingConfiguration(); IActivityScope activityScope = OwaApplication.GetRequestDetailsLogger.ActivityScope; HttpRequestMessageProperty httpRequestMessageProperty = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name]; string value = httpRequestMessageProperty.Headers[OWADispatchOperationSelector.Action]; activityScope.SetProperty(ExtensibleLoggerMetadata.EventId, value); string value2 = httpRequestMessageProperty.Headers["X-OWA-ClientBuildVersion"]; if (!string.IsNullOrEmpty(value2)) { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, value2); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, "NA"); } string value3 = httpRequestMessageProperty.Headers["X-EWS-TargetVersion"]; if (!string.IsNullOrEmpty(value3)) { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, value3); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, "NA"); } JsonMessageHeaderProcessor jsonMessageHeaderProcessor = new JsonMessageHeaderProcessor(); string methodName = OWAMessageInspector.GetMethodName(request); bool flag = OWAMessageInspector.RequestNeedsHeaderProcessing(methodName); bool flag2 = OWAMessageInspector.RequestNeedsQueryStringProcessing(methodName); bool flag3 = OWAMessageInspector.RequestNeedsHttpHeaderProcessing(methodName); if (flag || flag2 || flag3) { using (MessageBuffer messageBuffer = request.CreateBufferedCopy(int.MaxValue)) { Message request2 = messageBuffer.CreateMessage(); if (flag) { jsonMessageHeaderProcessor.ProcessMessageHeaders(request2); jsonMessageHeaderProcessor.ProcessEwsVersionFromHttpHeaders(request); } else if (flag2) { jsonMessageHeaderProcessor.ProcessMessageHeadersFromQueryString(request2); } else if (flag3) { jsonMessageHeaderProcessor.ProcessHttpHeaders(request, ExchangeVersion.Exchange2013); } request = messageBuffer.CreateMessage(); } } request.Properties["MessageHeaderProcessor"] = jsonMessageHeaderProcessor; request.Properties["ConnectionCostType"] = 0; WebMethodEntry jsonWebMethodEntry; if (!OWAMessageInspector.MethodNameToWebMethodEntryMap.Member.TryGetValue(methodName, out jsonWebMethodEntry)) { jsonWebMethodEntry = WebMethodEntry.JsonWebMethodEntry; } request.Properties["WebMethodEntry"] = jsonWebMethodEntry; MessageHeaderProcessor messageHeaderProcessor = (MessageHeaderProcessor)request.Properties["MessageHeaderProcessor"]; messageHeaderProcessor.MarkMessageHeaderAsUnderstoodIfExists(request, "RequestServerVersion", "http://schemas.microsoft.com/exchange/services/2006/types"); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitBegin); Message requestRef = request; CallContext callContext = OwaApplication.GetRequestDetailsLogger.TrackLatency <CallContext>(ServiceLatencyMetadata.CallContextInitLatency, () => CallContextUtilities.CreateCallContext(requestRef, messageHeaderProcessor, true, "")); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitEnd); callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsMowaClient, OfflineClientRequestUtilities.IsRequestFromMOWAClient(callContext.HttpContext.Request, callContext.HttpContext.Request.UserAgent) ? 1 : 0); bool?flag4 = new bool?(OfflineClientRequestUtilities.IsRequestFromOfflineClient(callContext.HttpContext.Request)); if (flag4 != null) { callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsOfflineEnabled, flag4.Value ? 1 : 0); } callContext.OwaExplicitLogonUser = UserContextUtilities.GetExplicitLogonUser(HttpContext.Current); if (string.IsNullOrEmpty(callContext.OwaExplicitLogonUser)) { OWAMessageInspector.CheckThatUserProvisionedDevice(methodName, callContext); OWAMessageInspector.CheckMowaRemoteWipe(methodName, callContext); OWAMessageInspector.CheckClientVersion(callContext); OWAMessageInspector.CheckMowaDisabled(callContext); OWAMessageInspector.CheckMobileDevicePolicyIsCorrect(methodName, callContext); } OWAMessageInspector.MarkResponseNonCacheable(methodName); callContext.WorkloadType = WorkloadType.Owa; callContext.UsingWcfDispatcher = true; callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.UsingWcfHttpHandler, 1); if (ExchangeVersion.Current == ExchangeVersion.Exchange2007) { ExchangeVersion.Current = ExchangeVersion.Exchange2013; } if (OWAMessageInspector.ShouldCreateUserContext(callContext)) { UserContext userContext = UserContextManager.GetMailboxContext(callContext.HttpContext, callContext.EffectiveCaller, true) as UserContext; if (userContext != null) { callContext.OwaCulture = userContext.UserCulture; if (userContext.FeaturesManager != null) { callContext.FeaturesManager = userContext.FeaturesManager; if (userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled) { callContext.OwaUserContextKey = userContext.Key.ToString(); } } } } } catch (LocalizedException ex) { Microsoft.Exchange.Diagnostics.Components.Services.ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, string>((long)this.GetHashCode(), "[OWAMessageInspector::AfterReceiveRequest] Caught localized exception trying to create callcontext. Class: {0}, Message: {1}", ex.GetType().FullName, ex.Message); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OWAMessageInspector", null, "InternalAfterReceiveRequest", string.Format("OwaServiceFaultException_InnerException - {0}", ex))); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex, "OwaServiceFaultException_InnerException"); throw OwaFaultExceptionUtilities.CreateFault(ex); } return(null); }
internal static OwaFlightConfigData ReadAggregatedFlightConfigData(UserConfigurationManager.IAggregationContext aggregator, OrganizationId orgId) { return(UserContextUtilities.ReadAggregatedType <OwaFlightConfigData>(aggregator, "OWA.FlightConfiguration", () => UserContext.ReadFlightConfigDataFromAD(orgId))); }
// Token: 0x06000805 RID: 2053 RVA: 0x0001A808 File Offset: 0x00018A08 internal static WacConfigData ReadAggregatedWacData(UserContext userContext, UserConfigurationManager.IAggregationContext ctx) { return(UserContextUtilities.ReadAggregatedType <WacConfigData>(ctx, "OWA.WacData", () => AttachmentPolicy.GetWacConfigData(userContext))); }
private static void CreateUserContext(HttpContext httpContext, UserContextKey userContextKey, AuthZClientInfo effectiveCaller, out IMailboxContext userContext, out UserContextStatistics userContextStats) { Stopwatch stopwatch = Stopwatch.StartNew(); userContextStats = new UserContextStatistics(); userContext = null; OwaIdentity owaIdentity = null; OwaIdentity owaIdentity2 = null; OwaIdentity owaIdentity3 = null; try { try { OwaIdentity owaIdentity4 = OwaIdentity.ResolveLogonIdentity(httpContext, effectiveCaller); owaIdentity2 = owaIdentity4; string explicitLogonUser = UserContextUtilities.GetExplicitLogonUser(httpContext); if (!string.IsNullOrEmpty(explicitLogonUser)) { ExTraceGlobals.UserContextTracer.TraceDebug <string>(0L, "Created partial mailbox identity from SMTP address={0}", explicitLogonUser); owaIdentity = OwaIdentity.CreateOwaIdentityFromExplicitLogonAddress(explicitLogonUser); owaIdentity3 = owaIdentity; } if (userContextKey == null) { userContextKey = UserContextKey.CreateNew(owaIdentity4, owaIdentity, httpContext); ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Creating new user context key: {0}", userContextKey); } else { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Reusing user context key: {0}", userContextKey); } OwaRWLockWrapper userContextKeyLock = UserContextManager.GetUserContextKeyLock(userContextKey.ToString()); if (userContextKeyLock == null) { userContextStats.Error = UserContextCreationError.UnableToAcquireOwaRWLock; throw new OwaLockException("UserContextManger::CreateUserContext was not able to create a lock"); } if (userContextKeyLock.LockWriterElastic(6000)) { try { userContext = UserContextManager.GetMailboxContextFromCache(userContextKey, false); if (userContext != null && userContext.TerminationStatus == UserContextTerminationStatus.TerminatePending) { UserContextManager.TerminateSession(userContext, userContext.AbandonedReason); userContext = null; } if (userContext == null) { userContextStats.Created = true; ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "User context was not found in the cache, creating one. UserContextKey: {0}", userContextKey); bool flag = false; try { if (UserContextManager.IsSharedContextKey(userContextKey)) { userContext = new SharedContext(userContextKey, httpContext.Request.UserAgent); } else { userContext = new UserContext(userContextKey, httpContext.Request.UserAgent); } Stopwatch stopwatch2 = Stopwatch.StartNew(); userContext.Load(owaIdentity4, owaIdentity, userContextStats); userContextStats.LoadTime = (int)stopwatch2.ElapsedMilliseconds; UserContextManager.InsertIntoCache(httpContext, userContext); owaIdentity2 = null; owaIdentity3 = null; string userName = userContext.LogonIdentity.UserSid.ToString(); PerformanceCounterManager.UpdatePerfCounteronUserContextCreation(userName, false, false, Globals.ArePerfCountersEnabled); flag = true; } finally { if (!flag) { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "User context creation failed. UserContextKey: {0}", userContextKey); if (userContext != null) { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Disposing user context. UserContextKey: {0}", userContextKey); userContext.Dispose(); userContext.State = UserContextState.Abandoned; } } } } goto IL_1EA; } finally { userContextKeyLock.ReleaseWriterLock(); } goto IL_1D4; IL_1EA: goto IL_237; } IL_1D4: userContextStats.Error = UserContextCreationError.UnableToAcquireOwaRWLock; throw new OwaLockTimeoutException("UserContextManger::CreateUserContext was not able to acquire a rw lock", null, null); } catch (OwaIdentityException ex) { userContextStats.Error = UserContextCreationError.UnableToResolveLogonIdentity; OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UserContext", userContext, "UserContextManager.CreateUserContext", ex.ToString())); throw; } catch (Exception ex2) { OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UserContext", userContext, "UserContextManager.CreateUserContext", ex2.ToString())); throw; } IL_237 :; } finally { if (owaIdentity2 != null) { owaIdentity2.Dispose(); } if (owaIdentity3 != null) { owaIdentity3.Dispose(); } stopwatch.Stop(); userContextStats.AcquireLatency = (int)stopwatch.ElapsedMilliseconds; httpContext.Items["UserContextStatistics"] = userContextStats; } }
// Token: 0x0600211A RID: 8474 RVA: 0x0007953C File Offset: 0x0007773C internal SessionSettingsType(UserContext userContext, MailboxSession mailboxSession, UserAgent userAgent, CallContext callContext, UMSettingsData umSettings, OwaHelpUrlData helpUrlData) { if (userContext == null) { throw new ArgumentNullException("userContext"); } if (userContext.ExchangePrincipal == null) { throw new OwaInvalidRequestException("userContext.ExchangePrincipal is null"); } StorePerformanceCountersCapture countersCapture = StorePerformanceCountersCapture.Start(mailboxSession); this.userDisplayName = userContext.ExchangePrincipal.MailboxInfo.DisplayName; this.userEmailAddress = userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(); this.userLegacyExchangeDN = userContext.ExchangePrincipal.LegacyDn; this.hasArchive = this.UserHasArchive(userContext.ExchangePrincipal); this.archiveDisplayName = (this.hasArchive ? userContext.ExchangePrincipal.GetArchiveMailbox().ArchiveName : string.Empty); IEnumerable <string> source = from emailAddress in userContext.ExchangePrincipal.MailboxInfo.EmailAddresses select emailAddress.AddressString; if (source.Any <string>()) { this.userProxyAddresses = source.ToArray <string>(); } this.UpdateMailboxQuotaLimits(mailboxSession); this.isBposUser = userContext.IsBposUser; this.userSipUri = userContext.SipUri; this.userPrincipalName = userContext.UserPrincipalName; this.isGallatin = SessionSettingsType.GetIsGallatin(); if (userContext.ExchangePrincipal.MailboxInfo.OrganizationId != null) { this.TenantGuid = userContext.ExchangePrincipal.MailboxInfo.OrganizationId.GetTenantGuid().ToString(); } if (userContext.LogEventCommonData != null) { this.TenantDomain = userContext.LogEventCommonData.TenantDomain; } OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsMisc, countersCapture, true); int?maximumMessageSize = SessionSettingsType.GetMaximumMessageSize(mailboxSession); this.maxMessageSizeInKb = ((maximumMessageSize != null) ? maximumMessageSize.Value : 5120); OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsMessageSize, countersCapture, true); this.isPublicLogon = UserContextUtilities.IsPublicRequest(callContext.HttpContext.Request); OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsIsPublicLogon, countersCapture, true); ADUser aduser = null; if (userContext.IsExplicitLogon) { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(), 303, ".ctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\types\\SessionSettingsType.cs"); aduser = (DirectoryHelper.ReadADRecipient(userContext.ExchangePrincipal.MailboxInfo.MailboxGuid, userContext.ExchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession) as ADUser); if (aduser != null && aduser.SharePointUrl != null) { this.sharePointUrl = aduser.SharePointUrl.ToString(); this.sharePointTitle = aduser.DisplayName; } } OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.TeamMailbox, countersCapture, true); if (userContext.LogonIdentity != null) { OWAMiniRecipient owaminiRecipient = userContext.LogonIdentity.GetOWAMiniRecipient(); this.LogonEmailAddress = string.Empty; if (owaminiRecipient != null) { SmtpAddress primarySmtpAddress = owaminiRecipient.PrimarySmtpAddress; this.LogonEmailAddress = owaminiRecipient.PrimarySmtpAddress.ToString(); } OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetOWAMiniRecipient, countersCapture, false); } this.MailboxGuid = userContext.ExchangePrincipal.MailboxInfo.MailboxGuid.ToString(); this.isExplicitLogon = userContext.IsExplicitLogon; this.isExplicitLogonOthersMailbox = false; this.canActAsOwner = true; countersCapture = StorePerformanceCountersCapture.Start(mailboxSession); this.SetDefaultFolderMapping(mailboxSession); OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SetDefaultFolderMapping, countersCapture, false); CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture; this.userCulture = currentUICulture.Name; this.isUserCultureSpeechEnabled = Culture.IsCultureSpeechEnabled(currentUICulture); this.isUserCultureRightToLeft = currentUICulture.TextInfo.IsRightToLeft; countersCapture = StorePerformanceCountersCapture.Start(mailboxSession); this.playOnPhoneDialString = umSettings.PlayOnPhoneDialString; this.isRequireProtectedPlayOnPhone = umSettings.IsRequireProtectedPlayOnPhone; this.isUMEnabled = umSettings.IsUMEnabled; if (SyncUtilities.IsDatacenterMode()) { SendAsSubscriptionsAndPeopleConnectResult allSendAsSubscriptionsAndPeopleConnect = SubscriptionManager.GetAllSendAsSubscriptionsAndPeopleConnect(mailboxSession); List <PimAggregationSubscription> pimSendAsAggregationSubscriptionList = allSendAsSubscriptionsAndPeopleConnect.PimSendAsAggregationSubscriptionList; this.PeopleConnectionsExist = allSendAsSubscriptionsAndPeopleConnect.PeopleConnectionsExist; List <AggregatedAccountInfo> list = null; if (aduser == null && userContext.ExchangePrincipal != null) { IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(), 375, ".ctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\types\\SessionSettingsType.cs"); aduser = (DirectoryHelper.ReadADRecipient(userContext.ExchangePrincipal.MailboxInfo.MailboxGuid, userContext.ExchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession2) as ADUser); } if (aduser != null) { AggregatedAccountHelper aggregatedAccountHelper = new AggregatedAccountHelper(mailboxSession, aduser); list = aggregatedAccountHelper.GetListOfAccounts(); } int capacity = pimSendAsAggregationSubscriptionList.Count + ((list != null) ? list.Count : 0); List <ConnectedAccountInfo> list2 = new List <ConnectedAccountInfo>(capacity); foreach (PimAggregationSubscription pimAggregationSubscription in pimSendAsAggregationSubscriptionList) { list2.Add(new ConnectedAccountInfo { SubscriptionGuid = pimAggregationSubscription.SubscriptionGuid, EmailAddress = SessionSettingsType.DecodeIdnDomain(pimAggregationSubscription.UserEmailAddress), DisplayName = pimAggregationSubscription.UserDisplayName }); } if (list != null) { foreach (AggregatedAccountInfo aggregatedAccountInfo in list) { bool flag = false; string aggregatedAccountEmail = SessionSettingsType.DecodeIdnDomain(aggregatedAccountInfo.SmtpAddress); if (!string.IsNullOrWhiteSpace(aggregatedAccountEmail)) { if (list2.Find((ConnectedAccountInfo account) => StringComparer.InvariantCultureIgnoreCase.Equals(account.EmailAddress, aggregatedAccountEmail)) != null) { break; } if (!flag) { list2.Add(new ConnectedAccountInfo { SubscriptionGuid = aggregatedAccountInfo.RequestGuid, EmailAddress = aggregatedAccountEmail, DisplayName = aggregatedAccountEmail }); } } } } this.connectedAccountInfos = list2.ToArray(); } OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.IsDatacenterMode, countersCapture, true); this.helpUrl = helpUrlData.HelpUrl; this.isPublicComputerSession = UserContextUtilities.IsPublicComputerSession(callContext.HttpContext); string errorString = string.Empty; try { IMailboxInfo mailboxInfo = userContext.ExchangePrincipal.MailboxInfo; TenantPublicFolderConfiguration tenantPublicFolderConfiguration = null; if (TenantPublicFolderConfigurationCache.Instance.TryGetValue(mailboxInfo.OrganizationId, out tenantPublicFolderConfiguration)) { ADObjectId defaultPublicFolderMailbox = userContext.ExchangePrincipal.DefaultPublicFolderMailbox; PublicFolderRecipient publicFolderRecipient = tenantPublicFolderConfiguration.GetPublicFolderRecipient(mailboxInfo.MailboxGuid, defaultPublicFolderMailbox); if (publicFolderRecipient != null) { if (publicFolderRecipient.IsLocal) { this.DefaultPublicFolderMailbox = publicFolderRecipient.PrimarySmtpAddress.ToString(); } else if (publicFolderRecipient.ObjectId == null) { errorString = "publicFolderRecipient not local and ObjectId null"; } else { errorString = "publicFolderRecipient not local and ObjectId " + publicFolderRecipient.ObjectId.ObjectGuid; } } else { errorString = "publicFolderRecipient null"; } } } catch (LocalizedException ex) { errorString = ex.ToString(); } finally { OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.DefaultPublicFolderMailbox, countersCapture, true, errorString); } }
internal override ExchangePrincipal InternalCreateExchangePrincipal() { ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "OwaClientSecurityContextIdentity.CreateExchangePrincipal Creating scoped AD session for {0}", (base.UserOrganizationId == null) ? this.DomainName : base.UserOrganizationId.ToString()); bool flag = HttpContext.Current != null && UserAgentUtilities.IsMonitoringRequest(HttpContext.Current.Request.UserAgent); ExchangePrincipal result; try { ADSessionSettings sessionSettings = (base.UserOrganizationId == null) ? UserContextUtilities.CreateScopedSessionSettings(this.DomainName, null) : UserContextUtilities.CreateScopedSessionSettings(null, base.UserOrganizationId); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 417, "InternalCreateExchangePrincipal", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\common\\OwaClientSecurityContextIdentity.cs"); if (flag) { TimeSpan value = TimeSpan.FromSeconds((double)OwaClientSecurityContextIdentity.ADTimeoutForExchangePrincipalInstantiation.Value); ExTraceGlobals.CoreCallTracer.TraceDebug <double>(0L, "OwaClientSecurityContextIdentity.CreateExchangePrincipal Reduced AD timeout to {0} seconds", value.TotalSeconds); tenantOrRootOrgRecipientSession.ClientSideSearchTimeout = new TimeSpan?(value); } ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaClientSecurityContextIdentity.CreateExchangePrincipal Calling ExchangePrincipal.FromUserSid"); try { result = ExchangePrincipal.FromUserSid(tenantOrRootOrgRecipientSession, this.UserSid); } catch (UserHasNoMailboxException ex) { ADUser aduser = tenantOrRootOrgRecipientSession.FindBySid(this.UserSid) as ADUser; ex.Data.Add("PrimarySmtpAddress", this.logonName); if (aduser == null) { throw; } if (aduser.RecipientType == RecipientType.MailUser && aduser.SKUAssigned != true) { throw new OwaUserHasNoMailboxAndNoLicenseAssignedException(ex.Message, ex.InnerException); } throw; } } catch (Exception ex2) { OwaDiagnostics.Logger.LogEvent(ClientsEventLogConstants.Tuple_OwaFailedToCreateExchangePrincipal, string.Empty, new object[] { this.UserSid, flag, ex2 }); throw; } return(result); }