Пример #1
0
        public override bool Verify()
        {
            TaskLogger.LogEnter();
            bool flag = false;

            if (this.webSitePath != null)
            {
                flag = IisUtility.Exists(this.WebSitePath, "IIsWebServer");
            }
            else
            {
                try
                {
                    IisUtility.FindWebSiteRoot(this.WebSiteName, this.ServerName);
                    flag = true;
                }
                catch (WebObjectNotFoundException)
                {
                    flag = false;
                }
            }
            TaskLogger.Trace("WebSiteExistsCondition is returning '{0}'", new object[]
            {
                flag
            });
            TaskLogger.LogExit();
            return(flag);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (base.FirewallRule != null)
     {
         TaskLogger.Trace("Removing Windows Firewall Rule: {0}", new object[]
         {
             base.FirewallRule.Name
         });
         base.FirewallRule.Remove();
     }
     else if (!string.IsNullOrEmpty(base.Name) && base.BinaryPath != null)
     {
         TaskLogger.Trace("Removing binary {0} from windows firewall exception", new object[]
         {
             base.Name
         });
         ManageService.RemoveAssemblyFromFirewallExceptions(base.Name, base.BinaryPath.PathName, new Task.TaskErrorLoggingDelegate(base.WriteError));
     }
     else
     {
         TaskLogger.Trace("ERROR: No Firewall Rule/Exception specified!", new object[0]);
     }
     TaskLogger.LogExit();
 }
Пример #3
0
        private bool ServerHasMailboxRole(string serverName)
        {
            MiniServer miniServer = null;

            try
            {
                miniServer = this.m_adSession.FindMiniServerByFqdn(SharedHelper.GetFqdnNameFromNode(serverName), FileShareWitness.s_miniServerProperties);
            }
            catch (ADTransientException ex)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex
                });
            }
            catch (ADExternalException ex2)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex2
                });
            }
            catch (ADOperationException ex3)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex3
                });
            }
            return(miniServer != null && miniServer.IsMailboxServer);
        }
Пример #4
0
        protected void CheckDatabaseStatus()
        {
            TDataObject dataObject = base.DataObject;

            this.server = dataObject.GetServer();
            if (this.server == null)
            {
                TDataObject dataObject2 = base.DataObject;
                this.WriteWarning(Strings.ErrorDBOwningServerNotFound(dataObject2.Identity.ToString()));
                return;
            }
            TDataObject dataObject3 = base.DataObject;

            base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.server.Fqdn));
            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(this.server.Fqdn))
            {
                base.WriteVerbose(Strings.VerboseCheckDatabaseStatus(dataObject3.Identity.ToString()));
                Guid[] dbGuids = new Guid[]
                {
                    dataObject3.Guid
                };
                MdbStatus[] array;
                if (this.ListMdbStatus(newStoreControllerInstance, dbGuids, out array) == null)
                {
                    if (array.Length == 0)
                    {
                        TaskLogger.Trace("The database being removed does not have storage", new object[0]);
                    }
                    else if (MdbStatusFlags.Backup == (array[0].Status & MdbStatusFlags.Backup))
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(dataObject3.Name)), ErrorCategory.InvalidOperation, dataObject3.Identity);
                    }
                }
            }
        }
Пример #5
0
 private void FillDatabaseSize(ExRpcAdmin rpcAdmin, Database database)
 {
     try
     {
         FaultInjectionUtils.FaultInjectionTracer.TraceTest(3395693885U);
         ulong bytesValue;
         ulong bytesValue2;
         rpcAdmin.GetDatabaseSize(database.Guid, out bytesValue, out bytesValue2);
         database.DatabaseSize             = new ByteQuantifiedSize?(ByteQuantifiedSize.FromBytes(bytesValue));
         database.AvailableNewMailboxSpace = new ByteQuantifiedSize?(ByteQuantifiedSize.FromBytes(bytesValue2));
     }
     catch (MapiExceptionNoSupport)
     {
     }
     catch (MapiPermanentException ex)
     {
         TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.FillDatabaseSize(Database '{0}') raises exception: {1}", new object[]
         {
             database.Identity.ToString(),
             ex.Message
         }), new object[0]);
         this.WriteWarning(Strings.ErrorFailedToGetDatabaseSize(database.Identity.ToString()));
     }
     catch (MapiRetryableException ex2)
     {
         TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.FillDatabaseSize(Database '{0}') raises exception: {1}", new object[]
         {
             database.Identity.ToString(),
             ex2.Message
         }), new object[0]);
         this.WriteWarning(Strings.ErrorFailedToGetDatabaseSize(database.Identity.ToString()));
     }
 }
