public static SQLBrokerConfig GetBrokerConfig() { var conf = (System.Collections.Hashtable)System.Configuration.ConfigurationManager.GetSection("SQLBrokerConfig"); if (conf != null) { var c = new SQLBrokerConfig { connectionConfigFromCaller = bool.Parse(conf["connectionConfigFromCaller"]?.ToString()), readOnly = bool.Parse(conf["readOnly"]?.ToString()), readTransactionsOnSQLGet = bool.Parse(conf["readTransactionsOnSQLGet"]?.ToString()), sql = bool.Parse(conf["sql"]?.ToString()), bo = bool.Parse(conf["bo"]?.ToString()), uq = bool.Parse(conf["uq"]?.ToString()), defaultProfile = conf["defaultProfile"]?.ToString(), exposedUQCategories = conf["exposedUQCategories"]?.ToString(), maxConnections = int.Parse(conf["maxConnections"]?.ToString()), }; if (!string.IsNullOrEmpty(c.defaultProfile)) { c.defaultConnection = ConnectionParams.GetConnectionProfile(c.defaultProfile); } return(c); } else { return(new SQLBrokerConfig()); } }
public static ConnectionParams getEffectiveConnectionParams(ConnectionParams fromRequest, ref NoPwdConnectionParams resultConnectionReference) { ConnectionParams cp = brokerConf.defaultConnection; if (!string.IsNullOrEmpty(fromRequest?.CompanyDB)) // Request contains connection params { if (brokerConf.connectionConfigFromCaller) { cp = fromRequest; } else { throw new Exception("SQL Broker is configured to reject connection parameters from clients. Only Profile name is allowed."); } } if (!string.IsNullOrEmpty(fromRequest?.Profile)) // Request can contain connection profile and it overrides everything else { ConnectionParams pcp = ConnectionParams.GetConnectionProfile(fromRequest?.Profile); if (pcp != null) { cp = pcp; //With the following logic, it is possible that the system admin intentionally leaves out user names and passords, //and the the application programmer has to take measures to make a form where the user can enter these users names //and corresponding passords. //The simplest way is just to leave out the SAP B1 password. Of course, don't use manager as the preconfigured //SAP user then. if (string.IsNullOrEmpty(cp.Password) && !string.IsNullOrEmpty(fromRequest.Password)) { cp.Password = fromRequest.Password; } if (string.IsNullOrEmpty(cp.UserName) && !string.IsNullOrEmpty(fromRequest.UserName)) { cp.UserName = fromRequest.UserName; } if (string.IsNullOrEmpty(cp.DbUserName) && !string.IsNullOrEmpty(fromRequest.DbUserName)) { cp.DbUserName = fromRequest.DbUserName; } if (string.IsNullOrEmpty(cp.DbPassword) && !string.IsNullOrEmpty(fromRequest.DbPassword)) { cp.DbPassword = fromRequest.DbPassword; } } } if (cp == null) { throw new Exception("No connection parameters are configured or sent by client"); } else //These are the effective connection parameters for reference to the caller { resultConnectionReference = new NoPwdConnectionParams(cp); } return(cp); }