« Previous Next »

Thread: question regarding iis7 ftp extensibility

Last post 09-01-2008 4:26 PM by SLORider. 9 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (10 items)

Sort Posts:

  • 04-07-2008, 6:07 PM

    • ryancammer
    • Not Ranked
    • Joined on 11-09-2007, 10:20 PM
    • Los Angeles, CA
    • Posts 8

    question regarding iis7 ftp extensibility

    i have a project that i've been given to:

    1) authenticate our users against the database, and then

    2) display a set of virtual directories and files based upon content that users have uploaded.

    the way that we were hoping to do this is to extend ftp. i just started researching, and it looks like authentication is possible, but what about the virtual files? am i able to modify a ftp request like i can a http request? if so, what's the best way to get started?

     thanks in advance for any insight!

    ryan
     

  • 04-11-2008, 2:46 PM In reply to

    • ryancammer
    • Not Ranked
    • Joined on 11-09-2007, 10:20 PM
    • Los Angeles, CA
    • Posts 8

    Re: question regarding iis7 ftp extensibility

    okay, the virtual directories we figured out. my boss found winfuse, which allows us to create our own file system. however, now the problem is trying to figure out how to implement custom authentication.

     i added the following to applicationHost.config (obviously i changed the namespace, assembly name, and key):

         <system.ftpServer>
            <providerDefinitions>
                <add name="IisManagerAuth" type="Microsoft.Web.FtpServer.Security.IisManagerAuthenticationProvider,Microsoft.Web.FtpServer,version=7.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
                <add name="AspNetAuth" type="Microsoft.Web.FtpServer.Security.AspNetFtpMembershipProvider,Microsoft.Web.FtpServer,version=7.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
                <add name="MyAuthProvider" type="Data.MyAuthProvider,Data,version=2.0.3.0, Culture=neutral,PublicKeyToken=2335d14bdda8ae70" />
            </providerDefinitions>
        </system.ftpServer>

    then wrote the following code:

    namespace Data
    {
        public class MyAuthProvider : IFtpAuthenticationProvider, IFtpProvider
        {
            bool IFtpAuthenticationProvider.AuthenticateUser( string sessionId, string siteName, string userName, string userPassword,
                                            out string canonicalUserName )
            {
                canonicalUserName = userName;

                return true;
            }

            public void ConfigurationUpdated()
            {
               
            }
        }
    }

     upon compilation, i drop the Data assembly into the gac as a post-build.
     

    i then set my FTP Authentication to use the provider, and end up with the following error:

     C:\Users\Administrator>ftp localhost
    Connected to ryanbox.
    220 Microsoft FTP Service
    User (ryanbox:(none)): ryan
    331 Password required for ryan.
    Password: ****
    530-User cannot log in.
     Win32 error:   No such interface supported
     Error details: An error occured during the authentication process.
    530 End
    Login failed.
    ftp>

    i don't see the Win32 error in the event logs, nor the ftp logs. the reason i chose to implement the IFtpAuthenticationProvider and IFtpProvider interfaces is because that's what AspNetFtpMembershipProvider and IisManagerAuthenticationProvider implement. i'm assuming both of those work, but haven't tested them yet.

    has anybody actually implemented a custom authentication provider for FTP 7? anybody know how i can get the actual error?

    a couple more details. since the Microsoft.Web.FtpServer assembly is in the gac, but visual studio 2008 doesn't display all of the gac assemblies in the add references dialog box, I copied the assembly to a different directory, and added a reference to it that way.

    also, i can't figure out how to attach to the ftp process from visual studio. i'm deving on windows 2008, since ftp 7 rtm doesn't actually install on vista. i don't see w3wp or any other process that looks like something i can attach to. i have all the iis 6 metabase functionality installed.

    finally, a gripe: whoever's on the ftp 7 team, next time you release a product and advertise a feature (extensible authentication), you think you can release some freakin' examples, or maybe some instructions? it doesn't do much good to say that authentication is extensible, but then leave it up to the developer to fiddle with interfaces and configs and try and find the winning combination. thanks.

    ryan cammer


     

  • 04-14-2008, 6:53 PM In reply to

    • robmcm
    • Top 50 Contributor
    • Joined on 05-27-2006, 1:05 AM
    • Redmond, WA
    • Posts 125

    Re: question regarding iis7 ftp extensibility

    I apologize for the delayed response - I was out of the office on Friday. 

    Unfortunately extensibility for the new FTP service is not public; in fact the APIs are incomplete as this is a feature that is targeted for the next release of the FTP service. (Note: We had intended to release extensibility for this version, but we simply ran out of time to fully implement it so we cut it from the RTW feature set, which is why there is not mention of extensibility in the RTW documentation or any examples.)

    That being said, there is a way that you may be able to expose this same sort of functionality. While the FTP service may not be extensible, the "IIS Managers" feature is, so you can write your own extensibility provider for that feature to look up users in a SQL database, then use the IIS managers authentication module in the new FTP service to authenticate users together with the user isolation feature in FTP to perform the home directory mapping.

    I've tested that configuration on several servers, so I can help you get that up-and-running if you have any questions.

    Robert McMurray (MSFT, IIS)
  • 04-15-2008, 12:02 PM In reply to

    • mcmill46
    • Not Ranked
    • Joined on 10-19-2006, 3:54 AM
    • Chicago, IL
    • Posts 2

    Re: question regarding iis7 ftp extensibility

    Ryan,

    I was having the same problem you describe and found that it was a misconfiguration of my Application Pool.  My site was pointed to a stale app pool record.  I added a new pool using framework 2.0 and Integrated pipeline, repointed my site to the new pool and magically it worked.  From the sounds of things, I've followed pretty much the same procedure as you did (except I'm deving on Vista SP1).  Also, I'm not using User Isolation.

    I still get the Win32 error anytime the server returns a 500-series status code.  I haven't tried to look into this yet and it may be acceptable for the purposes of my application.

    That said, I've read Rob's post and I'm not sure what to make of this... Rob, your thoughts?

    Ryan, here is a sample of my code.  Just as you did, I built a strongly named assembly, imported it into the GAC.  I took the assembly info from the GAC and added it into the applicationHost.config.

    References:
    Microsoft.Web.FtpServer (file reference - copied from GAC)
    System
    System.Web

    using System;

    using Microsoft.Web.FtpServer;

    namespace AppNamespace

    {

    public class ClassName : BaseProvider, IFtpAuthenticationProvider

    {

    bool IFtpAuthenticationProvider.AuthenticateUser(string sessionId, string siteName, string userName, string userPassword, out string canonicalUserName)

    {

    canonicalUserName = userName;

    bool retVal = false;if (userName == "test" && userPassword == "testing")

    {

    retVal =
    true;

    }

    return retVal;

    }

    }

    }

     

    Let me know if this works for you, too.

    Aaron

  • 04-15-2008, 12:23 PM In reply to

    • ryancammer
    • Not Ranked
    • Joined on 11-09-2007, 10:20 PM
    • Los Angeles, CA
    • Posts 8

    Re: question regarding iis7 ftp extensibility

    rob, this shouldn't work on ftp 7, right?

    aaron, ftp on vista isn't actually the rtm version of ftp, which is why i've been deving against 2008. however, if rob says it should still work, then i'll go do battle again.

    however, if i can get a solution working with the iis mgr feature, then i'll make a codeproject post and reference it in the forum. it's only fair, right?

  • 04-15-2008, 2:12 PM In reply to

    • mcmill46
    • Not Ranked
    • Joined on 10-19-2006, 3:54 AM
    • Chicago, IL
    • Posts 2

    Re: question regarding iis7 ftp extensibility

    Ryan,

    I was under the impression it wouldn't work either, based on Rob's input, but it seems to... dunno!  Having the same problem as you, I'd been keeping an eye on this thread, but got it working last night.

    You are correct, that FTP7 will not install on Vista, but it will on Vista SP1 (which has the exact same build number as Server 2008).  I've had the FTP7 RTW working since early March, when the service pack was released to MSDN subscribers.

    If you do get anything working, put up some documentation - I'm sure we're not the only people with this problem! :)

    Rob - any input on the matter would be helpful and appreciated!  I'm going to keep plugging away since it seems like it will work for my purposes, but I'm curious to hear your thoughts on the matter.

    Aaron

  • 04-15-2008, 3:29 PM In reply to

    • ryancammer
    • Not Ranked
    • Joined on 11-09-2007, 10:20 PM
    • Los Angeles, CA
    • Posts 8

    Re: question regarding iis7 ftp extensibility

    you're KIDDING me. i've been deving on 2008 on a laptop for the past week.

    however, i'd like to get a working example on 2008 first before installing ftp 7 rtw on my vista laptop, and deving against that. let me tell you, lugging around 2 laptops is great exercise. next time i buy laptops, however, i'm getting macbook airs.

    i've gotta finish up my virtual filesystem, but i'll start banging on authentication sometime later today. aaron, feel free to email me if you're interested in trying to come up with a working solution. my email's ryancammer at yahoo dot com.

    ryan 

  • 07-06-2008, 11:49 PM In reply to

    • ryancammer
    • Not Ranked
    • Joined on 11-09-2007, 10:20 PM
    • Los Angeles, CA
    • Posts 8

    Re: question regarding iis7 ftp extensibility

    okay, here's how to set up custom authentication. piece of cake! (thanks aaron)

  • 07-29-2008, 6:39 AM In reply to

    Re: question regarding iis7 ftp extensibility

    Ryan,

    If you have a moment, http://forums.iis.net/t/1150707.aspx 

    Any information on setting the home directory would be great.

    And thank you for your custom authentication.

  • 09-01-2008, 4:26 PM In reply to

    • SLORider
    • Top 500 Contributor
    • Joined on 11-25-2006, 10:11 PM
    • San Luis Obispo, CA USA
    • Posts 16

    Re: question regarding iis7 ftp extensibility

    I'm hoping to extend FTP logging using the IFtpLogProvider interface in Microsoft.Web.FtpServer. I created a test class like so:

      public class LogProviderTest : IFtpLogProvider
      {
        void IFtpLogProvider.Log(FtpLogEntry logEntry)
        {
          // this should "prove" it works, right? The FTP service would stop or log to the event log?
          throw new NotImplementedException();
        }
      }

    I installed this into the GAC, but need a hint how to tell FTP Server about my class????

    Modify applicationHost.config?

    Any ideas?

     

    Visit SLORider.com!
Page 1 of 1 (10 items)
Microsoft Communities