protected override void SaveXsoObject(IConfigDataProvider provider, IConfigurable dataObject) { Exception ex = null; try { TextMessagingHelper.SaveTextMessagingAccount((TextMessagingAccount)dataObject, (VersionedXmlDataProvider)provider, this.DataObject, (IRecipientSession)base.DataSession); CalendarNotification calendarNotification = (CalendarNotification)provider.Read <CalendarNotification>(this.DataObject.Identity); if (calendarNotification.TextMessagingPhoneNumber != ((TextMessagingAccount)dataObject).NotificationPhoneNumber) { calendarNotification.TextMessagingPhoneNumber = ((TextMessagingAccount)dataObject).NotificationPhoneNumber; provider.Save(calendarNotification); } } catch (ObjectExistedException ex2) { ex = ex2; } catch (SaveConflictException ex3) { ex = ex3; } catch (ADObjectEntryAlreadyExistsException ex4) { ex = ex4; } if (ex != null) { base.WriteError(new ConflictSavingException(this.DataObject.Identity.ToString(), ex), ErrorCategory.InvalidOperation, this.Identity); } }
// Token: 0x06000AB1 RID: 2737 RVA: 0x00045CD8 File Offset: 0x00043ED8 private static bool TryGetNotificationPhoneNumber(MailboxInfo mailbox, MailboxSession session, ADUser user, out string phoneNumber, out CultureInfo notificationPreferredCulture) { phoneNumber = null; notificationPreferredCulture = null; TextMessagingAccount textMessagingAccount = null; if (MwiAssistant.TryReadTextMessagingAccount(session, out textMessagingAccount)) { bool flag = TextMessagingHelper.IsMachineToPersonTextingOnlyAccount(textMessagingAccount); ExTraceGlobals.MWITracer.TraceDebug(0L, "MwiAssistant: TryGetNotificationPhoneNumber User = {0}, EASEnabled = {1}, Phone Number Verified = {2}, Phone Number = {3}, Can send sms = {4}", new object[] { user.DistinguishedName, textMessagingAccount.EasEnabled, textMessagingAccount.NotificationPhoneNumberVerified, (textMessagingAccount.NotificationPhoneNumber != null && textMessagingAccount.NotificationPhoneNumber.Number != null) ? textMessagingAccount.NotificationPhoneNumber.Number : "<null>", flag }); if (flag) { phoneNumber = textMessagingAccount.NotificationPhoneNumber.Number; notificationPreferredCulture = textMessagingAccount.NotificationPreferredCulture; } } else { ExTraceGlobals.MWITracer.TraceWarning <string>(0L, "MwiAssistant: TryGetNotificationPhoneNumber Cannot send SMS because TextMessagingAccount does not exist for User {0}", user.DistinguishedName); } return(phoneNumber != null); }
protected override void SaveXsoObject(IConfigDataProvider provider, IConfigurable dataObject) { Exception ex = null; try { TextMessagingHelper.SaveTextMessagingAccount((TextMessagingAccount)dataObject, (VersionedXmlDataProvider)provider, this.DataObject, (IRecipientSession)base.DataSession); MailboxTaskHelper.ProcessRecord(delegate { Rules inboxRules = ((VersionedXmlDataProvider)provider).MailboxSession.InboxRules; bool flag = false; foreach (Rule rule in inboxRules) { if (rule.IsEnabled) { bool flag2 = true; foreach (ActionBase actionBase in rule.Actions) { if (!(actionBase is SendSmsAlertToRecipientsAction) && !(actionBase is StopProcessingAction)) { flag2 = false; break; } } if (flag2) { rule.IsEnabled = false; flag = true; } } } if (flag) { inboxRules.Save(); } }, new MailboxTaskHelper.ThrowTerminatingErrorDelegate(base.WriteError), this.Identity); } catch (ObjectExistedException ex2) { ex = ex2; } catch (SaveConflictException ex3) { ex = ex3; } catch (ADObjectEntryAlreadyExistsException ex4) { ex = ex4; } if (ex != null) { base.WriteError(new ConflictSavingException(this.DataObject.Identity.ToString(), ex), ErrorCategory.InvalidOperation, this.Identity); } }
// 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); }
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(); }
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(); }
// 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); }
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(); } }