private static void WipeSqlServerCredentials(string webRootPath) { var pathToConnectionStringsConfig = webRootPath.PathCombine("App_Config").PathCombine("ConnectionStrings.config"); var connectionStringsDocument = new XmlDocumentEx(); connectionStringsDocument.Load(pathToConnectionStringsConfig); var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument); var connectionStrings = new ConnectionStringCollection(connectionsStringsElement); connectionStrings.AddRange(connectionsStringsElement.Element.ChildNodes.OfType <XmlElement>().Select(element => new ConnectionString(element, connectionsStringsElement.Document))); foreach (var connectionString in connectionStrings) { if (!connectionString.IsSqlConnectionString) { continue; } var builder = new SqlConnectionStringBuilder(connectionString.Value) { DataSource = string.Empty, UserID = string.Empty, Password = string.Empty }; connectionString.Value = builder.ToString(); } connectionStrings.Save(); }
private ConnectionStringCollection GetConnectionStringCollection(XmlElementEx connectionStringsNode) { var connectionStrings = new ConnectionStringCollection(connectionStringsNode); XmlNodeList addNodes = connectionStringsNode.Element.ChildNodes; connectionStrings.AddRange(addNodes.OfType<XmlElement>().Select(element => new ConnectionString(element, connectionStringsNode.Document))); return connectionStrings; }
private ConnectionStringCollection GetConnectionStringCollection(XmlElementEx connectionStringsNode) { var connectionStrings = new ConnectionStringCollection(connectionStringsNode); XmlNodeList addNodes = connectionStringsNode.Element.ChildNodes; connectionStrings.AddRange(addNodes.OfType <XmlElement>().Select(element => new ConnectionString(element, connectionStringsNode.Document))); return(connectionStrings); }
private static void WipeSqlServerCredentials(string webRootPath) { var pathToConnectionStringsConfig = webRootPath.PathCombine("App_Config").PathCombine("ConnectionStrings.config"); var connectionStringsDocument = new XmlDocumentEx(); connectionStringsDocument.Load(pathToConnectionStringsConfig); var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument); var connectionStrings = new ConnectionStringCollection(connectionsStringsElement); connectionStrings.AddRange(connectionsStringsElement.Element.ChildNodes.OfType<XmlElement>().Select(element => new ConnectionString(element, connectionsStringsElement.Document))); foreach (var connectionString in connectionStrings) { if (!connectionString.IsSqlConnectionString) { continue; } var builder = new SqlConnectionStringBuilder(connectionString.Value) { DataSource = string.Empty, UserID = string.Empty, Password = string.Empty }; connectionString.Value = builder.ToString(); } connectionStrings.Save(); }