protected override void CheckObjectReadOnly()
        {
            bool isObjectReadOnly = false;
            ExchangeObjectVersion exchangeObjectVersion = ExchangeObjectVersion.Exchange2003;

            foreach (string name in this.dataObjectStore.GetKeys())
            {
                IVersionable versionable = this.dataObjectStore.GetDataObject(name) as IVersionable;
                if (versionable != null && versionable.IsReadOnly)
                {
                    isObjectReadOnly = true;
                }
                if (versionable != null && exchangeObjectVersion.IsOlderThan(versionable.ExchangeVersion))
                {
                    exchangeObjectVersion = versionable.ExchangeVersion;
                }
            }
            base.IsObjectReadOnly = isObjectReadOnly;
            if (base.IsObjectReadOnly)
            {
                base.ObjectReadOnlyReason = Strings.VersionMismatchWarning(exchangeObjectVersion.ExchangeBuild);
                return;
            }
            base.ObjectReadOnlyReason = string.Empty;
        }
        internal static object DiffRetentionPeriodGetter(IPropertyBag propertyBag)
        {
            Unlimited <int> unlimited = (Unlimited <int>)propertyBag[OfflineAddressBookSchema.RawDiffRetentionPeriod];

            if (unlimited.IsUnlimited)
            {
                ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)propertyBag[ADObjectSchema.ExchangeVersion];
                if (exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2007))
                {
                    return(null);
                }
            }
            return(unlimited);
        }
 private void ClearNewAttributesForOldExchange(OfflineAddressBook dataObject, ExchangeObjectVersion version)
 {
     foreach (PropertyDefinition propertyDefinition in dataObject.Schema.AllProperties)
     {
         ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
         if (((version.IsOlderThan(adpropertyDefinition.VersionAdded) && !adpropertyDefinition.IsCalculated) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.ANRProperties) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.DetailsProperties) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.TruncatedProperties)) && !dataObject.ExchangeVersion.IsOlderThan(adpropertyDefinition.VersionAdded))
         {
             if (adpropertyDefinition.IsMultivalued)
             {
                 ((MultiValuedPropertyBase)dataObject[adpropertyDefinition]).Clear();
             }
             else
             {
                 dataObject[adpropertyDefinition] = null;
             }
         }
     }
 }
