Exemplo n.º 1
0
        // Token: 0x0600045C RID: 1116 RVA: 0x0000F930 File Offset: 0x0000DB30
        internal static void VerifyServerIsWithinScope(Database database, Task.ErrorLoggerDelegate errorHandler, ITopologyConfigurationSession adConfigSession)
        {
            ADObjectId[] array = database.IsExchange2009OrLater ? database.Servers : new ADObjectId[]
            {
                database.Server
            };
            if (array == null || array.Length == 0)
            {
                errorHandler(new NoServersForDatabaseException(database.Name), ExchangeErrorCategory.Client, null);
            }
            bool             flag = false;
            ADScopeException ex   = null;

            foreach (ADObjectId adObjectId in array)
            {
                Server mailboxServer = MapiTaskHelper.GetMailboxServer(new ServerIdParameter(adObjectId), adConfigSession, errorHandler);
                if (adConfigSession.TryVerifyIsWithinScopes(mailboxServer, true, out ex))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                errorHandler(new IsOutofDatabaseScopeException(database.Name, ex.Message), ExchangeErrorCategory.Authorization, null);
            }
        }
 public ProxyAddress GenerateRemoteRoutingAddress(string alias, Task.ErrorLoggerDelegate errorWriter)
 {
     if (string.IsNullOrEmpty(this.targetDeliveryDomain))
     {
         errorWriter(new ErrorCannotFindTargetDeliveryDomainException(), ExchangeErrorCategory.Client, null);
     }
     return(ProxyAddress.Parse(alias + "@" + this.targetDeliveryDomain));
 }
 internal static void CheckMembershipRestriction(ADGroup distributionGroup, Task.ErrorLoggerDelegate errorLogger)
 {
     if (GroupTypeFlags.SecurityEnabled == (distributionGroup.GroupType & GroupTypeFlags.SecurityEnabled))
     {
         if (distributionGroup.MemberJoinRestriction != MemberUpdateType.Closed && distributionGroup.MemberJoinRestriction != MemberUpdateType.ApprovalRequired)
         {
             errorLogger(new RecipientTaskException(Strings.ErrorJoinRestrictionInvalid), ExchangeErrorCategory.Client, null);
         }
         if (distributionGroup.MemberDepartRestriction != MemberUpdateType.Closed)
         {
             errorLogger(new RecipientTaskException(Strings.ErrorDepartRestrictionInvalid), ExchangeErrorCategory.Client, null);
         }
     }
 }
 public void ReportError(Task.ErrorLoggerDelegate writeError)
 {
     if (this.errors.Count > 0)
     {
         List <ReferenceParameterException> list = new List <ReferenceParameterException>();
         foreach (KeyValuePair <string, List <ReferenceException> > keyValuePair in this.errors)
         {
             ReferenceParameterException item = new ReferenceParameterException(Strings.ErrorReferenceParameter(keyValuePair.Key), keyValuePair.Key, keyValuePair.Value.ToArray());
             list.Add(item);
         }
         MultiReferenceParameterException exception = new MultiReferenceParameterException(Strings.ErrorMultiReferenceParameter(string.Join(", ", this.errors.Keys.ToArray <string>()), string.Join(", ", this.referenceValues.ToArray <string>())), list.ToArray());
         writeError(exception, ExchangeErrorCategory.Client, null);
     }
 }
 internal static void VerifyIsNotTinyTenant(OrganizationId organizationId, Task.ErrorLoggerDelegate writeError)
 {
     if (null == organizationId)
     {
         throw new ArgumentNullException("organizationId");
     }
     if (writeError == null)
     {
         throw new ArgumentNullException("writeError");
     }
     if (SharedConfiguration.GetSharedConfiguration(organizationId) != null)
     {
         SharedConfigurationTaskHelper.WriteTinyTenantError(writeError);
     }
 }
 internal static void ValidateOrganizationAddition(ITopologyConfigurationSession configSession, OrganizationId organizationId, ExchangeUpgradeBucket exchangeUpgradeBucket, Task.ErrorLoggerDelegate errorLogger)
 {
     if (!exchangeUpgradeBucket.MaxMailboxes.IsUnlimited && !exchangeUpgradeBucket.Organizations.Contains(organizationId.ConfigurationUnit))
     {
         int mailboxCount  = UpgradeBucketTaskHelper.MailboxCountCache.GetMailboxCount(organizationId, configSession);
         int mailboxCount2 = UpgradeBucketTaskHelper.GetMailboxCount(exchangeUpgradeBucket);
         int num           = exchangeUpgradeBucket.MaxMailboxes.Value - mailboxCount2;
         if (mailboxCount > num)
         {
             errorLogger(new RecipientTaskException(Strings.ExchangeUpgradeBucketNotEnoughCapacity(exchangeUpgradeBucket.ToString(), num.ToString(), mailboxCount.ToString())), ExchangeErrorCategory.Client, organizationId);
         }
     }
 }
 internal static void ValidateSourceAndTargetVersions(string sourceVersion, string targetVersion, Task.ErrorLoggerDelegate errorLogger)
 {
     string[] array = sourceVersion.Split(new char[]
     {
         '.'
     });
     string[] array2 = targetVersion.Split(new char[]
     {
         '.'
     });
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i] != "*" && array2[i] != "*")
         {
             if (int.Parse(array[i]) < int.Parse(array2[i]))
             {
                 return;
             }
             if (int.Parse(array[i]) > int.Parse(array2[i]))
             {
                 errorLogger(new RecipientTaskException(Strings.ExchangeUpgradeBucketSourceVersionBiggerThanTarget(sourceVersion, targetVersion)), ExchangeErrorCategory.Client, null);
             }
         }
         else
         {
             errorLogger((array[i] == "*") ? new RecipientTaskException(Strings.ExchangeUpgradeBucketTargetIncludedInSource(sourceVersion, targetVersion)) : new RecipientTaskException(Strings.ExchangeUpgradeBucketSourceIncludedInTarget(sourceVersion, targetVersion)), ExchangeErrorCategory.Client, null);
         }
     }
 }