Пример #6
0
        protected void RemoveSystemMailbox()
        {
            TDataObject dataObject = base.DataObject;
            ADObjectId  adobjectId = ((ADObjectId)dataObject.Identity).DomainId;

            adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
            adobjectId = adobjectId.GetChildId("SystemMailbox" + dataObject.Guid.ToString("B"));
            try
            {
                string identity = adobjectId.ToDNString();
                GeneralMailboxIdParameter generalMailboxIdParameter = GeneralMailboxIdParameter.Parse(identity);
                base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(generalMailboxIdParameter, this.RecipientSessionForSystemMailbox, typeof(ADRecipient), null));
                IEnumerable <ADSystemMailbox> objects = generalMailboxIdParameter.GetObjects <ADSystemMailbox>(null, this.RecipientSessionForSystemMailbox);
                using (IEnumerator <ADSystemMailbox> enumerator = objects.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ADSystemMailbox adsystemMailbox = enumerator.Current;
                        base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.RecipientSessionForSystemMailbox));
                        base.WriteVerbose(Strings.VerboseDeleteSystemAttendantObject(adsystemMailbox.Identity.ToString()));
                        this.RecipientSessionForSystemMailbox.Delete(adsystemMailbox);
                    }
                }
            }
            catch (DataSourceTransientException ex)
            {
                TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[]
                {
                    dataObject.Identity.ToString(),
                    ex.Message
                });
                this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex.Message));
            }
            catch (DataSourceOperationException ex2)
            {
                TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[]
                {
                    dataObject.Identity.ToString(),
                    ex2.Message
                });
                this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex2.Message));
            }
            catch (DataValidationException ex3)
            {
                TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[]
                {
                    dataObject.Identity.ToString(),
                    ex3.Message
                });
                this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex3.Message));
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.RecipientSessionForSystemMailbox));
            }
            TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' succeeded.", new object[]
            {
                dataObject.Identity.ToString()
            });
        }
Пример #7
0
        public override bool Verify()
        {
            bool flag = true;

            foreach (Database database in base.Databases)
            {
                if (string.Equals((null == database.EdbFilePath) ? string.Empty : database.EdbFilePath.PathName, this.edbFileLocation, StringComparison.OrdinalIgnoreCase))
                {
                    TaskLogger.Trace("The specifed path '{0}' equals to the product Edb file location or copy Edb file location of database '{1}'", new object[]
                    {
                        this.edbFileLocation,
                        (ADObjectId)database.Identity
                    });
                    flag = false;
                    break;
                }
            }
            TaskLogger.Trace("EdbFileLocationUniqueUnderServerCondition.Verify() returns {0}: <Server '{1}', PathName '{2}'>", new object[]
            {
                flag,
                base.ServerId.ToString(),
                this.edbFileLocation
            });
            return(flag);
        }
