Exemplo n.º 1
0
        public MultiValuedProperty <BindingMetadata> ValidateLocations(IEnumerable <string> locations)
        {
            ArgumentValidator.ThrowIfNull("locations", locations);
            MultiValuedProperty <BindingMetadata> multiValuedProperty = new MultiValuedProperty <BindingMetadata>();

            if (locations.Count <string>() > this.maxSitesLimit)
            {
                base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
                {
                    Strings.ErrorMaxSiteLimit(this.maxSitesLimit, locations.Count <string>())
                });
                base.WriteError(new SpValidatorException(Strings.ErrorMaxSiteLimit(this.maxSitesLimit, locations.Count <string>())), ErrorCategory.InvalidArgument);
            }
            foreach (string location in locations)
            {
                SharepointValidationResult validationResult = this.ValidateLocation(location);
                if (validationResult.IsValid)
                {
                    if (validationResult.IsTopLevelSiteCollection)
                    {
                        base.WriteWarning(validationResult.ValidationText);
                    }
                    if (!multiValuedProperty.Any((BindingMetadata p) => string.Equals(validationResult.SharepointSource.Identity, p.ImmutableIdentity, StringComparison.OrdinalIgnoreCase)))
                    {
                        multiValuedProperty.Add(new BindingMetadata(validationResult.SharepointSource.Title, validationResult.SharepointSource.SiteUrl, validationResult.SharepointSource.Identity, SourceValidator.GetBindingType(validationResult.SharepointSource.Identity)));
                    }
                }
                else
                {
                    base.WriteError(new SpValidatorException(validationResult.ValidationText), ErrorCategory.InvalidArgument);
                }
            }
            return(multiValuedProperty);
        }