Exemplo n.º 8
0
        internal static MailboxData DiscoverPublicFolderTestMailbox(IIdentityParameter identity, IConfigurationSession configurationSession, IRecipientSession recipientSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError)
        {
            if (identity == null)
            {
                Organization orgContainer = configurationSession.GetOrgContainer();
                if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid != default(Guid))
                {
                    identity = new MailboxIdParameter(orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid.ToString());
                }
                else
                {
                    writeError(new MigrationPermanentException(Strings.ErrorUnableToFindValidPublicFolderMailbox), ExchangeErrorCategory.Client, null);
                }
            }
            ADUser aduser = RequestTaskHelper.ResolveADUser(recipientSession, recipientSession, serverSettings, identity, new OptionalIdentityData(), null, getDataObject, writeVerbose, writeError, true);

            if (aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
            {
                writeError(new MigrationPermanentException(Strings.ErrorNotPublicFolderMailbox(identity.RawIdentity)), ExchangeErrorCategory.Client, null);
            }
            return(MailboxData.CreateFromADUser(aduser));
        }
Exemplo n.º 9
0
        internal static MailboxData DiscoverTestMailbox(IIdentityParameter identity, IRecipientSession adSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError)
        {
            if (identity == null)
            {
                MigrationADProvider migrationADProvider = new MigrationADProvider(adSession);
                return(migrationADProvider.GetMailboxDataForManagementMailbox());
            }
            ADUser      aduser      = RequestTaskHelper.ResolveADUser(adSession, adSession, serverSettings, identity, null, null, getDataObject, writeVerbose, writeError, true);
            MailboxData mailboxData = new MailboxData(aduser.ExchangeGuid, new Fqdn(aduser.ServerName), aduser.LegacyExchangeDN, aduser.Id, aduser.ExchangeObjectId);

            mailboxData.Update(identity.RawIdentity, aduser.OrganizationId);
            return(mailboxData);
        }
