public ActionResult UpdateManagerEmailAddress(FormCollection collection) { var model = GetUpdatedModel(); var errors = ModelState .Where(x => x.Value.Errors.Count > 0) .Select(x => new { x.Key, x.Value.Errors[0].ErrorMessage }) .ToArray(); // Test to see if the model has validated correctly if (ModelState.IsValid) { if (!string.IsNullOrEmpty(model.ManagerFirstName) && !string.IsNullOrEmpty(model.ManagerLastName)) { //Call LDAP service to get Line Manager Email Address. Put these in Model.LineManagerEmailAddresses. If only one returned then default this as the selected item DirectoryServiceClient dsc = new DirectoryServiceClient(); try { model.LineManagerEmailAddressList = dsc.GetEmailAddress(model.ManagerFirstName.Trim(), model.ManagerLastName.Trim()).ToList(); dsc.Close(); } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, dsc); model.Message = message; return(View(model)); } sessionManager.EmailDetails = model; } } ModelState.Clear(); return(View(model)); }
public static void Main(string[] args) { _directoryServiceClientRef = new DirectoryServiceClient(); //if (_directoryServiceClientRef.ClientCredentials != null) //{ // _directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.UserName = "******"; // _directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.Password = "******"; // _directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.Domain = "ADIR"; //} // setup timer to poll server _pollTimer = new Timer(); _pollTimer.Elapsed += PollServer; _pollTimer.Interval = PING_INTERVAL_MS; _pollTimer.Enabled = true; _runBroker = true; _connectionObj = new BrokerConnections(); _connectionObj.StartServer(); // setup web server IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); string localIp = string.Empty; foreach (IPAddress ipAddress in host.AddressList) { if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { localIp = ipAddress.ToString(); break; } } var signalrHostPort = int.Parse(ConfigurationManager.AppSettings["signalrHostPort"]); Console.WriteLine("This Broker IP: {0}", localIp); GlobalHost.Configuration.DisconnectTimeout = new TimeSpan(0, 0, 60); GlobalHost.Configuration.ConnectionTimeout = new TimeSpan(0, 0, 20); GlobalHost.Configuration.KeepAlive = new TimeSpan(0, 0, 5); bool webInterfaceRunning = false; IDisposable webAppHost; try { string urlAdminOnly = string.Format("http://+:{0}", signalrHostPort); webAppHost = WebApp.Start<Startup>(urlAdminOnly); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Broker SignalR running on {0}", urlAdminOnly); webInterfaceRunning = true; } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine( "Error occurred running web interface for all IP addresses (You probably need admin rights). Reverting to localhost only"); Console.ResetColor(); } if (!webInterfaceRunning) { string url = string.Format("http://localhost:{0}", signalrHostPort); webAppHost = WebApp.Start<Startup>(url); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Broker SignalR running on {0}", url); } Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Cyan; string navigateUrl = "http://" +(webInterfaceRunning ? localIp : "localhost") +":"+ signalrHostPort; Console.WriteLine("You can navigate to the broker manager by going to {0}", navigateUrl); Console.ResetColor(); // perform initial register Process.Start(navigateUrl); RegisterOrPollServer(); Console.WriteLine("--------------------------------------------------------------"); }
public static string[] GetServers() { var directoryServiceClientRef = new DirectoryServiceClient(); //directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.UserName = "******"; //directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.Password = "******"; //directoryServiceClientRef.ClientCredentials.Windows.ClientCredential.Domain = "ADIR"; return directoryServiceClientRef.GetServers(); }