Exemplo n.º 2
0
 internal static void ValidateSenderIPAddressRestrictions(MultiValuedProperty <IPRange> addressRanges, MultiValuedProperty <IPRange> ffoDCIPs, MultiValuedProperty <ServiceProviderSettings> serviceProviders, Task task)
 {
     if (MultiValuedPropertyBase.IsNullOrEmpty(addressRanges))
     {
         return;
     }
     using (MultiValuedProperty <IPRange> .Enumerator enumerator = addressRanges.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             IPRange ipRange = enumerator.Current;
             if (!MultiValuedPropertyBase.IsNullOrEmpty(ffoDCIPs))
             {
                 if (ffoDCIPs.Any((IPRange ffoDCIP) => ffoDCIP.Overlaps(ipRange)))
                 {
                     task.WriteError(new SenderIPAddressOverlapsFfoDCIPAddressesException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
                 }
             }
             if (!MultiValuedPropertyBase.IsNullOrEmpty(serviceProviders))
             {
                 if (serviceProviders.Any((ServiceProviderSettings serviceProvider) => serviceProvider.IPRanges != null && serviceProvider.IPRanges.Any((IPRange providerIPRange) => providerIPRange != null && providerIPRange.Overlaps(ipRange))))
                 {
                     task.WriteError(new SenderIPAddressOverlapsServiceProviderIPAddressesException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public static void GetTemplateListPostAction(DataRow inputRow, DataTable dataTable, DataObjectStore store)
 {
     foreach (object obj in dataTable.Rows)
     {
         DataRow dataRow = (DataRow)obj;
         if (!DBNull.Value.Equals(dataRow["RuleParameters"]))
         {
             MultiValuedProperty <string> source = (MultiValuedProperty <string>)dataRow["RuleParameters"];
             dataRow["SupportsDistributionGroup"]         = source.Any((string rp) => rp.Contains("%%exceptionDL%%"));
             dataRow["SupportsIncidentManagementMailbox"] = source.Any((string rp) => rp.Contains("%%IncidentManagementMailBox%%"));
         }
         else
         {
             dataRow["SupportsDistributionGroup"]         = false;
             dataRow["SupportsIncidentManagementMailbox"] = false;
         }
     }
 }
Exemplo n.º 4
0
 private static bool PartiallyOverlap(IEnumerable <IPRange> ranges1, MultiValuedProperty <IPRange> ranges2)
 {
     using (IEnumerator <IPRange> enumerator = ranges1.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             IPRange range1 = enumerator.Current;
             if (ranges2.Any((IPRange range) => range1.PartiallyOverlaps(range)))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 5
0
 internal static void ValidateTlsSenderCertificateRestrictions(TlsCertificate certificate, MultiValuedProperty <SmtpX509IdentifierEx> ffoFDSmtpCerts, MultiValuedProperty <ServiceProviderSettings> serviceProviders, Task task)
 {
     if (certificate == null)
     {
         return;
     }
     if (!MultiValuedPropertyBase.IsNullOrEmpty(ffoFDSmtpCerts) && ffoFDSmtpCerts.Any((SmtpX509IdentifierEx ffoFDSmtpCert) => ffoFDSmtpCert.Matches(certificate)))
     {
         task.WriteError(new TlsSenderCertificateNameMatchesFfoFDSmtpCertificateException(certificate.ToString()), ErrorCategory.InvalidArgument, null);
     }
     if (!MultiValuedPropertyBase.IsNullOrEmpty(serviceProviders) && serviceProviders.Any((ServiceProviderSettings serviceProvider) => serviceProvider.Certificates != null && serviceProvider.Certificates.Any((TlsCertificate providerCertificate) => providerCertificate != null && providerCertificate.Equals(certificate))))
     {
         task.WriteError(new TlsSenderCertificateNameMatchesServiceProviderCertificateException(certificate.ToString()), ErrorCategory.InvalidArgument, null);
     }
 }
Exemplo n.º 6
0
        internal virtual void PopulateTaskProperties(Task task, IConfigurationSession configurationSession)
        {
            this.InitializeBindings();
            foreach (BindingStorage bindingStorage in this.StorageBindings)
            {
                switch (bindingStorage.Workload)
                {
                case Workload.Exchange:
                    this.ExchangeBinding = Utils.GetScopesFromStorage(bindingStorage);
                    break;

                case Workload.SharePoint:
                {
                    MultiValuedProperty <BindingMetadata> scopesFromStorage   = Utils.GetScopesFromStorage(bindingStorage);
                    MultiValuedProperty <BindingMetadata> multiValuedProperty = new MultiValuedProperty <BindingMetadata>(PsCompliancePolicyBase.GetBindingsBySubWorkload(scopesFromStorage, Workload.SharePoint));
                    multiValuedProperty.SetIsReadOnly(false, null);
                    if (multiValuedProperty.Any <BindingMetadata>())
                    {
                        this.SharePointBinding = multiValuedProperty;
                    }
                    else
                    {
                        multiValuedProperty = new MultiValuedProperty <BindingMetadata>(PsCompliancePolicyBase.GetBindingsBySubWorkload(scopesFromStorage, Workload.OneDriveForBusiness));
                        multiValuedProperty.SetIsReadOnly(false, null);
                        if (multiValuedProperty.Any <BindingMetadata>())
                        {
                            this.OneDriveBinding = scopesFromStorage;
                        }
                    }
                    break;
                }

                default:
                    this.ReadOnly = true;
                    this.ExchangeBinding.Clear();
                    this.SharePointBinding.Clear();
                    this.OneDriveBinding.Clear();
                    break;
                }
            }
            PolicyStorage policyStorage = base.DataObject as PolicyStorage;
            ADUser        userObjectByExternalDirectoryObjectId  = Utils.GetUserObjectByExternalDirectoryObjectId(policyStorage.CreatedBy, configurationSession);
            ADUser        userObjectByExternalDirectoryObjectId2 = Utils.GetUserObjectByExternalDirectoryObjectId(policyStorage.LastModifiedBy, configurationSession);

            this.CreatedBy      = ((!Utils.ExecutingUserIsForestWideAdmin(task) && userObjectByExternalDirectoryObjectId != null) ? userObjectByExternalDirectoryObjectId.DisplayName : policyStorage.CreatedBy);
            this.LastModifiedBy = ((!Utils.ExecutingUserIsForestWideAdmin(task) && userObjectByExternalDirectoryObjectId2 != null) ? userObjectByExternalDirectoryObjectId2.DisplayName : policyStorage.LastModifiedBy);
        }
 private static void ValidateSmartHostRestrictions(TenantOutboundConnector tenantOutboundConnector, Task task, bool skipIpIsNotReservedValidation)
 {
     if (tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.SmartHosts) && !MultiValuedPropertyBase.IsNullOrEmpty(tenantOutboundConnector.SmartHosts))
     {
         MultiValuedProperty <IPRange> multiValuedProperty = null;
         bool flag = false;
         using (MultiValuedProperty <SmartHost> .Enumerator enumerator = tenantOutboundConnector.SmartHosts.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 SmartHost smartHost = enumerator.Current;
                 if (smartHost.IsIPAddress)
                 {
                     if (smartHost.Address.AddressFamily != AddressFamily.InterNetwork || !IPAddressValidation.IsValidIPv4Address(smartHost.Address.ToString()))
                     {
                         task.WriteError(new SmartHostsIPValidationFailedException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                     }
                     if (!skipIpIsNotReservedValidation)
                     {
                         if (IPAddressValidation.IsReservedIPv4Address(smartHost.Address.ToString()))
                         {
                             task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                         }
                         if (!flag)
                         {
                             if (!HygieneDCSettings.GetFfoDCPublicIPAddresses(out multiValuedProperty))
                             {
                                 task.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                             }
                             flag = true;
                         }
                         if (!MultiValuedPropertyBase.IsNullOrEmpty(multiValuedProperty))
                         {
                             if (multiValuedProperty.Any((IPRange ffoDCIP) => ffoDCIP.Contains(smartHost.Address)))
                             {
                                 task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        private void UpdateWorkloadStorageBinding(Guid universalIdentity, Workload workload, MultiValuedProperty <BindingMetadata> scopes, Exception mulipleStorageObjectsException)
        {
            ExAssert.RetailAssert(workload != Workload.SharePoint, "UpdateWorkloadBinding called for Sharepoint workload.");
            if (this.StorageBindings.Count((BindingStorage x) => x.Workload == workload) > 1)
            {
                throw mulipleStorageObjectsException;
            }
            BindingStorage bindingStorage = this.StorageBindings.FirstOrDefault((BindingStorage x) => x.Workload == workload);

            if (bindingStorage == null && scopes.Any <BindingMetadata>())
            {
                bindingStorage = Utils.CreateNewBindingStorage(base.OrganizationalUnitRoot, workload, universalIdentity);
                this.StorageBindings.Add(bindingStorage);
            }
            if (bindingStorage != null)
            {
                Utils.PopulateScopeStorages(bindingStorage, scopes);
            }
        }
Exemplo n.º 9
0
 private void VerifyAndAddRecipient(ReducedRecipient recipient, MultiValuedProperty <BindingMetadata> validatedRecipients, bool inGroupExpansion)
 {
     if (ExchangeValidator.IsValidRecipientType(recipient))
     {
         if (!validatedRecipients.Any((BindingMetadata p) => string.Equals(recipient.ExternalDirectoryObjectId, p.ImmutableIdentity, StringComparison.OrdinalIgnoreCase)))
         {
             if (validatedRecipients.Count < this.maxRecipientsLimit)
             {
                 validatedRecipients.Add(new BindingMetadata(recipient.Name, recipient.PrimarySmtpAddress.ToString(), recipient.ExternalDirectoryObjectId, PolicyBindingTypes.IndividualResource));
                 return;
             }
             base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
             {
                 Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit)
             });
             base.WriteError(new ExValidatorException(Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit)), ErrorCategory.InvalidArgument);
             return;
         }
     }
     else
     {
         if (inGroupExpansion)
         {
             if (!this.warnedSkipInvalidTypeInGroup)
             {
                 this.warnedSkipInvalidTypeInGroup = true;
                 base.WriteWarning(Strings.SkippingInvalidTypeInGroupExpansion);
             }
             base.LogOneEntry(ExecutionLog.EventType.Warning, "Invalid group member '{0}' skipped as the type '{1}' is not supported", new object[]
             {
                 recipient.PrimarySmtpAddress.ToString(),
                 recipient.RecipientTypeDetails
             });
             return;
         }
         base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[]
         {
             Strings.ErrorInvalidRecipientType(recipient.PrimarySmtpAddress.ToString(), recipient.RecipientTypeDetails.ToString())
         });
         base.WriteError(new ExValidatorException(Strings.ErrorInvalidRecipientType(recipient.PrimarySmtpAddress.ToString(), recipient.RecipientTypeDetails.ToString())), ErrorCategory.InvalidArgument);
     }
 }
Exemplo n.º 10
0
 internal static void MergeBindings(MultiValuedProperty <BindingMetadata> bindings, MultiValuedProperty <BindingMetadata> addedBindings, MultiValuedProperty <BindingMetadata> removedBindings, bool forceClear)
 {
     ArgumentValidator.ThrowIfNull("bindings", bindings);
     ArgumentValidator.ThrowIfNull("addedBindings", addedBindings);
     ArgumentValidator.ThrowIfNull("removedBindings", removedBindings);
     if (forceClear && bindings.Any <BindingMetadata>())
     {
         bindings.Clear();
         return;
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator = removedBindings.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             BindingMetadata item            = enumerator.Current;
             BindingMetadata bindingMetadata = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata != null)
             {
                 bindings.Remove(bindingMetadata);
             }
         }
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator2 = addedBindings.GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             BindingMetadata item             = enumerator2.Current;
             BindingMetadata bindingMetadata2 = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata2 == null)
             {
                 bindings.Add(item);
             }
             else if (!string.Equals(bindingMetadata2.DisplayName, item.DisplayName, StringComparison.InvariantCulture) || !string.Equals(bindingMetadata2.Name, item.Name, StringComparison.InvariantCultureIgnoreCase))
             {
                 int index = bindings.IndexOf(bindingMetadata2);
                 bindings[index] = item;
             }
         }
     }
 }
Exemplo n.º 11
0
        private void UpdateSharepointStorageBinding(Guid universalIdentity, Workload subWorkload, MultiValuedProperty <BindingMetadata> scopes, Exception mulipleStorageObjectsException)
        {
            ExAssert.RetailAssert(subWorkload == Workload.SharePoint || subWorkload == Workload.OneDriveForBusiness, "UpdateSharepointStorageBinding called for non-Sharepoint workload.");
            if (this.StorageBindings.Count((BindingStorage x) => x.Workload == Workload.SharePoint) > 2)
            {
                throw mulipleStorageObjectsException;
            }
            BindingStorage bindingStorageForSubWorkload = this.GetBindingStorageForSubWorkload(this.StorageBindings, subWorkload, universalIdentity, scopes.Any <BindingMetadata>());

            if (bindingStorageForSubWorkload != null)
            {
                Utils.PopulateScopeStorages(bindingStorageForSubWorkload, scopes);
            }
        }