Exemplo n.º 10
0
        // Token: 0x06000452 RID: 1106 RVA: 0x0000F624 File Offset: 0x0000D824
        internal static OrganizationIdParameter ResolveTargetOrganizationIdParameter(OrganizationIdParameter organizationParameter, IIdentityParameter identity, OrganizationId currentOrganizationId, Task.ErrorLoggerDelegate errorHandler, Task.TaskWarningLoggingDelegate warningHandler)
        {
            OrganizationIdParameter organizationIdParameter = null;

            if (identity != null)
            {
                if (identity is MailPublicFolderIdParameter)
                {
                    organizationIdParameter = (identity as MailPublicFolderIdParameter).Organization;
                }
                else if (identity is PublicFolderIdParameter)
                {
                    organizationIdParameter = (identity as PublicFolderIdParameter).Organization;
                }
            }
            if (!currentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                if (organizationIdParameter != null)
                {
                    errorHandler(new ManagementObjectNotFoundException(Strings.ErrorManagementObjectNotFound(identity.ToString())), ExchangeErrorCategory.Client, identity);
                }
            }
            else
            {
                if (organizationParameter != null)
                {
                    if (organizationIdParameter != null)
                    {
                        warningHandler(Strings.WarningDuplicateOrganizationSpecified(organizationParameter.ToString(), organizationIdParameter.ToString()));
                    }
                    organizationIdParameter = organizationParameter;
                }
                if (organizationIdParameter == null && !(identity is MailPublicFolderIdParameter))
                {
                    errorHandler(new ErrorMissOrganizationException(), ExchangeErrorCategory.Client, null);
                }
            }
            return(organizationIdParameter);
        }
Exemplo n.º 11
0
        public static ActiveDirectorySecurity ReadMailboxSecurityDescriptor(ADUser mailbox, IConfigurationSession adSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            TaskLogger.LogEnter();
            RawSecurityDescriptor exchangeSecurityDescriptor = mailbox.ExchangeSecurityDescriptor;
            RawSecurityDescriptor rawSecurityDescriptor;

            if (mailbox.RecipientType == RecipientType.SystemAttendantMailbox)
            {
                rawSecurityDescriptor = exchangeSecurityDescriptor;
            }
            else
            {
                RawSecurityDescriptor rawSecurityDescriptor2 = adSession.ReadSecurityDescriptor(mailbox.Database);
                if (rawSecurityDescriptor2 == null)
                {
                    logError(new TaskInvalidOperationException(Strings.ErrorReadDatabaseSecurityDescriptor(mailbox.Database.ToString())), ExchangeErrorCategory.ServerOperation, null);
                    return(null);
                }
                rawSecurityDescriptor = MailboxSecurity.CreateMailboxSecurityDescriptor(SecurityDescriptor.FromRawSecurityDescriptor(rawSecurityDescriptor2), SecurityDescriptor.FromRawSecurityDescriptor(exchangeSecurityDescriptor)).ToRawSecurityDescriptor();
                if (rawSecurityDescriptor == null)
                {
                    logError(new TaskInvalidOperationException(Strings.ErrorReadMailboxSecurityDescriptor(mailbox.DistinguishedName)), ExchangeErrorCategory.ServerOperation, mailbox.Identity);
                    return(null);
                }
            }
            ActiveDirectorySecurity result = SecurityDescriptorConverter.ConvertToActiveDirectorySecurity(rawSecurityDescriptor);

            TaskLogger.LogExit();
            return(result);
        }
Exemplo n.º 12
0
        // Token: 0x06000459 RID: 1113 RVA: 0x0000F8C0 File Offset: 0x0000DAC0
        internal static void VerifyIsWithinConfigWriteScope(ADSessionSettings sessionSettings, ADObject obj, Task.ErrorLoggerDelegate errorHandler)
        {
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, sessionSettings, 481, "VerifyIsWithinConfigWriteScope", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\MapiTaskHelper.cs");
            ADScopeException      ex;

            if (!tenantOrTopologyConfigurationSession.TryVerifyIsWithinScopes(obj, true, out ex))
            {
                errorHandler(new IsOutofConfigWriteScopeException(obj.GetType().ToString(), obj.Name), ExchangeErrorCategory.Client, null);
            }
        }
