If we have a config that looks like this...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
</services>
<bindings>
<basicHttpBinding>
<binding name="serviceConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="33554432" messageEncoding="Text" textEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="1048576"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
I would like to change
<security mode="TransportCredentialOnly">
to <security mode="Transport">
<transport clientCredentialType="Windows" />
to <transport clientCredentialType="None" />
So far i have read the xml file and read the security node
WebConfig = @"c:\xml.xml";
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load(WebConfig);
XmlNodeList oldNodes;
oldNodes = myXmlDocument.GetElementsByTagName("security");
But i'm unsure how to change the XML nodes and save it back to the file.
We need to do this as sometimes we have to change configs manually after deployment and there are hundreds of them, so i'm pragmatically recursively going through the files and ending them.