public IConfigurable Read <T>(ObjectId identity) where T : IConfigurable, new() { AggregationSubscriptionIdentity aggregationSubscriptionIdentity = (AggregationSubscriptionIdentity)identity; try { using (MailboxSession mailboxSession = this.OpenMailboxSession(aggregationSubscriptionIdentity)) { bool upgradeIfRequired = this.ShouldUpgradeIfRequired(); PimAggregationSubscription pimAggregationSubscription = (PimAggregationSubscription)SubscriptionManager.GetSubscription(mailboxSession, aggregationSubscriptionIdentity.SubscriptionId, upgradeIfRequired); PimSubscriptionProxy pimSubscriptionProxy = pimAggregationSubscription.CreateSubscriptionProxy(); if (this.loadReport) { ReportData reportData = SkippedItemUtilities.GetReportData(aggregationSubscriptionIdentity.SubscriptionId); reportData.Load(mailboxSession.Mailbox.MapiStore); pimSubscriptionProxy.Report = reportData.ToReport(); } return(pimSubscriptionProxy); } } catch (LocalizedException ex) { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1365UL, AggregationTaskUtils.Tracer, "Read: {0} hit exception: {1}.", new object[] { aggregationSubscriptionIdentity, ex }); } return(null); }
private void UpdateAggregationSubscription(PimSubscriptionProxy pimSubscriptionProxy) { PimAggregationSubscription subscription = pimSubscriptionProxy.Subscription; try { using (MailboxSession mailboxSession = this.OpenMailboxSession(subscription.SubscriptionIdentity)) { IList <AggregationSubscription> allSubscriptions = this.GetAllSubscriptions(); this.aggregationSubscriptionConstraintChecker.CheckUpdateSubscriptionConstraints(subscription, allSubscriptions); DelayedEmailSender delayedEmailSender = null; if (pimSubscriptionProxy.SendAsCheckNeeded) { delayedEmailSender = this.SetAppropriateSendAsState(subscription); } SubscriptionManager.SetSubscriptionAndSyncNow(mailboxSession, subscription); if (pimSubscriptionProxy.SendAsCheckNeeded) { this.PostSaveSendAsStateProcessing(subscription, delayedEmailSender, mailboxSession); } } } catch (LocalizedException ex) { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1246UL, AggregationTaskUtils.Tracer, "UpdateAggregationSubscription: {0} hit exception: {1}.", new object[] { subscription.Name, ex }); throw new FailedSetAggregationSubscriptionException(subscription.Name, ex); } }
private DelayedEmailSender SetAppropriateSendAsState(PimAggregationSubscription subscription) { IEmailSender toWrap = subscription.CreateEmailSenderFor(this.adUser, this.primaryExchangePrincipal); DelayedEmailSender delayedEmailSender = new DelayedEmailSender(toWrap); SendAsAutoProvision sendAsAutoProvision = new SendAsAutoProvision(); sendAsAutoProvision.SetAppropriateSendAsState(subscription, delayedEmailSender); return(delayedEmailSender); }
private void CheckSameSubscriptionNameConstraint(PimAggregationSubscription newSubscription, PimAggregationSubscription existingSubscription) { if (string.Equals(existingSubscription.Name, newSubscription.Name, StringComparison.InvariantCultureIgnoreCase)) { this.syncLogSession.LogError((TSLID)1248UL, AggregationTaskUtils.Tracer, (long)existingSubscription.Name.GetHashCode(), "Subscription creation failed: {0}. There is already a subscription with the same name", new object[] { existingSubscription.Name }); throw new SubscriptionNameAlreadyExistsException(existingSubscription.Name); } }
private void CheckIfCanCreateNewSubscriptionConstraint(PimAggregationSubscription newSubscription, int maxSubscriptionAllowed, int subscriptionCount) { if (subscriptionCount >= maxSubscriptionAllowed) { this.syncLogSession.LogError((TSLID)1251UL, AggregationTaskUtils.Tracer, (long)newSubscription.Name.GetHashCode(), "Every user can only have {0} subscriptions", new object[] { maxSubscriptionAllowed }); throw new SubscriptionNumberExceedLimitException(maxSubscriptionAllowed); } }
public virtual void CheckUpdateSubscriptionConstraints(PimAggregationSubscription updatedSubscription, IList <AggregationSubscription> subscriptions) { SyncUtilities.ThrowIfArgumentNull("UpdatedSubscription", updatedSubscription); if (subscriptions == null) { return; } foreach (AggregationSubscription aggregationSubscription in subscriptions) { if (!aggregationSubscription.SubscriptionGuid.Equals(updatedSubscription.SubscriptionGuid)) { this.CheckUpdateSubscriptionConstraints(updatedSubscription, aggregationSubscription as PimAggregationSubscription); } } }
private void NewAggregationSubscription(PimSubscriptionProxy pimSubscriptionProxy) { PimAggregationSubscription subscription = pimSubscriptionProxy.Subscription; ExchangePrincipal exchangePrincipal = this.primaryExchangePrincipal; IList <AggregationSubscription> allSubscriptions = this.GetAllSubscriptions(); int userMaximumSubscriptionAllowed = this.GetUserMaximumSubscriptionAllowed(); this.aggregationSubscriptionConstraintChecker.CheckNewSubscriptionConstraints(subscription, allSubscriptions, userMaximumSubscriptionAllowed); bool flag = false; try { DelayedEmailSender delayedEmailSender = null; if (pimSubscriptionProxy.SendAsCheckNeeded) { delayedEmailSender = this.SetAppropriateSendAsState(subscription); } flag = true; using (MailboxSession mailboxSession = this.OpenMailboxSession(exchangePrincipal)) { SubscriptionManager.CreateSubscription(mailboxSession, subscription); if (pimSubscriptionProxy.SendAsCheckNeeded) { this.PostSaveSendAsStateProcessing(subscription, delayedEmailSender, mailboxSession); } } } catch (LocalizedException ex) { if (!flag) { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1504UL, AggregationTaskUtils.Tracer, "NewAggregationSubscription: {0}. Failed to set send as state with exception: {1}.", new object[] { subscription.Name, ex }); } else { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1505UL, AggregationTaskUtils.Tracer, "NewAggregationSubscription: {0}. Failed to open mailbox session with exception: {1}.", new object[] { subscription.Name, ex }); } throw new FailedCreateAggregationSubscriptionException(subscription.Name, ex); } }
private void CheckUpdateSubscriptionConstraints(PimAggregationSubscription newSubscription, PimAggregationSubscription existingSubscription) { this.CheckSameSubscriptionNameConstraint(newSubscription, existingSubscription); if (newSubscription.AggregationType != AggregationType.PeopleConnection) { this.CheckSubscriptionEmailAddressesConstraint(newSubscription, existingSubscription); if (newSubscription is PopAggregationSubscription) { this.CheckPOPSubscriptionConstraint(newSubscription, existingSubscription); return; } if (newSubscription is IMAPAggregationSubscription) { this.CheckIMAPSubscriptionConstraint(newSubscription, existingSubscription); } } }
private void PostSaveSendAsStateProcessing(PimAggregationSubscription subscription, DelayedEmailSender delayedEmailSender, MailboxSession mailboxSession) { SyncUtilities.ThrowIfArgumentNull("delayedEmailSender", delayedEmailSender); if (subscription.SendAsState == SendAsState.Enabled) { AggregationTaskUtils.EnableAlwaysShowFrom(this.primaryExchangePrincipal); } if (!delayedEmailSender.SendAttempted) { return; } IEmailSender emailSender = delayedEmailSender.TriggerDelayedSend(); SendAsManager sendAsManager = new SendAsManager(); sendAsManager.UpdateSubscriptionWithDiagnostics(subscription, emailSender); SubscriptionManager.SetSubscription(mailboxSession, subscription); }
private void CheckSubscriptionEmailAddressesConstraint(PimAggregationSubscription newSubscription, PimAggregationSubscription existingSubscription) { if (newSubscription.AggregationType != existingSubscription.AggregationType) { return; } if (!(newSubscription.UserEmailAddress == existingSubscription.UserEmailAddress)) { return; } string text = newSubscription.UserEmailAddress.ToString(); this.syncLogSession.LogError((TSLID)1247UL, AggregationTaskUtils.Tracer, (long)newSubscription.Name.GetHashCode(), "Cannot create subscription. A subscription with email address {0} already exists", new object[] { text }); throw new RedundantPimSubscriptionException(text); }
public void CheckNewSubscriptionConstraints(PimAggregationSubscription newSubscription, IList <AggregationSubscription> subscriptions, int maxSubscriptionAllowed) { SyncUtilities.ThrowIfArgumentNull("newSubscription", newSubscription); if (subscriptions == null) { return; } this.CheckUpdateSubscriptionConstraints(newSubscription, subscriptions); int num = 0; foreach (AggregationSubscription aggregationSubscription in subscriptions) { if (aggregationSubscription.AggregationType == newSubscription.AggregationType) { num++; } } this.CheckIfCanCreateNewSubscriptionConstraint(newSubscription, maxSubscriptionAllowed, num); }
private void RemoveAggregationSubscription(PimAggregationSubscription subscription) { try { ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromLegacyDN(this.recipientSession.SessionSettings, subscription.UserLegacyDN, RemotingOptions.AllowCrossSite); using (MailboxSession mailboxSession = this.OpenMailboxSession(exchangePrincipal)) { SubscriptionManager.Instance.DeleteSubscription(mailboxSession, subscription, true); } } catch (LocalizedException ex) { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1506UL, AggregationTaskUtils.Tracer, "RemoveAggregationSubscription: {0} hit exception: {1}.", new object[] { subscription.Name, ex }); throw new FailedDeleteAggregationSubscriptionException(subscription.Name, ex); } }
private void CheckIMAPSubscriptionConstraint(PimAggregationSubscription newSubscription, PimAggregationSubscription existingSubscription) { IMAPAggregationSubscription imapaggregationSubscription = existingSubscription as IMAPAggregationSubscription; if (imapaggregationSubscription == null) { return; } IMAPAggregationSubscription imapaggregationSubscription2 = newSubscription as IMAPAggregationSubscription; if (imapaggregationSubscription2 != null && string.Compare(imapaggregationSubscription2.IMAPServer, imapaggregationSubscription.IMAPServer, true) == 0 && string.Compare(imapaggregationSubscription2.IMAPLogOnName, imapaggregationSubscription.IMAPLogOnName, true) == 0) { string text = imapaggregationSubscription2.IMAPServer.ToString(); this.syncLogSession.LogError((TSLID)1250UL, AggregationTaskUtils.Tracer, (long)newSubscription.Name.GetHashCode(), "Cannot create subscription. An IMAP subscription for username {0} on server {1} already exists", new object[] { imapaggregationSubscription2.IMAPLogOnName, text }); throw new RedundantAccountSubscriptionException(imapaggregationSubscription2.IMAPLogOnName, text); } }
private void CheckPOPSubscriptionConstraint(PimAggregationSubscription newSubscription, PimAggregationSubscription existingSubscription) { PopAggregationSubscription popAggregationSubscription = existingSubscription as PopAggregationSubscription; if (popAggregationSubscription == null) { return; } PopAggregationSubscription popAggregationSubscription2 = newSubscription as PopAggregationSubscription; if (popAggregationSubscription2 != null && string.Compare(popAggregationSubscription2.PopServer, popAggregationSubscription.PopServer, true) == 0 && string.Compare(popAggregationSubscription2.PopLogonName, popAggregationSubscription.PopLogonName, true) == 0) { string text = popAggregationSubscription2.PopServer.ToString(); this.syncLogSession.LogError((TSLID)1249UL, AggregationTaskUtils.Tracer, (long)newSubscription.Name.GetHashCode(), "Cannot create subscription. A POP subscription for username {0} on server {1} already exists", new object[] { popAggregationSubscription2.PopLogonName, text }); throw new RedundantAccountSubscriptionException(popAggregationSubscription2.PopLogonName, text); } }
private PimSubscriptionProxy[] GetSubscriptions(AggregationSubscriptionQueryFilter queryFilter) { List <PimSubscriptionProxy> list = new List <PimSubscriptionProxy>(3); IList <AggregationSubscription> allSubscriptions = this.GetAllSubscriptions(); if (allSubscriptions != null) { foreach (AggregationSubscription aggregationSubscription in allSubscriptions) { PimAggregationSubscription pimAggregationSubscription = (PimAggregationSubscription)aggregationSubscription; if (queryFilter == null || queryFilter.Match(pimAggregationSubscription)) { PimSubscriptionProxy pimSubscriptionProxy = pimAggregationSubscription.CreateSubscriptionProxy(); if (this.loadReport && this.reports.ContainsKey(aggregationSubscription.SubscriptionGuid)) { pimSubscriptionProxy.Report = this.reports[aggregationSubscription.SubscriptionGuid]; } list.Add(pimSubscriptionProxy); } } } return(list.ToArray()); }
// Token: 0x06001869 RID: 6249 RVA: 0x0008F2EC File Offset: 0x0008D4EC private void ProcessGet() { using (this.user.Context.Tracker.Start(TimeId.UserInformationSettingsProcessGet)) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing UserInformationSetting - Get"); XmlNode xmlNode = base.Response.OwnerDocument.CreateElement("Get", "Settings:"); bool flag = this.version > 140; XmlNode xmlNode2 = null; XmlNode xmlNode3 = null; if (flag) { xmlNode2 = base.Response.OwnerDocument.CreateElement("Accounts", "Settings:"); xmlNode3 = base.Response.OwnerDocument.CreateElement("Account", "Settings:"); } XmlNode xmlNode4 = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:"); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.user.OrganizationId), 203, "ProcessGet", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\UserInformationSetting.cs"); ADRecipient adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(this.user.ADUser.ExchangeGuid); base.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, tenantOrRootOrgRecipientSession.LastUsedDc); if (adrecipient != null && adrecipient.EmailAddresses != null) { using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator = adrecipient.EmailAddresses.GetEnumerator()) { while (enumerator.MoveNext()) { ProxyAddress proxyAddress = enumerator.Current; AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found proxy address {0}!", proxyAddress.AddressString); if (SmtpAddress.IsValidSmtpAddress(proxyAddress.AddressString)) { if (this.version > 140 && proxyAddress.IsPrimaryAddress && proxyAddress.Prefix.DisplayName == "SMTP") { AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Primary Smtp proxy address {0}!", proxyAddress.AddressString); XmlNode xmlNode5 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:"); xmlNode5.InnerText = proxyAddress.AddressString; xmlNode4.AppendChild(xmlNode5); } else { AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "Found valid Smtp proxy address {0}!", proxyAddress.AddressString); XmlNode xmlNode6 = base.Response.OwnerDocument.CreateElement("SmtpAddress", "Settings:"); xmlNode6.InnerText = proxyAddress.AddressString; xmlNode4.AppendChild(xmlNode6); } } } goto IL_263; } } AirSyncDiagnostics.TraceDebug <bool, bool>(ExTraceGlobals.RequestsTracer, this, "fullRecipient fullRecipient.EmailAddresses is null! fullRecipient == null: {0}, fullRecipient.EmailAddresses == null : {1}", adrecipient == null, adrecipient != null && adrecipient.EmailAddresses == null); IL_263: if (flag) { xmlNode3.AppendChild(xmlNode4); xmlNode2.AppendChild(xmlNode3); } if (flag) { List <AggregationSubscription> allSubscriptions = SubscriptionManager.GetAllSubscriptions(this.mailboxSession, AggregationSubscriptionType.AllEMail); foreach (AggregationSubscription aggregationSubscription in allSubscriptions) { PimAggregationSubscription pimAggregationSubscription = aggregationSubscription as PimAggregationSubscription; if (pimAggregationSubscription == null) { AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found AggregationSubscription that was not a PimAggregationSubscription {0}!", pimAggregationSubscription.SubscriptionGuid); } else { AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found valid subscription {0}!", pimAggregationSubscription.SubscriptionGuid); XmlNode xmlNode7 = base.Response.OwnerDocument.CreateElement("Account", "Settings:"); XmlNode xmlNode8 = base.Response.OwnerDocument.CreateElement("AccountId", "Settings:"); xmlNode8.InnerText = pimAggregationSubscription.SubscriptionGuid.ToString(); xmlNode7.AppendChild(xmlNode8); XmlNode xmlNode9 = base.Response.OwnerDocument.CreateElement("AccountName", "Settings:"); xmlNode9.InnerText = pimAggregationSubscription.Name; xmlNode7.AppendChild(xmlNode9); XmlNode xmlNode10 = base.Response.OwnerDocument.CreateElement("UserDisplayName", "Settings:"); xmlNode10.InnerText = pimAggregationSubscription.UserDisplayName; xmlNode7.AppendChild(xmlNode10); if (!pimAggregationSubscription.SendAsCapable || !SubscriptionManager.IsValidForSendAs(pimAggregationSubscription.SendAsState, pimAggregationSubscription.Status)) { XmlNode newChild = base.Response.OwnerDocument.CreateElement("SendDisabled", "Settings:"); xmlNode7.AppendChild(newChild); } XmlNode xmlNode11 = base.Response.OwnerDocument.CreateElement("PrimarySmtpAddress", "Settings:"); xmlNode11.InnerText = pimAggregationSubscription.UserEmailAddress.ToString(); xmlNode4 = base.Response.OwnerDocument.CreateElement("EmailAddresses", "Settings:"); xmlNode4.AppendChild(xmlNode11); xmlNode7.AppendChild(xmlNode4); xmlNode2.AppendChild(xmlNode7); } } } XmlNode xmlNode12 = base.Response.OwnerDocument.CreateElement("Status", "Settings:"); XmlNode xmlNode13 = xmlNode12; int num = (int)this.status; xmlNode13.InnerText = num.ToString(CultureInfo.InvariantCulture); base.Response.AppendChild(xmlNode12); if (flag) { xmlNode.AppendChild(xmlNode2); } else { xmlNode.AppendChild(xmlNode4); } base.Response.AppendChild(xmlNode); AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing UserInformationSetting - Get."); } }
public bool Match(AggregationSubscription subscription) { if (subscription == null) { return(false); } if (this.subscriptionIdParameter.SubscriptionIdentity != null && !this.subscriptionIdParameter.SubscriptionIdentity.Equals(subscription.SubscriptionIdentity)) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1252UL, "Match: Ignoring subscription as identity {0} does not match desired value: {1}.", new object[] { subscription.SubscriptionIdentity, this.subscriptionIdParameter.SubscriptionIdentity }); return(false); } if ((subscription.SubscriptionType & this.subscriptionIdParameter.SubscriptionType) == AggregationSubscriptionType.Unknown) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1253UL, "Match: Ignoring subscription as type {0} does not match desired value: {1}.", new object[] { subscription.SubscriptionType, this.subscriptionIdParameter.SubscriptionType }); return(false); } if (this.subscriptionIdParameter.AggregationType != null && this.subscriptionIdParameter.AggregationType != AggregationType.All && subscription.AggregationType != this.subscriptionIdParameter.AggregationType) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1254UL, "Match: Ignoring subscription as aggregation type {0} does not match desired value: {1}.", new object[] { subscription.AggregationType, this.subscriptionIdParameter.AggregationType }); return(false); } if (!string.IsNullOrEmpty(this.subscriptionIdParameter.Name) && !this.subscriptionIdParameter.Name.Equals(subscription.Name, StringComparison.OrdinalIgnoreCase)) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1255UL, "Match: Ignoring subscription as name {0} does not match desired value: {1}.", new object[] { subscription.Name, this.subscriptionIdParameter.Name }); return(false); } PimAggregationSubscription pimAggregationSubscription = subscription as PimAggregationSubscription; if (pimAggregationSubscription != null && !this.subscriptionIdParameter.EmailAddress.Equals(SmtpAddress.Empty) && !this.subscriptionIdParameter.EmailAddress.Equals(pimAggregationSubscription.UserEmailAddress)) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1256UL, "Match: Ignoring subscription as UserEmailAddress {0} does not match desired value: {1}.", new object[] { pimAggregationSubscription.UserEmailAddress, this.subscriptionIdParameter.EmailAddress }); return(false); } if (!this.subscriptionIdParameter.SubscriptionId.Equals(Guid.Empty) && !this.subscriptionIdParameter.SubscriptionId.Equals(subscription.SubscriptionGuid)) { CommonLoggingHelper.SyncLogSession.LogVerbose((TSLID)1257UL, "Match: Ignoring subscription as subscriptionGuid {0} does not match desired value: {1}.", new object[] { subscription.SubscriptionGuid, this.subscriptionIdParameter.SubscriptionId }); return(false); } return(true); }