Exemplo n.º 13
0
        internal static string GenerateUniqueAliasForSiteMailbox(IRecipientSession recipientSession, OrganizationId organizationId, string preferredAlias, string prefix, bool isMicrosoftHostedOnlyDatacenter, Task.TaskVerboseLoggingDelegate logHandler, Task.ErrorLoggerDelegate writeError)
        {
            string text = WindowsLiveIDLocalPartConstraint.RemoveInvalidPartOfWindowsLiveID(preferredAlias);

            if (!string.IsNullOrEmpty(text) && text.Length > 3)
            {
                logHandler(Strings.VerboseGenerateAliasBySiteDisplayName(preferredAlias));
                text = RecipientTaskHelper.GenerateUniqueAlias(recipientSession, organizationId, (!string.IsNullOrEmpty(prefix)) ? (prefix + text) : text, logHandler, 63);
            }
            else
            {
                int num = 1000;
                if (string.IsNullOrEmpty(prefix))
                {
                    prefix = (isMicrosoftHostedOnlyDatacenter ? "SMO-" : "SM-");
                }
                do
                {
                    text = TeamMailboxHelper.GenerateRandomString();
                    text = prefix + text;
                    logHandler(Strings.VerboseGenerateAliasByRandomString(preferredAlias, text));
                    if (RecipientTaskHelper.IsAliasUnique(recipientSession, organizationId, null, text, logHandler, writeError, ExchangeErrorCategory.Client))
                    {
                        break;
                    }
                    text = string.Empty;
                }while (num-- > 0);
            }
            if (string.IsNullOrEmpty(text))
            {
                writeError(new ErrorCannotGenerateSiteMailboxAliasException(), ExchangeErrorCategory.Client, null);
            }
            return(text);
        }
        internal static string GetGroupNameWithNamingPolicy(Organization organization, ADUser user, ADGroup group, string groupName, PropertyDefinition property, Task.ErrorLoggerDelegate errorLogger)
        {
            DistributionGroupTaskHelper.ValidateGroupNameWithBlockedWordsList(organization, group, groupName, property, errorLogger);
            if (organization.DistributionGroupNamingPolicy == null)
            {
                errorLogger(new RecipientTaskException(Strings.ErrorDistributionGroupNamingPolicy), ExchangeErrorCategory.ServerOperation, organization.Identity);
            }
            string appliedName = organization.DistributionGroupNamingPolicy.GetAppliedName(groupName, user);

            return(appliedName.Trim());
        }
 internal static void VerifyIsNotTinyTenant(LazilyInitialized <SharedTenantConfigurationState> configurationState, Task.ErrorLoggerDelegate writeError)
 {
     if (null == configurationState)
     {
         throw new ArgumentNullException("configurationState");
     }
     if (writeError == null)
     {
         throw new ArgumentNullException("writeError");
     }
     if ((configurationState.Value & SharedTenantConfigurationState.Dehydrated) != SharedTenantConfigurationState.UnSupported)
     {
         SharedConfigurationTaskHelper.WriteTinyTenantError(writeError);
     }
 }
 internal RoleAssignmentsGlobalConstraints(IConfigurationSession configurationSession, IRecipientSession recipientSession, Task.ErrorLoggerDelegate writeError)
 {
     this.configurationSession = configurationSession;
     this.configurationSession.SessionSettings.IsSharedConfigChecked = true;
     this.recipientSession = recipientSession;
     this.writeError       = writeError;
     this.CacheRoles       = new List <ExchangeRole>();
 }