Example #4
0
        // Token: 0x06000C15 RID: 3093 RVA: 0x0004EEF0 File Offset: 0x0004D0F0
        private RoutingAddress[] FilterByServerVersionAndLookupDisplayName(RoutingAddress[] routingAddresses, IRecipientSession recipientSession, string decisionMakerAddress, out string decisionMakerDisplayName)
        {
            List <RoutingAddress> list = new List <RoutingAddress>(routingAddresses.Length);

            ProxyAddress[] array = new ProxyAddress[routingAddresses.Length];
            decisionMakerDisplayName = string.Empty;
            for (int i = 0; i < routingAddresses.Length; i++)
            {
                array[i] = new SmtpProxyAddress(routingAddresses[i].ToString(), true);
            }
            Result <ADRawEntry>[] array2 = recipientSession.FindByProxyAddresses(array, ApprovalAssistant.ExchangeVersionDisplayNameProperties);
            for (int j = 0; j < array2.Length; j++)
            {
                ADRawEntry data = array2[j].Data;
                if (data == null)
                {
                    ApprovalAssistant.GeneralTracer.TraceDebug <RoutingAddress>((long)this.GetHashCode(), "AD entry not found for '{0}', will not send update to this address.", routingAddresses[j]);
                }
                else
                {
                    ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)data[ADObjectSchema.ExchangeVersion];
                    if (exchangeObjectVersion != null && !exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010))
                    {
                        list.Add(routingAddresses[j]);
                        ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses];
                        foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                        {
                            if (string.Equals(proxyAddress.AddressString, decisionMakerAddress, StringComparison.OrdinalIgnoreCase))
                            {
                                decisionMakerDisplayName = (string)data[ADRecipientSchema.DisplayName];
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Example #5
0
        internal static MultiValuedProperty <string> ConvertSourceMailboxesCollection(IEnumerable <RecipientIdParameter> recipientIds, bool inplaceHoldEnabled, Func <RecipientIdParameter, ADRecipient> recipientGetter, IRecipientSession recipientSession, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate)
        {
            MultiValuedProperty <string> results = null;

            if (recipientIds != null)
            {
                RecipientType[] source = new RecipientType[]
                {
                    RecipientType.UserMailbox,
                    RecipientType.Group,
                    RecipientType.MailUniversalDistributionGroup,
                    RecipientType.MailUniversalSecurityGroup,
                    RecipientType.MailNonUniversalGroup,
                    RecipientType.DynamicDistributionGroup
                };
                bool flag = false;
                foreach (RecipientIdParameter arg in recipientIds)
                {
                    if (results == null)
                    {
                        results = new MultiValuedProperty <string>();
                    }
                    ADRecipient       adrecipient     = recipientGetter(arg);
                    string            text            = null;
                    ADSessionSettings sessionSettings = adrecipient.OrganizationId.ToADSessionSettings();
                    if (Utils.IsPublicFolderMailbox(adrecipient))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientTypeDetails(adrecipient.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    else if (Utils.IsValidMailboxType(adrecipient))
                    {
                        if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox(adrecipient.RecipientTypeDetails) && ExchangePrincipal.FromADUser(sessionSettings, (ADUser)adrecipient, RemotingOptions.AllowCrossSite).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                        {
                            writeErrorDelegate(new MailboxSearchTaskException(Strings.SourceMailboxMustBeE15OrLater(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                        }
                        text = adrecipient.LegacyExchangeDN;
                    }
                    else if (source.Contains(adrecipient.RecipientType))
                    {
                        if (inplaceHoldEnabled)
                        {
                            if (!flag)
                            {
                                if (shouldContinueDelegate(Strings.ShouldContinueToExpandGroupsForHold))
                                {
                                    flag = true;
                                }
                                else
                                {
                                    writeErrorDelegate(new MailboxSearchTaskException(Strings.GroupsIsNotAllowedForHold(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                                }
                            }
                            bool invalidTypeSkipped                   = false;
                            bool oldVersionMailboxSkipped             = false;
                            ADRecipientExpansion adrecipientExpansion = new ADRecipientExpansion(new PropertyDefinition[]
                            {
                                ADRecipientSchema.LegacyExchangeDN,
                                ADRecipientSchema.RecipientTypeDetailsValue,
                                ADObjectSchema.ExchangeVersion
                            }, adrecipient.OrganizationId);
                            adrecipientExpansion.Expand(adrecipient, delegate(ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                if (expansionType == ExpansionType.GroupMembership)
                                {
                                    return(ExpansionControl.Continue);
                                }
                                if (Utils.IsValidMailboxType(expandedRecipient))
                                {
                                    ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)expandedRecipient[ADObjectSchema.ExchangeVersion];
                                    string text2 = (string)expandedRecipient[ADRecipientSchema.LegacyExchangeDN];
                                    if (!oldVersionMailboxSkipped && exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox((RecipientTypeDetails)expandedRecipient[ADRecipientSchema.RecipientTypeDetails]) && ExchangePrincipal.FromLegacyDN(sessionSettings, text2).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                                    {
                                        oldVersionMailboxSkipped = true;
                                        writeWarningDelegate(Strings.OldVersionMailboxSkipped);
                                    }
                                    if (!results.Contains(text2))
                                    {
                                        results.Add(text2);
                                    }
                                }
                                else if (!invalidTypeSkipped)
                                {
                                    invalidTypeSkipped = true;
                                    writeWarningDelegate(Strings.SkippingInvalidTypeInGroupExpansion);
                                }
                                return(ExpansionControl.Skip);
                            }, delegate(ExpansionFailure failure, ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                TaskLogger.Trace("Skipping invalid AD entry {0} because of failure: {1}", new object[]
                                {
                                    expandedRecipient,
                                    failure
                                });
                                return(ExpansionControl.Skip);
                            });
                        }
                        else
                        {
                            text = adrecipient.LegacyExchangeDN;
                        }
                    }
                    else
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientType.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    if (text != null && !results.Contains(text))
                    {
                        results.Add(text);
                    }
                    if (results.Count > Utils.MaxNumberOfMailboxesInSingleHold)
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTooManyMailboxesInSingleHold(Utils.MaxNumberOfMailboxesInSingleHold)), ErrorCategory.InvalidArgument, null);
                    }
                }
                if (results != null)
                {
                    uint discoveryMaxMailboxes = SearchUtils.GetDiscoveryMaxMailboxes(recipientSession);
                    if ((long)results.Count > (long)((ulong)discoveryMaxMailboxes) && !shouldContinueDelegate(Strings.ShouldContinueMoreMailboxesThanMaxSearch(results.Count, discoveryMaxMailboxes)))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTaskCancelledBecauseMoreMailboxesThanSearchSupported), ErrorCategory.InvalidArgument, null);
                    }
                }
            }
            return(results);
        }