Пример #8
0
        protected override void ProcessMetabaseProperties(ExchangeVirtualDirectory dataObject)
        {
            TaskLogger.LogEnter();
            base.ProcessMetabaseProperties(dataObject);
            ADOwaVirtualDirectory adowaVirtualDirectory = (ADOwaVirtualDirectory)dataObject;

            try
            {
                WebAppVirtualDirectoryHelper.UpdateFromMetabase(adowaVirtualDirectory);
                if (adowaVirtualDirectory.GzipLevel != GzipLevel.Off && !adowaVirtualDirectory.IsExchange2007OrLater && this.IsMailboxRoleInstalled(adowaVirtualDirectory))
                {
                    this.WriteWarning(Strings.OwaGzipEnabledOnLegacyVirtualDirectoryWhenMailboxRoleInstalledWarning(adowaVirtualDirectory.Id.Name));
                }
            }
            catch (Exception ex)
            {
                TaskLogger.Trace("Exception occurred: {0}", new object[]
                {
                    ex.Message
                });
                this.WriteError(new LocalizedException(Strings.OwaMetabaseGetPropertiesFailure), ErrorCategory.InvalidOperation, null, false);
            }
            finally
            {
                TaskLogger.LogExit();
            }
        }
        protected override IConfigDataProvider CreateSession()
        {
            OrganizationId organizationId = this.ResolveCurrentOrganization();
            ADUser         tenantArbitrationMailbox;

            try
            {
                tenantArbitrationMailbox = AdminAuditLogHelper.GetTenantArbitrationMailbox(organizationId);
            }
            catch (ObjectNotFoundException innerException)
            {
                TaskLogger.Trace("ObjectNotFoundException occurred when getting Exchange principal from the arbitration mailbox.", new object[0]);
                throw new AuditLogSearchArbitrationMailboxNotFoundException(organizationId.ToString(), innerException);
            }
            catch (NonUniqueRecipientException innerException2)
            {
                TaskLogger.Trace("More than one tenant arbitration mailbox found for the current organization.", new object[0]);
                throw new AuditLogSearchNonUniqueArbitrationMailboxFoundException(organizationId.ToString(), innerException2);
            }
            ExchangePrincipal principal       = ExchangePrincipal.FromADUser(ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), tenantArbitrationMailbox, RemotingOptions.AllowCrossSite);
            ADSessionSettings sessionSettings = base.CurrentOrganizationId.ToADSessionSettings();

            this.recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.FullyConsistent, sessionSettings, 310, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AuditLogSearch\\NewAuditLogSearch.cs");
            return(this.InternalCreateSearchDataProvider(principal, organizationId));
        }
 internal static bool TryCompressXmlBytes(byte[] uncompressedXmlBytes, out byte[] compressedXmlBytes)
 {
     compressedXmlBytes = null;
     if (uncompressedXmlBytes == null)
     {
         return(false);
     }
     using (MemoryStream memoryStream = new MemoryStream())
     {
         using (Package package = Package.Open(memoryStream, FileMode.Create))
         {
             PackagePart packagePart = package.CreatePart(ClassificationDefinitionUtils.defaultXmlContentPackagePartUri, "text/xml", CompressionOption.Normal);
             try
             {
                 packagePart.GetStream().Write(uncompressedXmlBytes, 0, uncompressedXmlBytes.Length);
             }
             catch (IOException ex)
             {
                 TaskLogger.Trace("IOException encountered while compressing classification rule collection payload: {0}", new object[]
                 {
                     ex.Message
                 });
                 return(false);
             }
         }
         compressedXmlBytes = memoryStream.ToArray();
     }
     return(true);
 }
        private void MoveDatabasesBackToServer()
        {
            Exception ex = null;

            try
            {
                int            mountDialOverride        = (int)this.MountDialOverride;
                AmDbActionCode actionCode               = new AmDbActionCode(AmDbActionInitiator.Admin, AmDbActionReason.Cmdlet, AmDbActionCategory.Move);
                List <AmDatabaseMoveResult> moveResults = AmRpcClientHelper.ServerMoveAllDatabases(null, this.m_targetServer.Fqdn, 0, 16, mountDialOverride, false, (int)this.GetSkipFlags(), (int)actionCode, this.MoveComment, out this.m_lastServerContacted);
                this.m_output.WriteProgress(Strings.ProgressStatusCompleted, this.GetRpcDoneProgressString(), 100);
                this.WriteMoveBackResults(moveResults);
            }
            catch (AmReplayServiceDownException ex2)
            {
                ex = new InvalidOperationException(Strings.ErrorActiveManagerIsNotReachable(ex2.ServerName, ex2.RpcErrorMessage));
            }
            catch (AmServerException ex3)
            {
                ex = ex3;
            }
            catch (AmServerTransientException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                TaskLogger.Trace("MoveActiveMdb.MoveDatabasesBackToServer raised exception while moving databases: {0}", new object[]
                {
                    ex
                });
                this.m_output.WriteError(ex, ErrorCategory.InvalidOperation, this.m_targetServer.Identity);
            }
        }