Exemplo n.º 17
0
        // Token: 0x06000450 RID: 1104 RVA: 0x0000F440 File Offset: 0x0000D640
        public static Server GetMailboxServer(ServerIdParameter serverIdParameter, ITopologyConfigurationSession configurationSession, Task.ErrorLoggerDelegate errorHandler)
        {
            if (serverIdParameter == null)
            {
                throw new ArgumentNullException("serverIdParameter");
            }
            if (configurationSession == null)
            {
                throw new ArgumentNullException("serverIdParameter");
            }
            if (errorHandler == null)
            {
                throw new ArgumentNullException("errorHandler");
            }
            IEnumerable <Server> objects = serverIdParameter.GetObjects <Server>(null, configurationSession);
            Server server = null;

            using (IEnumerator <Server> enumerator = objects.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    errorHandler(new ManagementObjectNotFoundException(Strings.ErrorServerNotFound(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                    return(null);
                }
                server = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    errorHandler(new ManagementObjectAmbiguousException(Strings.ErrorServerNotUnique(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                    return(null);
                }
            }
            if (!server.IsExchange2007OrLater)
            {
                errorHandler(new TaskInvalidOperationException(Strings.ExceptionLegacyObjects(serverIdParameter.ToString())), ExchangeErrorCategory.Context, null);
                return(null);
            }
            if (!server.IsMailboxServer)
            {
                errorHandler(new TaskInvalidOperationException(Strings.ErrorNotMailboxServer(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                return(null);
            }
            return(server);
        }
Exemplo n.º 18
0
        // Token: 0x0600045D RID: 1117 RVA: 0x0000F9E4 File Offset: 0x0000DBE4
        private static void VerifyDatabaseIsWithinScope(ADSessionSettings sessionSettings, Database database, Task.ErrorLoggerDelegate errorHandler, bool includeCheckForServer)
        {
            if (sessionSettings == null)
            {
                throw new ArgumentNullException("sessionSettings");
            }
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }
            if (errorHandler == null)
            {
                throw new ArgumentNullException("errorHandler");
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, sessionSettings, 613, "VerifyDatabaseIsWithinScope", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\MapiTaskHelper.cs");
            ADScopeException ex;

            if (!topologyConfigurationSession.TryVerifyIsWithinScopes(database, true, out ex))
            {
                errorHandler(new TaskInvalidOperationException(Strings.ErrorIsOutOfDatabaseScopeNoServerCheck(database.Name, ex.Message)), ExchangeErrorCategory.Authorization, null);
            }
            if (includeCheckForServer)
            {
                MapiTaskHelper.VerifyServerIsWithinScope(database, errorHandler, topologyConfigurationSession);
            }
        }
        internal static void ValidateOrganizationVersion(ExchangeConfigurationUnit configurationUnit, ExchangeUpgradeBucket exchangeUpgradeBucket, Task.ErrorLoggerDelegate errorLogger)
        {
            string text = configurationUnit.IsUpgradingOrganization ? exchangeUpgradeBucket.TargetVersion : exchangeUpgradeBucket.SourceVersion;

            if (!UpgradeBucketTaskHelper.ValidateExchangeObjectVersion(configurationUnit.AdminDisplayVersion, text))
            {
                errorLogger(new RecipientTaskException(Strings.ExchangeUpgradeBucketInvalidOrganizationVersion(configurationUnit.AdminDisplayVersion.ToString(), text)), ExchangeErrorCategory.Client, null);
            }
        }
Exemplo n.º 20
0
 private static void SaveAdSecurityDescriptor(ADUser mailbox, IConfigDataProvider writableAdSession, RawSecurityDescriptor rawSd, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
 {
     if (writableAdSession != null)
     {
         ADUser aduser = mailbox;
         if (mailbox.IsReadOnly)
         {
             aduser = (ADUser)writableAdSession.Read <ADUser>(mailbox.Id);
         }
         if (aduser != null)
         {
             aduser.ExchangeSecurityDescriptor = rawSd;
             logVerbose(Strings.VerboseSaveADSecurityDescriptor(aduser.Id.ToString()));
             writableAdSession.Save(aduser);
             return;
         }
         logError(new DirectoryObjectNotFoundException(mailbox.Id.DistinguishedName), ExchangeErrorCategory.ServerOperation, null);
     }
 }
 private static void WriteTinyTenantError(Task.ErrorLoggerDelegate writeError)
 {
     writeError(new InvalidOperationInDehydratedContextException(Strings.ErrorWriteOpOnDehydratedTenant), ExchangeErrorCategory.Context, null);
 }
Exemplo n.º 22
0
 // Token: 0x0600045B RID: 1115 RVA: 0x0000F924 File Offset: 0x0000DB24
 internal static void VerifyDatabaseIsWithinScope(ADSessionSettings sessionSettings, Database database, Task.ErrorLoggerDelegate errorHandler)
 {
     MapiTaskHelper.VerifyDatabaseIsWithinScope(sessionSettings, database, errorHandler, false);
 }
        internal static void ValidateGroupNameWithBlockedWordsList(Organization organization, ADGroup group, string groupName, PropertyDefinition property, Task.ErrorLoggerDelegate errorLogger)
        {
            if (organization == null)
            {
                throw new ArgumentNullException("organization");
            }
            if (group == null)
            {
                throw new ArgumentNullException("group");
            }
            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentNullException("groupName");
            }
            string text = groupName.ToLower();

            foreach (string text2 in organization.DistributionGroupNameBlockedWordsList)
            {
                if (text.Contains(text2.ToLower()))
                {
                    throw new DataValidationException(new PropertyValidationError(Strings.ErrorGroupNameContainBlockedWords(text2), property, null));
                }
            }
        }
Exemplo n.º 24
0
 public static void ValidateExternalEmailAddress(ADContact contact, IConfigurationSession configurationSession, Task.ErrorLoggerDelegate writeError, ProvisioningCache provisioningCache)
 {
     if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled)
     {
         SmtpProxyAddress smtpProxyAddress = contact.ExternalEmailAddress as SmtpProxyAddress;
         if (smtpProxyAddress == null)
         {
             writeError(new RecipientTaskException(Strings.ErrorExternalEmailAddressNotSmtpAddress((contact.ExternalEmailAddress == null) ? "$null" : contact.ExternalEmailAddress.ToString())), ExchangeErrorCategory.Client, contact.Identity);
             return;
         }
         if (RecipientTaskHelper.SMTPAddressCheckWithAcceptedDomain(configurationSession, contact.OrganizationId, writeError, provisioningCache))
         {
             string domain = new SmtpAddress(smtpProxyAddress.SmtpAddress).Domain;
             if (RecipientTaskHelper.IsAcceptedDomain(configurationSession, contact.OrganizationId, domain, provisioningCache))
             {
                 writeError(new RecipientTaskException(Strings.ErrorIsAcceptedDomain(domain)), ExchangeErrorCategory.Client, null);
             }
         }
         contact.EmailAddressPolicyEnabled = false;
         if (contact.PrimarySmtpAddress == SmtpAddress.Empty)
         {
             contact.PrimarySmtpAddress = new SmtpAddress(smtpProxyAddress.SmtpAddress);
         }
     }
 }
Exemplo n.º 25
0
        private static void SaveArchiveSecurityDescriptor(ADUser mailbox, IConfigDataProvider writableAdSession, RawSecurityDescriptor rawSd, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            ADObjectId adobjectId = mailbox.ArchiveDatabase ?? mailbox.Database;
            MailboxId  mailboxId  = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), mailbox.ArchiveGuid);

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(adobjectId.ObjectGuid);
                using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn)))
                {
                    logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName));
                    mapiMessageStoreSession.ForceStoreToRefreshMailbox(mailboxId);
                }
            }
            catch (FormatException)
            {
                logError(new TaskInvalidOperationException(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString())), ExchangeErrorCategory.ServerOperation, null);
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseArchiveNotExistInStore(mailbox.Name));
                PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
            catch (LocalizedException exception)
            {
                logError(new SetArchivePermissionException(mailbox.Name, exception), ExchangeErrorCategory.ServerOperation, null);
            }
        }
