private static List <ServerComponentStates.ItemEntry> GetReconciledStates(string targetServerFqdn, MultiValuedProperty <string> adComponentStates, ServerComponentStateSources sourcesToUse, string component, out List <ServerComponentStates.ItemEntry> localStates, out List <ServerComponentStates.ItemEntry> remoteStates)
        {
            localStates  = null;
            remoteStates = null;
            List <ServerComponentStates.ItemEntry> localStatesTemp = null;
            List <ServerComponentStates.ItemEntry> result          = null;

            if (sourcesToUse.HasFlag(ServerComponentStateSources.Registry))
            {
                Exception ex = ServerComponentStateManager.RunLocalRegistryOperationNoThrow(delegate
                {
                    localStatesTemp = ServerComponentStates.GetLocalStates(targetServerFqdn, component);
                });
                if (ex != null && !sourcesToUse.HasFlag(ServerComponentStateSources.AD))
                {
                    throw new ServerComponentApiException(DirectoryStrings.ServerComponentLocalRegistryError(ex.ToString()), ex);
                }
                localStates = localStatesTemp;
                result      = localStatesTemp;
            }
            if (sourcesToUse.HasFlag(ServerComponentStateSources.AD))
            {
                remoteStates = ServerComponentStates.GetRemoteStates(adComponentStates, component);
                result       = remoteStates;
            }
            if (localStates != null && remoteStates != null)
            {
                result = ServerComponentStates.ReconcileStates(localStates, remoteStates);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static void SyncAdState()
        {
            MultiValuedProperty <string> adStates = null;
            Exception ex = ServerComponentStateManager.RunADOperationNoThrow(delegate
            {
                adStates = ServerComponentStateManager.ReadLocalServerComponentStatesFromAD();
                ServerComponentStateManager.UseAdStates(adStates);
            });

            if (ex != null)
            {
                ServerComponentStateManager.Tracer.TraceError <Exception>(0L, "SyncAdState failed to read from AD: {0}", ex);
                throw new ServerComponentApiException(DirectoryStrings.ServerComponentReadADError(ex.ToString()), ex);
            }
            Exception ex2 = ServerComponentStateManager.RunLocalRegistryOperationNoThrow(delegate
            {
                ServerComponentStates.SyncComponentStates(adStates);
            });

            if (ex2 != null)
            {
                ServerComponentStateManager.Tracer.TraceError <Exception>(0L, "SyncAdState failed in ServerComponentStates.SyncComponentStates: {0}", ex2);
                throw new ServerComponentApiException(DirectoryStrings.ServerComponentLocalRegistryError(ex2.ToString()), ex2);
            }
        }
Exemplo n.º 3
0
        private static void RunLocalRegistryOperation(Action codeToRun)
        {
            Exception ex = ServerComponentStateManager.RunLocalRegistryOperationNoThrow(codeToRun);

            if (ex != null)
            {
                throw new ServerComponentApiException(DirectoryStrings.ServerComponentLocalRegistryError(ex.ToString()), ex);
            }
        }
Exemplo n.º 4
0
        public static void SetOnline(ServerComponentEnum serverComponent)
        {
            Exception ex = ServerComponentStateManager.RunLocalRegistryOperationNoThrow(delegate
            {
                ServerComponentStates.UpdateLocalState(null, ServerComponentRequest.HealthApi.ToString(), serverComponent.ToString(), ServiceState.Active);
            });

            if (ex != null)
            {
                ServerComponentStateManager.Tracer.TraceError <ServerComponentEnum, Exception>(0L, "SetOnline({0}) failed: {1}", serverComponent, ex);
                throw new ServerComponentApiException(DirectoryStrings.ServerComponentLocalRegistryError(ex.ToString()), ex);
            }
        }