Пример #12
0
 private bool?GetAuthentication(ExchangeVirtualDirectory dataObject, string subVDirName, AuthenticationMethodFlags authFlags)
 {
     TaskLogger.LogEnter();
     try
     {
         string text = dataObject.MetabasePath;
         if (!string.IsNullOrEmpty(subVDirName))
         {
             text = string.Format("{0}/{1}", text, subVDirName);
         }
         if (IisUtility.Exists(text))
         {
             using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(text, new Task.TaskErrorLoggingReThrowDelegate(this.WriteError), dataObject.Identity))
             {
                 bool ignoreAnonymousOnCert = dataObject is ADPowerShellCommonVirtualDirectory;
                 return(new bool?(IisUtility.CheckForAuthenticationMethod(directoryEntry, authFlags, ignoreAnonymousOnCert)));
             }
         }
     }
     catch (Exception ex)
     {
         TaskLogger.Trace("Exception occurred: {0}", new object[]
         {
             ex.Message
         });
         base.WriteError(new LocalizedException(this.MetabaseGetPropertiesFailureMessage, ex), (ErrorCategory)1001, dataObject.Identity);
     }
     finally
     {
         TaskLogger.LogExit();
     }
     return(null);
 }
        public override bool Verify()
        {
            int  num  = this.isEnterprise ? 100 : 5;
            bool flag = false;

            foreach (StorageGroup storageGroup in base.StorageGroups)
            {
                if (storageGroup.Recovery)
                {
                    flag = true;
                }
            }
            bool flag2;

            if (this.isForRecovery)
            {
                flag2 = !flag;
            }
            else
            {
                flag2 = (base.StorageGroups.Count < (flag ? (num + 1) : num));
            }
            TaskLogger.Trace("StorageGroupNumberLessThanMaxLimitCondition.Verify() returns {0}: <Server '{1}'>", new object[]
            {
                flag2,
                base.ServerId.ToString()
            });
            return(flag2);
        }
Пример #14
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            ADMobileVirtualDirectory dataObject = this.DataObject;

            MobileSyncVirtualDirectoryHelper.SetToMetabase(dataObject, this);
            if (base.Fields.Contains("InstallIsapiFilter") && this.InstallIsapiFilter)
            {
                try
                {
                    MobileSyncVirtualDirectoryHelper.InstallIsapiFilter(this.DataObject, !ExchangeServiceVDirHelper.IsBackEndVirtualDirectory(this.DataObject));
                }
                catch (Exception ex)
                {
                    TaskLogger.Trace("Exception occurred in InstallIsapiFilter(): {0}", new object[]
                    {
                        ex.Message
                    });
                    this.WriteWarning(Strings.ActiveSyncMetabaseIsapiInstallFailure);
                    throw;
                }
            }
            TaskLogger.LogExit();
        }
 private void UpdateCompressionSettings()
 {
     if (base.Fields.IsModified("GzipLevel"))
     {
         string metabasePath = this.DataObject.MetabasePath;
         Gzip.SetIisGzipLevel(IisUtility.WebSiteFromMetabasePath(metabasePath), GzipLevel.High);
         Gzip.SetVirtualDirectoryGzipLevel(metabasePath, this.DataObject.GzipLevel);
         if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
         {
             try
             {
                 Gzip.SetIisGzipMimeTypes();
             }
             catch (Exception ex)
             {
                 TaskLogger.Trace("Exception occurred in SetIisGzipMimeTypes(): {0}", new object[]
                 {
                     ex.Message
                 });
                 this.WriteWarning(Strings.SetIISGzipMimeTypesFailure);
                 throw;
             }
         }
     }
 }