Exemplo n.º 26
0
        internal static void CheckModeratedMailboxes(ADUser user, IConfigDataProvider session, Task.ErrorLoggerDelegate writeError)
        {
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.ModerationEnabled, true),
                new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.ModeratedBy, user.Id)
            });
            IEnumerable <ADUser> enumerable = session.FindPaged <ADUser>(filter, null, true, null, 1);

            using (IEnumerator <ADUser> enumerator = enumerable.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    writeError(new RecipientTaskException(Strings.ErrorRemoveModeratorMailbox(user.Name)), ExchangeErrorCategory.Client, user);
                }
            }
        }
Exemplo n.º 27
0
        public static void SetMailboxAces(ADUser mailbox, IConfigDataProvider writableAdSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.TaskWarningLoggingDelegate logWarning, Task.ErrorLoggerDelegate logError, IConfigurationSession adSession, ref MapiMessageStoreSession storeSession, bool remove, params ActiveDirectoryAccessRule[] aces)
        {
            ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadMailboxSecurityDescriptor(mailbox, adSession, logVerbose, logError);

            if (activeDirectorySecurity != null)
            {
                DirectoryCommon.ApplyAcesOnAcl(logVerbose, logWarning, null, mailbox.DistinguishedName, activeDirectorySecurity, remove, aces);
                PermissionTaskHelper.SaveMailboxSecurityDescriptor(mailbox, activeDirectorySecurity, writableAdSession, ref storeSession, logVerbose, logError);
            }
        }
 internal override ScopeSet CalculateScopeSetForExchangeCmdlet(string exchangeCmdletName, IList <string> parameters, OrganizationId organizationId, Task.ErrorLoggerDelegate writeError)
 {
     if (this.IsMaximumAgeLimitExceeded(ExpirationLimit.RunspaceRefresh))
     {
         base.LoadRoleCmdletInfo();
         this.SetMaxAgeLimit(ExpirationLimit.RunspaceRefresh);
         base.RefreshProvisioningBroker();
     }
     return(base.CalculateScopeSetForExchangeCmdlet(exchangeCmdletName, parameters, organizationId, writeError));
 }
