private static SharepointValidator Create(IConfigurationSession configurationSession, ADObjectId executingUserId, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate, string logTag, SourceValidator.Clients client, int existingSitesCount, ExecutionLog logger) { ArgumentValidator.ThrowIfNull("configurationSession", configurationSession); Uri uri = null; Uri uri2 = null; OrganizationId organizationId = configurationSession.GetOrgContainer().OrganizationId; UnifiedPolicyConfiguration.GetInstance().GetTenantSharePointUrls(configurationSession, out uri, out uri2); if (uri == null) { EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", client.ToString(), string.Format("Tenant {0}, Error:{1}", organizationId.ToExternalDirectoryOrganizationId(), Strings.FailedToGetSpSiteUrlForTenant), ResultSeverityLevel.Error, false); throw new SpValidatorException(Strings.FailedToGetSpSiteUrlForTenant); } ADUser actAsUser = null; if (executingUserId != null) { ADSessionSettings sessionSettings = ADSessionSettings.FromExternalDirectoryOrganizationId(new Guid(organizationId.ToExternalDirectoryOrganizationId())); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 520, "Create", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\UnifiedPolicy\\Validators\\SharepointValidator.cs"); actAsUser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(executingUserId); } ICredentials credentials = UnifiedPolicyConfiguration.GetInstance().GetCredentials(configurationSession, actAsUser); if (credentials == null) { EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", client.ToString(), string.Format("Tenant {0}, Error:{1}", organizationId.ToExternalDirectoryOrganizationId(), Strings.FailedToGetCredentialsForTenant), ResultSeverityLevel.Error, false); throw new SpValidatorException(Strings.FailedToGetCredentialsForTenant); } int maxLimitFromConfig = SourceValidator.GetMaxLimitFromConfig("MaxSitesLimit", 100, existingSitesCount); return(new SharepointValidator(uri, credentials, executingUserId != null, writeErrorDelegate, writeWarningDelegate, shouldContinueDelegate, maxLimitFromConfig, logger, logTag, organizationId.ToExternalDirectoryOrganizationId(), client)); }
public static ExchangeValidator Create(IConfigurationSession configSession, Func <RecipientIdParameter, IRecipientSession, ReducedRecipient> recipientGetter, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate, bool allowGroups, string logTag, SourceValidator.Clients client, int existingRecipientsCount, ExecutionLog logger) { ArgumentValidator.ThrowIfNull("configSession", configSession); OrganizationId organizationId = configSession.GetOrgContainer().OrganizationId; ADSessionSettings sessionSettings = ADSessionSettings.FromExternalDirectoryOrganizationId(new Guid(organizationId.ToExternalDirectoryOrganizationId())); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 205, "Create", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\UnifiedPolicy\\Validators\\ExchangeValidator.cs"); int maxLimitFromConfig = SourceValidator.GetMaxLimitFromConfig("MaxRecipientsLimit", 1000, existingRecipientsCount); return(new ExchangeValidator(tenantOrRootOrgRecipientSession, recipientGetter, writeErrorDelegate, writeWarningDelegate, shouldContinueDelegate, allowGroups, maxLimitFromConfig, logger, logTag, organizationId.ToExternalDirectoryOrganizationId(), client)); }
public SharepointValidationResult ValidateLocation(string location) { ArgumentValidator.ThrowIfNullOrWhiteSpace("location", location); if (SourceValidator.IsWideScope(location)) { base.LogOneEntry(ExecutionLog.EventType.Verbose, "Skipping validation for wide scoped location '{0}", new object[] { location }); return(new SharepointValidationResult { IsTopLevelSiteCollection = false, IsValid = true, SharepointSource = new SharepointSource(location, location, Guid.Empty, Guid.Empty) }); } SharepointValidationResult result = null; try { if (this.validateUsingSearch) { result = this.ValidateLocationBySearch(location); } else { result = this.ValidateLocationByLoad(location); } } catch (Exception ex) { base.LogOneEntry(ExecutionLog.EventType.Error, ex, "Unexpected Exception occurred when Validating the location {0}. ValidatingUsingSearch: {1}", new object[] { location, this.validateUsingSearch }); EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", base.Client.ToString(), string.Format("Unexpected exception occured when validating the sites(using search:{0}). Exception:{1}", this.validateUsingSearch, ex), ResultSeverityLevel.Error, false); throw; } return(result); }
private MultiValuedProperty <BindingMetadata> ValidateRecipientsImpl(IEnumerable <string> recipients) { MultiValuedProperty <BindingMetadata> multiValuedProperty = new MultiValuedProperty <BindingMetadata>(); bool flag = false; this.warnedSkipInvalidTypeInGroup = false; if (recipients.Count <string>() > this.maxRecipientsLimit) { base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}", new object[] { Strings.ErrorMaxMailboxLimit(this.maxRecipientsLimit, recipients.Count <string>()) }); base.WriteError(new ExValidatorException(Strings.ErrorMaxMailboxLimit(this.maxRecipientsLimit, recipients.Count <string>())), ErrorCategory.InvalidArgument); } else { foreach (string text in recipients) { if (SourceValidator.IsWideScope(text)) { base.LogOneEntry(ExecutionLog.EventType.Verbose, "Skipping validation for wide scoped value '{0}", new object[] { text }); multiValuedProperty.Add(new BindingMetadata(text, text, text, SourceValidator.GetBindingType(text))); } else { RecipientIdParameter recipientIdParameter = RecipientIdParameter.Parse(text); ReducedRecipient reducedRecipient = this.recipientGetter(recipientIdParameter, this.recipientSession); if (ExchangeValidator.IsMembershipGroup(reducedRecipient) && this.allowGroups) { if (!flag) { if (base.ShouldContinue(Strings.ShouldExpandGroups)) { flag = true; base.LogOneEntry(ExecutionLog.EventType.Information, "Got confirmation to expand groups", new object[0]); } else { base.LogOneEntry(ExecutionLog.EventType.Error, "User selected not to expand groups. {0}", new object[] { Strings.GroupsIsNotAllowedForHold(recipientIdParameter.RawIdentity) }); base.WriteError(new ExValidatorException(Strings.GroupsIsNotAllowedForHold(recipientIdParameter.RawIdentity)), ErrorCategory.InvalidArgument); } } if (flag) { this.ExpandGroupMembership(reducedRecipient, multiValuedProperty); } } else { this.VerifyAndAddRecipient(reducedRecipient, multiValuedProperty, false); } } } } return(multiValuedProperty); }
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); }