IIS 7.0 and FTP 7

Discussion in 'ASP .Net' started by Mick Walker, Oct 30, 2007.

  1. Mick Walker

    Mick Walker Guest

    I am using a combination of IIS 7.0 and Microsoft FTP Publishing Service
    7.0 RC0 on my system.

    I am looking for a way to automate the deployment of ftp servers the way
    I also automate the deployment of new websites within IIS.

    I have looked at my applicationHost.config file, and noticed that the
    FTP server makes the following changes to the file:

    <binding protocol="ftp" bindingInformation="*:21:" />
    </bindings>
    <ftpServer>
    <security>
    <ssl
    serverCertHash="AEAFAC5AAE6A0D057B552BF2065957718BCB50BB" ssl128="false"
    controlChannelPolicy="SslAllow" dataChannelPolicy="SslAllow" />
    <authentication>
    <basicAuthentication enabled="true" />
    </authentication>
    </security>
    <messages exitMessage="Goodbye"
    greetingMessage="Welcome" bannerMessage="Hello" maxClientsMessage="Max
    Connections" suppressDefaultBanner="true" />
    <userIsolation mode="None">
    <activeDirectory />
    </userIsolation>
    </ftpServer>

    Under the current <site> node.

    It also adds the following upon adding ftp support to the first site:


    FOr each website that ftp support is added to, it writes the following
    information in the same file:

    <location path="ControlPanel">
    <system.ftpServer>
    <security>
    <authorization>
    <add accessType="Allow" users="mick.walker"
    permissions="Read, Write" />
    </authorization>
    </security>
    </system.ftpServer>
    </location>
    <location path="Default Web Site">
    <system.ftpServer>
    <security>
    <authorization>
    <add accessType="Allow" users="mick.walker"
    permissions="Read, Write" />
    </authorization>
    </security>
    </system.ftpServer>
    </location>


    I am looking for a way to do this manually. I would love to find an API
    to do it for me, but if not I would have to write the raw XML to the
    file myself. I have never used XML before, so does anyone have a few
    buzz words I should read into to figure out what it is I need to do?


    Or if anyone knows a better way, please suggest it. :)

    Regards
    Mick
    P.S:
    (ASP.NET is running with appropriate permissions to modify the file)
     
    Mick Walker, Oct 30, 2007
    #1
    1. Advertisements

  2. Mick Walker

    Ken Schaefer Guest

    Some options to look at:

    Use WMI
    Use appcmd.exe

    Cheers
    Ken
     
    Ken Schaefer, Oct 30, 2007
    #2
    1. Advertisements

  3. Mick Walker

    Mick Walker Guest

    Thanks for your reply Ken, I have actually been looking at
    Microsoft.Web.Administration.

    I wrote a little test program, which would allow me to modify various
    options within the appplicationHost.config file:

    using System;
    using Microsoft.Web.Administration;

    namespace WebATest1 {
    internal class Program {
    private static void Main(string[] args) {
    ServerManager serverManager =
    ServerManager.OpenRemote("194.46.4.8");
    Configuration config =
    serverManager.GetApplicationHostConfiguration();

    // This works Perfectly
    ConfigurationSection section =
    config.GetSection("system.webServer/asp");
    ConfigurationElement element =
    section.GetChildElement("session");

    Console.Write("allowSessionState attribute value: ");

    Console.WriteLine(element.GetAttributeValue("allowSessionState"));
    Console.WriteLine("Set allowSessionState value to true");

    element.SetAttributeValue("allowSessionState", true);

    serverManager.CommitChanges();

    Console.Write("allowSessionState attribute value: ");

    Console.WriteLine(element.GetAttributeValue("allowSessionState"));

    section = null;
    element = null;

    // However this part doesnt
    section = config.GetSection("system.webServer/");
    element = section.GetChildElement("enableKernelCache");

    Console.Write("enableKernelCache enabled value: ");

    Console.WriteLine(element.GetAttributeValue("enableKernelCache"));
    Console.WriteLine("Set enabled value to false ");
    element.SetAttributeValue("enableKernelCache", false);

    serverManager.CommitChanges();
    Console.ReadLine();
    }
    }
    }

    The first part works perfectly, however the second part of the program
    doesn't.

    the applicationHost.config file section in question looks like:
    <system.webServer>

    <asp>
    <cache
    diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled
    Templates" />
    <session allowSessionState="true" />
    </asp>

    <caching enabled="true" enableKernelCache="true">
    </caching>

    <cgi />
    .....
    .....
    ......
    .......
    </system.webServer>

    Also I can not find any information on adding elements using the above
    method.
     
    Mick Walker, Oct 30, 2007
    #3
  4. Mick Walker

    Ken Schaefer Guest

    I am not so familiar with using managed code, but I'll try to repro your
    problem

    When you say "it doesn't work", what do you mean exactly? nothing changes?
    you get an error? etc

    Cheers
    Ken

     
    Ken Schaefer, Oct 31, 2007
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.