Exemplo n.º 29
0
        public static void SaveMailboxSecurityDescriptor(ADUser mailbox, ActiveDirectorySecurity adSecurity, IConfigDataProvider writableAdSession, ref MapiMessageStoreSession storeSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            if (writableAdSession == null)
            {
                throw new ArgumentException("writableAdSession");
            }
            RawSecurityDescriptor rawSd = new RawSecurityDescriptor(adSecurity.GetSecurityDescriptorBinaryForm(), 0);

            PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            string text = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid);
                text = serverForDatabase.ServerFqdn;
                if (storeSession == null)
                {
                    storeSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                else
                {
                    storeSession.RedirectServer(serverForDatabase.ServerLegacyDN, Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid);
                logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), storeSession.ServerName));
                storeSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
            }
            catch (DatabaseNotFoundException)
            {
                logVerbose(Strings.ErrorMailboxDatabaseNotFound(mailbox.Database.ToString()));
            }
            catch (MapiExceptionNetworkError)
            {
                logVerbose(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty));
            }
            catch (FormatException)
            {
                logVerbose(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString()));
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseMailboxNotExistInStore(mailbox.DistinguishedName));
            }
            if (mailbox.HasLocalArchive)
            {
                PermissionTaskHelper.SaveArchiveSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
        }