Пример #16
0
        private bool IsValidResult(GetFederationInformationResult result, string expectedDomain)
        {
            if (result == null)
            {
                return(false);
            }
            if (result.Type != AutodiscoverResult.Success)
            {
                return(false);
            }
            bool flag = false;

            foreach (string y in result.Domains)
            {
                if (StringComparer.OrdinalIgnoreCase.Equals(expectedDomain, y))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                TaskLogger.Trace("Response from is not valid because domain {0} is not present in Domains element: {1}", new object[]
                {
                    expectedDomain,
                    result.Domains
                });
                return(false);
            }
            return(true);
        }
        protected override void InternalProcessMetabase()
        {
            TaskLogger.LogEnter();
            base.InternalProcessMetabase();
            if (base.Role == VirtualDirectoryRole.ClientAccess && Datacenter.IsMicrosoftHostedOnly(false) && ((Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 1) || Environment.OSVersion.Version.Major >= 7))
            {
                if (DirectoryEntry.Exists(this.DataObject.MetabasePath))
                {
                    TaskLogger.Trace("MultiTenancy mode: installing AuthModuleFilter isapi filter", new object[0]);
                    try
                    {
                        NewAutodiscoverVirtualDirectory.InstallAuthModuleIsapiFilter(this.DataObject);
                        goto IL_DE;
                    }
                    catch (Exception ex)
                    {
                        TaskLogger.Trace("Exception occurred in InstallIsapiFilter(): {0}", new object[]
                        {
                            ex.Message
                        });
                        this.WriteWarning(Strings.AuthModuleFilterMetabaseIsapiInstallFailure);
                        throw;
                    }
                }
                base.WriteError(new InvalidOperationException(Strings.ErrorMetabasePathNotFound(this.DataObject.MetabasePath)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
IL_DE:
            TaskLogger.LogExit();
        }
Пример #18
0
        public override bool Verify()
        {
            bool flag = true;

            foreach (Database database in base.Databases)
            {
                ADObjectId[] serversToCompare;
                if (database.Servers != null && database.Servers.Length != 0)
                {
                    serversToCompare = database.Servers;
                }
                else
                {
                    serversToCompare = new ADObjectId[]
                    {
                        database.Server
                    };
                }
                if (string.Equals((null == database.LogFolderPath) ? string.Empty : database.LogFolderPath.PathName, this.logLocation, StringComparison.OrdinalIgnoreCase) && EdbFileLocationUniqueUnderDAGCondition.HasCommonServer(this.serversOfMyDBCopies, serversToCompare))
                {
                    flag = false;
                    break;
                }
            }
            TaskLogger.Trace("DbLogLocationUniqueUnderServerCondition.Verify() returns {0}: <Server '{1}', LogLocation '{2}'>", new object[]
            {
                flag,
                base.ServerId.ToString(),
                this.logLocation
            });
            return(flag);
        }
Пример #19
0
        private void UpdateCompressionSettings()
        {
            if (this.GzipLevel == GzipLevel.Error)
            {
                base.WriteError(new TaskException(Strings.GzipCannotBeSetToError), ErrorCategory.NotSpecified, null);
                return;
            }
            if (this.GzipLevel == GzipLevel.Low)
            {
                this.WriteWarning(Strings.GzipLowDoesNotUseDynamicCompression);
            }
            string metabasePath = this.DataObject.MetabasePath;

            Gzip.SetIisGzipLevel(IisUtility.WebSiteFromMetabasePath(metabasePath), GzipLevel.High);
            Gzip.SetVirtualDirectoryGzipLevel(metabasePath, this.DataObject.GzipLevel);
            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    Gzip.SetIisGzipMimeTypes();
                }
                catch (Exception ex)
                {
                    TaskLogger.Trace("Exception occurred in SetIisGzipMimeTypes(): {0}", new object[]
                    {
                        ex.Message
                    });
                    this.WriteWarning(Strings.SetIISGzipMimeTypesFailure);
                    throw;
                }
            }
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         if (!this.Force)
         {
             OfflineAddressBook[] array = this.ConfigurationSession.FindOABsForWebDistributionPoint(base.DataObject);
             if (array != null && array.Length > 0)
             {
                 StringBuilder stringBuilder = new StringBuilder();
                 stringBuilder.Append(array[0].Name);
                 for (int i = 1; i < array.Length; i++)
                 {
                     stringBuilder.Append(", ");
                     stringBuilder.Append(array[i].Name);
                 }
                 if (!base.ShouldContinue(Strings.RemoveNonEmptyOabVirtualDirectory(this.Identity.ToString(), stringBuilder.ToString())))
                 {
                     return;
                 }
             }
         }
     }
     catch (DataSourceTransientException ex)
     {
         TaskLogger.Trace("The action of quary offline address books associcated with this virtual directory raised exception {0}", new object[]
         {
             ex.ToString()
         });
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
        private IEnumerable <MailboxAuditLogRecord> SearchMailboxStorage(EwsAuditClient ewsClient, bool isArchive)
        {
            FolderIdType auditRootId;
            bool         auditExists = ewsClient.FindFolder("Audits", isArchive ? MailboxAuditLogSearchWorker.ArchiveRecoverableItemsRootId : MailboxAuditLogSearchWorker.RecoverableItemsRootId, out auditRootId);

            if (auditExists)
            {
                TaskLogger.Trace("Search query filter is defined. Searching audit log messages in audit folder", new object[0]);
                int maxCount = this.resultSize.IsUnlimited ? int.MaxValue : ((this.resultSize.Value > this.outputCount) ? (this.resultSize.Value - this.outputCount) : 0);
                EwsAuditLogCollection logCollection = new EwsAuditLogCollection(ewsClient, auditRootId);
                IEnumerable <MailboxAuditLogRecord> records;
                if (this.queryString != null)
                {
                    records = AuditLogSearchQuery.SearchAuditLogs <MailboxAuditLogRecord, QueryStringType>(logCollection, this.queryString, maxCount, TimeSpan.FromSeconds((double)this.searchTimeoutSeconds), new MailboxAuditLogSearchWorker.QueryStrategy(this), MailboxAuditLogSearchWorker.Tracer);
                }
                else
                {
                    records = AuditLogSearchQuery.SearchAuditLogs <MailboxAuditLogRecord, RestrictionType>(logCollection, this.queryFilter, maxCount, TimeSpan.FromSeconds((double)this.searchTimeoutSeconds), new MailboxAuditLogSearchWorker.QueryStrategy(this), MailboxAuditLogSearchWorker.Tracer);
                }
                foreach (MailboxAuditLogRecord record in records)
                {
                    yield return(record);
                }
            }
            yield break;
        }
Пример #22
0
		public static void PruneServerList(IList<ADObjectId> serverIds, IList<RoutingGroupConnector> alternateConnectors)
		{
			TaskLogger.LogEnter();
			int i = 0;
			while (i < serverIds.Count)
			{
				bool flag = false;
				foreach (RoutingGroupConnector routingGroupConnector in alternateConnectors)
				{
					if (routingGroupConnector.SourceTransportServers.Contains(serverIds[i]))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					TaskLogger.Trace("Removing server '{0}' from the list", new object[]
					{
						serverIds[i].Name
					});
					serverIds.RemoveAt(i);
				}
				else
				{
					i++;
				}
			}
			TaskLogger.LogExit();
		}
Пример #23
0
		public static IList<RoutingGroupConnector> GetAlternateRgcs(RoutingGroupConnector connectorBeingProcessed, IConfigurationSession session, out RoutingGroupConnector savedConnector)
		{
			TaskLogger.Trace("Reading alternate RGCs for RG '{0}'", new object[]
			{
				connectorBeingProcessed.SourceRoutingGroup
			});
			ADPagedReader<RoutingGroupConnector> adpagedReader = session.FindPaged<RoutingGroupConnector>(connectorBeingProcessed.SourceRoutingGroup, QueryScope.SubTree, null, null, ADGenericPagedReader<RoutingGroupConnector>.DefaultPageSize);
			savedConnector = null;
			IList<RoutingGroupConnector> list = new List<RoutingGroupConnector>();
			foreach (RoutingGroupConnector routingGroupConnector in adpagedReader)
			{
				if (connectorBeingProcessed.TargetRoutingGroup.Equals(routingGroupConnector.TargetRoutingGroup))
				{
					if (connectorBeingProcessed.Id.Equals(routingGroupConnector.Id))
					{
						savedConnector = routingGroupConnector;
					}
					else
					{
						list.Add(routingGroupConnector);
					}
				}
			}
			TaskLogger.Trace("Found {0} alternate RGCs", new object[]
			{
				list.Count
			});
			return list;
		}
Пример #24
0
        protected virtual void PopulateCalculatedProperties()
        {
            TaskLogger.Trace("Resolving sid", new object[0]);
            SecurityIdentifier sid = (SecurityIdentifier)this.RealAce.IdentityReference;

            this.User = new SecurityPrincipalIdParameter(sid);
            this.Deny = (this.realAce.AccessControlType == AccessControlType.Deny);
        }
Пример #25
0
		public static void SetConnectorId(SendConnector connector, ADObjectId sourceRgId)
		{
			connector.SetId(sourceRgId.GetChildId("Connections").GetChildId(connector.Name));
			TaskLogger.Trace("Set connector ID to '{0}'", new object[]
			{
				connector.Id
			});
		}
        private DNWithBinary CreateWKGuid(ADContainer container, ADObjectId dn, Guid wkGuid)
        {
            DNWithBinary dnwithBinary = new DNWithBinary(dn.DistinguishedName, wkGuid.ToByteArray());

            container.OtherWellKnownObjects.Add(dnwithBinary);
            this.configurationSession.Save(container);
            TaskLogger.Trace(Strings.InfoCreatedWKGuid(wkGuid.ToString(), dn.DistinguishedName, container.DistinguishedName));
            return(dnwithBinary);
        }
Пример #27
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADUser aduser = (ADUser)base.PrepareDataObject();

            MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            if (ComplianceConfigImpl.JournalArchivingHardeningEnabled)
            {
                MailboxTaskHelper.BlockRemoveOrDisableMailUserIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, false);
            }
            if (!aduser.ExchangeVersion.IsOlderThan(ADUserSchema.ArchiveGuid.VersionAdded))
            {
                if (aduser.ArchiveGuid != Guid.Empty)
                {
                    if (!this.PreventRecordingPreviousDatabase)
                    {
                        aduser.DisabledArchiveGuid     = aduser.ArchiveGuid;
                        aduser.DisabledArchiveDatabase = aduser.ArchiveDatabase;
                    }
                    else
                    {
                        aduser.DisabledArchiveGuid     = Guid.Empty;
                        aduser.DisabledArchiveDatabase = null;
                    }
                }
                aduser.ArchiveGuid             = Guid.Empty;
                aduser.ArchiveName             = null;
                aduser.ArchiveDatabase         = null;
                aduser.ArchiveStatus           = (aduser.ArchiveStatus &= ~ArchiveStatusFlags.Active);
                aduser.AllowArchiveAddressSync = false;
            }
            if ("Archive" == base.ParameterSetName)
            {
                MailboxTaskHelper.ClearExchangeProperties(aduser, DisableMailUserBase <MailUserIdParameter> .MailboxMovePropertiesToReset);
                TaskLogger.Trace("DisableMailbox -Archive skipping PrepareDataObject", new object[0]);
                TaskLogger.LogExit();
                return(aduser);
            }
            int        recipientSoftDeletedStatus = aduser.RecipientSoftDeletedStatus;
            DateTime?  whenSoftDeleted            = aduser.WhenSoftDeleted;
            Guid       disabledArchiveGuid        = aduser.DisabledArchiveGuid;
            ADObjectId disabledArchiveDatabase    = aduser.DisabledArchiveDatabase;

            MailboxTaskHelper.ClearExchangeProperties(aduser, RecipientConstants.DisableMailUserBase_PropertiesToReset);
            aduser.SetExchangeVersion(null);
            aduser.OverrideCorruptedValuesWithDefault();
            aduser.propertyBag.SetField(ADRecipientSchema.RecipientSoftDeletedStatus, recipientSoftDeletedStatus);
            aduser.propertyBag.SetField(ADRecipientSchema.WhenSoftDeleted, whenSoftDeleted);
            if (disabledArchiveGuid != Guid.Empty)
            {
                aduser.propertyBag.SetField(ADUserSchema.DisabledArchiveGuid, disabledArchiveGuid);
                aduser.propertyBag.SetField(ADUserSchema.DisabledArchiveDatabase, disabledArchiveDatabase);
            }
            TaskLogger.LogExit();
            return(aduser);
        }
        private void CreateAndValidateRoleGroups(ADOrganizationalUnit usgContainer, RoleGroupCollection roleGroups)
        {
            foreach (RoleGroupDefinition roleGroup in roleGroups)
            {
                this.CreateRoleGroup(usgContainer, roleGroup);
            }
            WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            string           name             = windowsPrincipal.Identity.Name;

            string[] array = name.Split(new char[]
            {
                '\\'
            }, 2);
            ADRecipient adrecipient = (ADRecipient)this.recipientSession.FindByAccountName <ADRecipient>(array[0], array[1]);

            if (adrecipient != null)
            {
                TaskLogger.Trace("Didn't find user {0})", new object[]
                {
                    name
                });
            }
            ADGroup adgroup = base.ResolveExchangeGroupGuid <ADGroup>(WellKnownGuid.EoaWkGuid);

            if (adgroup == null)
            {
                base.WriteError(new ExOrgAdminSGroupNotFoundException(WellKnownGuid.EoaWkGuid), ErrorCategory.ObjectNotFound, null);
            }
            else if (adrecipient != null)
            {
                base.LogReadObject(adrecipient);
                TaskLogger.Trace("User {0} is being set as member of RoleGroup {1}", new object[]
                {
                    adrecipient.DistinguishedName,
                    adgroup.Name
                });
                InitializeExchangeUniversalGroups.AddMember(adrecipient, this.rootDomainRecipientSession, adgroup, new WriteVerboseDelegate(base.WriteVerbose));
            }
            foreach (RoleGroupDefinition roleGroupDefinition in roleGroups)
            {
                if (roleGroupDefinition.ADGroup == null)
                {
                    roleGroupDefinition.ADGroup = base.ResolveExchangeGroupGuid <ADGroup>(roleGroupDefinition.RoleGroupGuid);
                    if (roleGroupDefinition.ADGroup == null)
                    {
                        base.WriteError(roleGroupDefinition.GuidNotFoundException, ErrorCategory.ObjectNotFound, null);
                    }
                    base.LogReadObject(roleGroupDefinition.ADGroup);
                }
                if (roleGroupDefinition.ADGroup != null && !roleGroupDefinition.ADGroup.ManagedBy.Contains(adgroup.Id))
                {
                    roleGroupDefinition.ADGroup.ManagedBy.Add(adgroup.Id);
                    this.rootDomainRecipientSession.Save(roleGroupDefinition.ADGroup);
                    base.LogWriteObject(roleGroupDefinition.ADGroup);
                }
            }
        }
Пример #29
0
		public static void SetConnectorHomeMta(SendConnector connector, IConfigurationSession configSession)
		{
			Server server = configSession.Read<Server>(connector.SourceTransportServers[0]);
			connector.HomeMTA = server.ResponsibleMTA;
			TaskLogger.Trace("Set connector homeMTA to '{0}'", new object[]
			{
				connector.HomeMTA
			});
		}
        private DNWithBinary CreateWKGuid(ADObjectId dn, Guid wkGuid)
        {
            DNWithBinary dnwithBinary = new DNWithBinary(dn.DistinguishedName, wkGuid.ToByteArray());

            this.configurationUnit.OtherWellKnownObjects.Add(dnwithBinary);
            this.configurationSession.Save(this.configurationUnit);
            base.LogWriteObject(this.configurationUnit);
            TaskLogger.Trace(Strings.InfoCreatedWKGuid(wkGuid.ToString(), dn.DistinguishedName, this.configurationUnit.DistinguishedName));
            return(dnwithBinary);
        }