Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

IIS 7.0 and FTP 7

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mick Walker - 30 Oct 2007 11:33 GMT
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)
Signature

Mick Walker
Software Engineer

http://www.mick-walker.co.uk

Ken Schaefer - 30 Oct 2007 14:24 GMT
Some options to look at:

Use WMI
Use appcmd.exe

Cheers
Ken

>I am using a combination of IIS 7.0 and Microsoft FTP Publishing Service
>7.0 RC0 on my system.
[quoted text clipped - 63 lines]
> P.S:
> (ASP.NET is running with appropriate permissions to modify the file)
Mick Walker - 30 Oct 2007 14:40 GMT
> Some options to look at:
>
[quoted text clipped - 4 lines]
> Ken
>  
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.

Signature

Mick Walker
Software Engineer

http://www.mick-walker.co.uk

Ken Schaefer - 31 Oct 2007 13:52 GMT
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

>> Some options to look at:
>>
[quoted text clipped - 84 lines]
> Also I can not find any information on adding elements using the above
> method.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.