Exemplo n.º 30
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.isToInactiveMailbox         = false;
     this.isDisconnectInactiveMailbox = false;
     if (this.Identity != null)
     {
         base.InternalValidate();
         this.isToInactiveMailbox         = this.IsToInactiveMailbox();
         this.isDisconnectInactiveMailbox = this.IsDisconnectInactiveMailbox();
         if (!this.isToInactiveMailbox && !this.isDisconnectInactiveMailbox)
         {
             MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
             MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
         }
         MailboxTaskHelper.BlockRemoveOrDisableIfJournalNDRMailbox(base.DataObject, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false);
         if (ComplianceConfigImpl.JournalArchivingHardeningEnabled && !this.skipJournalArchivingCheck)
         {
             MailboxTaskHelper.BlockRemoveOrDisableMailboxIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false);
         }
         if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.ArbitrationMailbox && this.ArbitrationMailboxUsageValidationRequired)
         {
             ADUser dataObject = base.DataObject;
             Task.ErrorLoggerDelegate writeError = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity = this.Identity;
             MailboxTaskHelper.ValidateNotBuiltInArbitrationMailbox(dataObject, writeError, Strings.ErrorRemoveArbitrationMailbox(identity.ToString()));
             ADUser                   dataObject2 = base.DataObject;
             IRecipientSession        tenantGlobalCatalogSession = base.TenantGlobalCatalogSession;
             Task.ErrorLoggerDelegate writeError2 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity                identity2   = this.Identity;
             MailboxTaskHelper.ValidateArbitrationMailboxHasNoGroups(dataObject2, tenantGlobalCatalogSession, writeError2, Strings.ErrorRemoveMailboxWithAssociatedApprovalRecipents(identity2.ToString()));
             ADUser dataObject3   = base.DataObject;
             bool   overrideCheck = this.RemoveArbitrationMailboxWithOABsAllowed.ToBool();
             Task.ErrorLoggerDelegate writeError3 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity3 = this.Identity;
             MailboxTaskHelper.ValidateNoOABsAssignedToArbitrationMailbox(dataObject3, overrideCheck, writeError3, Strings.ErrorRemoveArbitrationMailboxWithOABsAssigned(identity3.ToString()));
             ADUser            dataObject4 = base.DataObject;
             IRecipientSession tenantGlobalCatalogSession2 = base.TenantGlobalCatalogSession;
             ADObjectId        rootOrgContainerId          = base.RootOrgContainerId;
             bool isPresent = this.RemoveLastArbitrationMailboxAllowed.IsPresent;
             Task.ErrorLoggerDelegate writeError4 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity4 = this.Identity;
             MailboxTaskHelper.ValidateNotLastArbitrationMailbox(dataObject4, tenantGlobalCatalogSession2, rootOrgContainerId, isPresent, writeError4, Strings.ErrorCannotRemoveLastArbitrationMailboxInOrganization(identity4.ToString()));
         }
         if (this.AuditLog)
         {
             if (base.DataObject.RecipientTypeDetails != RecipientTypeDetails.AuditLogMailbox)
             {
                 LocalizedException    exception = new RecipientTaskException(Strings.ErrorSpecifiedMailboxShouldBeAuditLogMailbox(base.DataObject.Identity.ToString()));
                 ExchangeErrorCategory category  = ExchangeErrorCategory.Context;
                 TIdentity             identity5 = this.Identity;
                 base.WriteError(exception, category, identity5.ToString());
             }
         }
         else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox)
         {
             LocalizedException    exception2 = new RecipientTaskException(Strings.ErrorAuditLogMailboxShouldBeDeletedWithAuditLogSpecified(base.DataObject.Identity.ToString()));
             ExchangeErrorCategory category2  = ExchangeErrorCategory.Context;
             TIdentity             identity6  = this.Identity;
             base.WriteError(exception2, category2, identity6.ToString());
         }
     }
     else
     {
         this.InternalValidateStoreMailboxIdentity();
         try
         {
             this.mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.StoreMailboxIdentity, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(this.database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), ExchangeErrorCategory.Client);
             MailboxTaskHelper.ValidateMailboxIsDisconnected(base.TenantGlobalCatalogSession, this.mailboxStatistics.MailboxGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
             this.mailboxStatistics.Database = this.database.Identity;
         }
         catch (DataSourceTransientException exception3)
         {
             base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, this.StoreMailboxIdentity);
         }
     }
     if (this.PublicFolder)
     {
         Organization orgContainer = this.TenantLocalConfigurationSession.GetOrgContainer();
         if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid == Guid.Empty && !this.Force)
         {
             LocalizedException    exception4 = new RecipientTaskException(Strings.ErrorPrimaryPublicFolderMailboxNotFound);
             ExchangeErrorCategory category3  = ExchangeErrorCategory.Context;
             TIdentity             identity7  = this.Identity;
             base.WriteError(exception4, category3, identity7.ToString());
         }
         if (this.currentOrganizationId == null || this.currentOrganizationId != base.DataObject.OrganizationId)
         {
             this.currentOrganizationId = base.DataObject.OrganizationId;
             TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.DataObject.OrganizationId);
         }
         MailboxTaskHelper.RemoveOrDisablePublicFolderMailbox(base.DataObject, Guid.Empty, this.tenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false, this.Force);
     }
     TaskLogger.LogExit();
 }