public static bool IsSmsSyncEnabled(UserContext userContext, out E164Number smsSyncPhoneNumber, out string smsSyncDeviceProtocol, out string smsSyncDeviceType, out string smsSyncDeviceId, out string smsSyncDeviceFriendlyName) { smsSyncPhoneNumber = null; smsSyncDeviceProtocol = null; smsSyncDeviceType = null; smsSyncDeviceId = null; smsSyncDeviceFriendlyName = null; bool result; using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(userContext.MailboxSession)) { TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(userContext.ExchangePrincipal.ObjectId); if (textMessagingAccount.EasEnabled && null != textMessagingAccount.EasPhoneNumber) { smsSyncPhoneNumber = textMessagingAccount.EasPhoneNumber; smsSyncDeviceProtocol = textMessagingAccount.EasDeviceProtocol; smsSyncDeviceType = textMessagingAccount.EasDeviceType; smsSyncDeviceId = textMessagingAccount.EasDeviceId; smsSyncDeviceFriendlyName = textMessagingAccount.EasDeviceName; result = true; } else { result = false; } } return(result); }
// Token: 0x06000AB0 RID: 2736 RVA: 0x00045C88 File Offset: 0x00043E88 private static bool TryReadTextMessagingAccount(MailboxSession session, out TextMessagingAccount account) { using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(session)) { account = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(session.MailboxOwner.ObjectId); } return(account != null); }
// Token: 0x06000A64 RID: 2660 RVA: 0x000445CC File Offset: 0x000427CC internal static bool TryLoadTextNotification(MailboxSession session, out CalendarNotification textNotification) { textNotification = null; using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(session)) { textNotification = (CalendarNotification)versionedXmlDataProvider.Read <CalendarNotification>(session.MailboxOwner.ObjectId); } return(textNotification != null); }
// Token: 0x06000A63 RID: 2659 RVA: 0x00044578 File Offset: 0x00042778 internal static bool TryLoadTextMessagingAccount(MailboxSession session, out TextMessagingAccount textMessagingAccount) { textMessagingAccount = null; using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(session)) { textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(session.MailboxOwner.ObjectId); } return(textMessagingAccount != null); }
internal static bool IsSMSConfigured(UserContext context) { bool result; using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(context.MailboxSession)) { ADObjectId objectId = context.MailboxSession.MailboxOwner.ObjectId; TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(objectId); result = (textMessagingAccount != null && textMessagingAccount.NotificationPhoneNumber != null && textMessagingAccount.NotificationPhoneNumberVerified); } return(result); }
// Token: 0x060008FC RID: 2300 RVA: 0x0003CE9C File Offset: 0x0003B09C private void SyncTextMessagingStates(long cookie) { this.UpdateAllUserSettings(cookie, delegate(MailboxSession mailboxSession, IRecipientSession recipientSession, ADUser user) { using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(mailboxSession)) { TextMessagingAccount account = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(user.Identity); if (this.ShouldContinue(cookie)) { TextMessagingHelper.UpdateAndSaveTextMessgaingStateOnAdUser(account, user, recipientSession); } } }, (ADRawEntry user) => user[ADRecipientSchema.TextMessagingState] == null); }
public void GetServiceProviderCapability() { IList <DeliveryPoint> list = null; using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(base.UserContext.MailboxSession)) { list = ((TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(base.UserContext.ExchangePrincipal.ObjectId)).TextMessagingSettings.PersonToPersonPreferences; } if (list.Count == 0) { return; } MobileServiceCapability mobileServiceCapability = null; try { MobileSession mobileSession = new MobileSession(base.UserContext.ExchangePrincipal, list); if (mobileSession.ServiceManagers != null && mobileSession.ServiceManagers.Count > 0) { mobileServiceCapability = mobileSession.ServiceManagers[0].GetCapabilityForRecipient(null); } } catch (MobileTransientException) { return; } catch (MobilePermanentException) { return; } if (mobileServiceCapability != null) { foreach (CodingSupportability codingSupportability in mobileServiceCapability.CodingSupportabilities) { if (codingSupportability.CodingScheme == CodingScheme.GsmDefault) { this.RenderScriptIntAssignment("a_iMax7Bit", codingSupportability.RadixPerPart); } else if (codingSupportability.CodingScheme == CodingScheme.Unicode) { this.RenderScriptIntAssignment("a_iMaxUncd", codingSupportability.RadixPerPart); } } int value = ((mobileServiceCapability.SupportedPartType & PartType.Concatenated) == PartType.Concatenated) ? 1 : 0; this.RenderScriptIntAssignment("a_fLngSms", value); return; } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(XsoStoreDataProviderBase.GetExchangePrincipalWithAdSessionSettingsForOrg(base.SessionSettings.CurrentOrganizationId, this.DataObject), (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "Compare-TextMessagingVerificationCode")) { TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read<TextMessagingAccount>(this.DataObject.Identity); IList<PossibleRecipient> effectivePossibleRecipients = textMessagingAccount.TextMessagingSettings.MachineToPersonMessagingPolicies.EffectivePossibleRecipients; if (effectivePossibleRecipients.Count == 0) { base.WriteError(new NotificationPhoneNumberAbsentException(this.Identity.ToString()), ErrorCategory.InvalidData, this.Identity); } PossibleRecipient possibleRecipient = effectivePossibleRecipients[0]; bool flag = false; if (string.IsNullOrEmpty(possibleRecipient.Passcode)) { base.WriteError(new VerificationCodeNeverSentException(this.Identity.ToString()), ErrorCategory.InvalidData, this.Identity); } DateTime utcNow = DateTime.UtcNow; if (6 <= PossibleRecipient.CountTimesSince(possibleRecipient.PasscodeVerificationFailedTimeHistory, utcNow - TimeSpan.FromDays(1.0), true)) { base.WriteError(new VerificationCodeTooManyFailedException(), ErrorCategory.InvalidData, this.Identity); } if (string.Equals(possibleRecipient.Passcode, this.VerificationCode, StringComparison.InvariantCultureIgnoreCase)) { possibleRecipient.SetAcknowledged(true); ADUser dataObject = this.DataObject; SmsSqmDataPointHelper.AddNotificationTurningOnDataPoint(SmsSqmSession.Instance, dataObject.Id, dataObject.LegacyExchangeDN, textMessagingAccount); } else { possibleRecipient.PasscodeVerificationFailedTimeHistory.Add(utcNow); flag = true; } versionedXmlDataProvider.Save(textMessagingAccount); if (flag) { base.WriteError(new VerificationCodeUnmatchException(this.VerificationCode), ErrorCategory.InvalidData, this.Identity); } else if (!textMessagingAccount.EasEnabled) { TextMessagingHelper.SendSystemTextMessage(versionedXmlDataProvider.MailboxSession, textMessagingAccount.NotificationPhoneNumber, Strings.CalendarNotificationConfirmation.ToString(textMessagingAccount.NotificationPreferredCulture ?? TextMessagingHelper.GetSupportedUserCulture(this.DataObject)), true); } } TaskLogger.LogExit(); }
// Token: 0x060009E4 RID: 2532 RVA: 0x00041508 File Offset: 0x0003F708 public void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item) { if (ObjectType.MAPI_MESSAGE == mapiEvent.ItemType && item == null) { ExTraceGlobals.UserSettingsTracer.TraceDebug <string>((long)this.GetHashCode(), "Event is MAPI_MESSAGE but item is null, message class is {0}", mapiEvent.ObjectClass); return; } if (!itemStore.Capabilities.CanHaveUserConfigurationManager) { ExTraceGlobals.UserSettingsTracer.TraceDebug <string>((long)this.GetHashCode(), "Mailbox sesstion does not have UserConfigurationManager capability. Possibly an alternate mailbox, {0}.", itemStore.MailboxOwnerLegacyDN); return; } if (this.IsMailboxDeletedOrDisconnected(mapiEvent)) { ExTraceGlobals.UserSettingsTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Processing Disabling event for mailbox {0} on database {1}", itemStore.MailboxOwnerLegacyDN, itemStore.MdbGuid); UserSettings settings = new UserSettings(itemStore); SystemMailbox systemMailbox = this.GetSystemMailbox(); if (systemMailbox != null) { NotificationFactories.Instance.UpdateSettingUnderSystemMailbox(settings, systemMailbox); } SettingsChangeListener.Instance.RaiseSettingsChangedEvent(settings, new InfoFromUserMailboxSession(itemStore)); return; } if (this.IsMailboxCreatedOrConnected(mapiEvent)) { ExTraceGlobals.UserSettingsTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Processing Enabling event for mailbox {0} on database {1}", itemStore.MailboxOwnerLegacyDN, itemStore.MdbGuid); using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(itemStore)) { TextMessagingAccount account = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(itemStore.MailboxOwner.ObjectId); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, itemStore.GetADSessionSettings(), 194, "HandleEvent", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\CalendarNotification\\SettingsChangeProcessor.cs"); ADRecipient adrecipient = tenantOrRootOrgRecipientSession.Read(itemStore.MailboxOwner.ObjectId); if (adrecipient != null) { TextMessagingHelper.UpdateAndSaveTextMessgaingStateOnAdUser(account, adrecipient, tenantOrRootOrgRecipientSession); } } } this.HandleSettingsEvent(itemStore); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(XsoStoreDataProviderBase.GetExchangePrincipalWithAdSessionSettingsForOrg(base.SessionSettings.CurrentOrganizationId, this.DataObject), (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "Send-TextMessagingVerificationCode")) { TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(this.DataObject.Identity); IList <PossibleRecipient> effectivePossibleRecipients = textMessagingAccount.TextMessagingSettings.MachineToPersonMessagingPolicies.EffectivePossibleRecipients; if (effectivePossibleRecipients.Count == 0) { base.WriteError(new NotificationPhoneNumberAbsentException(this.Identity.ToString()), ErrorCategory.InvalidData, this.Identity); } PossibleRecipient possibleRecipient = effectivePossibleRecipients[0]; DateTime utcNow = DateTime.UtcNow; if (3 <= PossibleRecipient.CountTimesSince(possibleRecipient.PasscodeSentTimeHistory, utcNow - TimeSpan.FromMinutes(30.0), false)) { this.WriteWarning(new VerificationCodeSentTooManyTimesException(textMessagingAccount.NotificationPhoneNumber.ToString()).LocalizedString); TaskLogger.LogExit(); return; } if (PossibleRecipient.CountTimesSince(possibleRecipient.PasscodeSentTimeHistory, utcNow - TimeSpan.FromDays(1.0), true) == 0) { if (DateTime.UtcNow > SendTextMessagingVerificationCode.timeCreatingRandom + TimeSpan.FromSeconds((double)SendTextMessagingVerificationCode.timeSpan)) { SendTextMessagingVerificationCode.random = new Random(); SendTextMessagingVerificationCode.timeCreatingRandom = DateTime.UtcNow; SendTextMessagingVerificationCode.timeSpan = new Random().Next(60); } possibleRecipient.SetPasscode(SendTextMessagingVerificationCode.random.Next(999999).ToString("000000")); } possibleRecipient.PasscodeSentTimeHistory.Add(utcNow); try { TextMessagingHelper.SendSystemTextMessage(versionedXmlDataProvider.MailboxSession, textMessagingAccount.NotificationPhoneNumber, Strings.PasscodeInformation(possibleRecipient.Passcode).ToString(textMessagingAccount.NotificationPreferredCulture ?? TextMessagingHelper.GetSupportedUserCulture(this.DataObject)), false); } catch (SendAsDeniedException innerException) { base.WriteError(new TextMessageInsufficientPermissionException(innerException), ErrorCategory.InvalidOperation, this.Identity); } versionedXmlDataProvider.Save(textMessagingAccount); } TaskLogger.LogExit(); }
public static bool ShouldReturnMobile(MailboxSession mailboxSession) { if (mailboxSession == null) { return(false); } if (!mailboxSession.SupportedRoutingTypes.Contains("MOBILE")) { return(false); } try { using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(mailboxSession)) { TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(mailboxSession.MailboxOwner.ObjectId); return(textMessagingAccount.EasEnabled); } } catch (AccessDeniedException arg) { ExTraceGlobals.ApplicationlogicTracer.TraceError <AccessDeniedException>((long)typeof(TextMessagingHelper).GetHashCode(), "ShouldReturnMobile throwing an exception: {0}", arg); } return(false); }
private void ProcessSet(XmlNode setNode) { using (this.command.Context.Tracker.Start(TimeId.DeviceInfoProcessSet)) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing DeviceInformation - Set"); foreach (object obj in setNode.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; string innerText = xmlNode.InnerText; string localName; switch (localName = xmlNode.LocalName) { case "Model": this.deviceModel = DeviceClassCache.NormalizeDeviceClass(innerText); break; case "IMEI": this.deviceImei = innerText; break; case "FriendlyName": this.deviceFriendlyName = innerText; break; case "OS": this.deviceOS = innerText; break; case "OSLanguage": this.deviceOSLanguage = innerText; break; case "PhoneNumber": this.devicePhoneNumber = innerText; break; case "UserAgent": this.deviceUserAgent = innerText; break; case "EnableOutboundSMS": { string a; if (this.command.User.IsConsumerOrganizationUser) { this.deviceEnableOutboundSMS = false; } else if ((a = innerText) != null) { if (!(a == "0")) { if (a == "1") { this.deviceEnableOutboundSMS = true; } } else { this.deviceEnableOutboundSMS = false; } } break; } case "MobileOperator": this.deviceMobileOperator = innerText; break; case "Annotations": this.command.RequestAnnotations.ParseWLAnnotations(xmlNode, "DeviceInformation"); break; } } if (this.command.RequestAnnotations.ContainsAnnotation("CreateChatsFolder", "DeviceInformation")) { this.CreateSmsAndChatsSyncFolder(); } bool flag = false; GlobalInfo globalInfo = this.command.GlobalInfo; globalInfo.DeviceModel = this.deviceModel; globalInfo.DeviceImei = this.deviceImei; globalInfo.DeviceFriendlyName = this.deviceFriendlyName; globalInfo.UserAgent = this.deviceUserAgent; string text; if (this.command.Context.Request.DeviceIdentity.DeviceType.ToUpper().Contains("SAMSUNG") && this.command.TryParseDeviceOSFromUserAgent(out text)) { this.deviceOS = text; } globalInfo.DeviceOS = this.deviceOS; globalInfo.DeviceOSLanguage = this.deviceOSLanguage; globalInfo.DevicePhoneNumber = this.devicePhoneNumber; string text2 = string.IsNullOrEmpty(this.devicePhoneNumber) ? globalInfo.DevicePhoneNumberForSms : this.devicePhoneNumber; if (string.IsNullOrEmpty(text2)) { text2 = Guid.NewGuid().GetHashCode().ToString("D3", CultureInfo.InvariantCulture); globalInfo.DevicePhoneNumberForSms = text2; } else { flag |= (string.Compare(text2, globalInfo.DevicePhoneNumberForSms, StringComparison.Ordinal) != 0); } flag |= (this.deviceEnableOutboundSMS != globalInfo.DeviceEnableOutboundSMS); globalInfo.DeviceMobileOperator = this.deviceMobileOperator; globalInfo.DeviceInformationReceived = true; SmsSqmDataPointHelper.AddDeviceInfoReceivedDataPoint(SmsSqmSession.Instance, this.mailboxSession.MailboxOwner.ObjectId, this.mailboxSession.MailboxOwner.LegacyDn, this.command.Request.DeviceIdentity.DeviceType, this.command.Request.VersionString); if (flag) { try { using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(this.mailboxSession)) { TextMessagingAccount textMessagingAccount = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(this.mailboxSession.MailboxOwner.ObjectId); IRecipientSession adrecipientSession = this.mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent); ADRecipient adrecipient = adrecipientSession.Read(this.mailboxSession.MailboxOwner.ObjectId); this.command.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, adrecipientSession.LastUsedDc); if (adrecipient == null) { throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, new LocalizedString("Cannot find AD Recipient correlated to the text messaging account"), false) { ErrorStringForProtocolLogger = "NoUserAccountForSms" }; } E164Number e164Number = null; E164Number.TryParse(text2, out e164Number); if (this.deviceEnableOutboundSMS) { if (e164Number == null) { throw new AirSyncPermanentException(StatusCode.Sync_ServerError, new LocalizedString(string.Format("Cannot parse phone number {0} into a E164 number.", text2)), false) { ErrorStringForProtocolLogger = "BadSmsPhoneNum" }; } bool notificationEnabled = textMessagingAccount.NotificationPhoneNumber != null && textMessagingAccount.NotificationPhoneNumberVerified; textMessagingAccount.SetEasEnabled(e164Number, this.syncStateStorage.DeviceIdentity.Protocol, this.syncStateStorage.DeviceIdentity.DeviceType, this.syncStateStorage.DeviceIdentity.DeviceId, this.deviceFriendlyName); TextMessagingHelper.SaveTextMessagingAccount(textMessagingAccount, versionedXmlDataProvider, adrecipient, adrecipientSession); this.command.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, adrecipientSession.LastUsedDc); SmsSqmDataPointHelper.AddEasConfigurationDataPoint(SmsSqmSession.Instance, this.mailboxSession.MailboxOwner.ObjectId, this.mailboxSession.MailboxOwner.LegacyDn, this.command.Request.DeviceIdentity.DeviceType, notificationEnabled, this.command.Request.VersionString); } else if (textMessagingAccount.EasEnabled && textMessagingAccount.EasPhoneNumber == e164Number) { textMessagingAccount.SetEasDisabled(); TextMessagingHelper.SaveTextMessagingAccount(textMessagingAccount, versionedXmlDataProvider, adrecipient, adrecipientSession); this.command.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, adrecipientSession.LastUsedDc); } } globalInfo.DevicePhoneNumberForSms = text2; globalInfo.DeviceEnableOutboundSMS = this.deviceEnableOutboundSMS; } catch (StoragePermanentException innerException) { throw new AirSyncPermanentException(StatusCode.ServerError, new LocalizedString("Server Error when trying to update SMS settings."), innerException, false) { ErrorStringForProtocolLogger = "SmsSettingsSaveError" }; } } this.OutputToIISLog(); } }