protected override void OnStart(string[] args) { _timer.Start(); var task = _relay.StartAsync(); task.Wait(); }
public static async Task <ValidationResponse> ValidateAsync(LoginModel login, Cache cache) { try { var client = new SigRClient(Settings.AdminSiteUrl, Settings.STSApiKey, "SiteHub"); var domainName = login.UserName.Split('@')[1].ToLower(); var site = await SiteCache.GetSiteByDomain(cache, domainName); var cred = new STSCredential { Domain = site.OnPremDomainName, UserName = login.UserName, Password = login.Password, RemoteSiteId = site.Id }; await client.StartAsync(); ValidationResponse res = await client.ProcessSTSValidationRequest(cred); return(res); } catch (Exception ex) { Utils.AddLogEntry("Error during user validation", System.Diagnostics.EventLogEntryType.Error, 0, ex); return(new ValidationResponse { IsValid = false }); } }
public static async Task <RelayResponse> ResetPassword(PasswordReset credential, StagedUser stagedUser) { try { var client = new SigRClient(Settings.AdminSiteUrl, Settings.STSApiKey, "SiteHub"); var data = JsonConvert.SerializeObject(credential); var msg = new RelayMessage { ApiKey = Settings.AdminApiKey, Data = data, DestSiteId = stagedUser.SiteId, Identifier = stagedUser.Id, Operation = SiteOperation.ResetPW }; await client.StartAsync(); RelayResponse res = await client.ProcessRelayMessage(msg); return(res); } catch (Exception ex) { Utils.AddLogEntry("Error setting user status", EventLogEntryType.Error, 0, ex); return(new RelayResponse { Success = false, ErrorMessage = ex.Message }); } }
public static async Task <RelayResponse> GetUserStatus(StagedUser user) { try { var client = new SigRClient(Settings.AdminSiteUrl, Settings.STSApiKey, "SiteHub"); var msg = new RelayMessage { ApiKey = Settings.AdminApiKey, Data = user.LocalGuid, DestSiteId = user.SiteId, Identifier = user.Upn, Operation = SiteOperation.GetUserStatus }; await client.StartAsync(); RelayResponse res = await client.ProcessRelayMessage(msg); return(res); } catch (Exception ex) { Utils.AddLogEntry("Error getting user status", EventLogEntryType.Error, 0, ex); return(new RelayResponse { Success = false, ErrorMessage = ex.Message }); } }
private static void RunConsole(RemoteSite siteConfig, string[] args) { if (ParseCommandLine(args)) { relay.StartAsync().Wait(); timer.Start(); _isRunning = true; while (_isRunning) { Console.TreatControlCAsInput = true; Console.WriteLine("Press \"p\" to send a Ping test, Ctrl-C to end."); var key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.P: WriteConsoleStatus("Sending ping..."); _pingTest = new PingEvent(DateTime.Now); relay.Send(new RelayMessage { Operation = SiteOperation.Ping, ApiKey = OrgApiCalls.ApiKey, DestSiteId = siteConfig.Id }); break; case ConsoleKey.Escape: case ConsoleKey.C: if (key.Key == ConsoleKey.C && key.Modifiers != ConsoleModifiers.Control) { break; } Console.WriteLine("Stop the relay agent? (Y or N)"); if (Console.ReadKey().Key == ConsoleKey.Y) { WriteConsoleStatus("Received shutdown command."); _isRunning = false; } break; } } relay.Stop(); } }