Re: Adding FTP to WebSite using C#



Try .net dev groups.

--
Regards,
Bernard Cheah
http://www.iis.net/
http://msmvps.com/blogs/bernard/


"Mick Walker" <materialised@xxxxxxxxxxx> wrote in message
news:5om6oaFni5d2U1@xxxxxxxxxxxxxxxxxxxxx
Hi All,

I am attempting to add ftp support to a website I create. To create the
website, I use the following function:

public class WebSites {
public const string FTPSERVICE = "/MSFTPSVC";
public const string IIS = "IIS://";
public const string WEBSERVICE = "/W3SVC";

public static bool AddSite(WebSites NewWebSite) {
string strIISPath = IIS + NewWebSite.ServerName + WEBSERVICE;

string strPhysicalPath = "\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName + "\\httpdocs";
// Try to create the Directory
Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName);


// Create Restricted Directories
Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\httpdocs");
Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\httpdocs\\App_Code");

Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\httpdocs\\App_Data");
Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\httpdocs\\bin");
Directory.CreateDirectory("\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\private");

// Set the Websites Physical Path
NewWebSite.PhysicalPath = "\\\\" + NewWebSite.ServerName +
"\\hosts\\" + NewWebSite.SiteName +
"\\httpdocs";
// Create the New Website
ServerManager iisManager =
ServerManager.OpenRemote(NewWebSite.ServerName);
iisManager.Sites.Add(NewWebSite.SiteName, "http",
NewWebSite.HostHeader, strPhysicalPath);
iisManager.Sites.Add(NewWebSite.SiteName, "ftp",
NewWebSite.HostHeader, strPhysicalPath);
iisManager.CommitChanges();



// Use Active Directory to set the website permissions
DirectoryEntry objIISDirectoryEntry = new
DirectoryEntry(strIISPath + "/" + GetSiteID(strIISPath,
NewWebSite.SiteName));
// Assign property to Website
objIISDirectoryEntry.Properties["EnableDirBrowsing"][0] =
NewWebSite.HasBrowseAccess;
objIISDirectoryEntry.Properties["AccessExecute"][0] =
NewWebSite.HasExecuteAccess;
objIISDirectoryEntry.Properties["AccessRead"][0] =
NewWebSite.HasReadAccess;
objIISDirectoryEntry.Properties["AccessWrite"][0] =
NewWebSite.HasWriteAccess;
objIISDirectoryEntry.Properties["AuthAnonymous"][0] =
NewWebSite.IsAnonymousAccessAllow;
objIISDirectoryEntry.Properties["AuthBasic"][0] =
NewWebSite.IsBasicAuthenticationSet;
objIISDirectoryEntry.Properties["AuthNTLM"][0] =
NewWebSite.IsNTLMAuthenticationSet;

// Save Changes
objIISDirectoryEntry.CommitChanges();

// Close both directory object.
objIISDirectoryEntry.Close();
return true;
}

It uses a Mixture of Active Directory and System.Web.Administration
classes to automate the process.
How can I also create a default website with the same document root as the
site I have just created?
Kind regards
Mick Walker
--
Mick Walker
Software Engineer

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


.



Relevant Pages

  • Re: Network Security Assessment - 2nd edition
    ... Might I suggest as an update to your Windows Chapter, a section on Active Directory and using AD tools such as dsquery, dsget, enumprop, ... These tools can be found in the various Microsoft Support/Resource Kits and ... Audit your website security with Acunetix Web Vulnerability Scanner: ... Cross site scripting and other web attacks before hackers do! ...
    (Pen-Test)
  • Re: Distribution Lists
    ... How the website formats the data is yet to be determined: ... > information from a website into a distribution group in Active Directory ... > Microsoft Online Partner Support ...
    (microsoft.public.exchange.admin)
  • looking for tools/scripts to clean up unused AD accounts
    ... - Active Directory is one of the key repositories for system and user accounts. ... Audit your website security with Acunetix Web Vulnerability Scanner: ... Cross site scripting and other web attacks before hackers do! ...
    (Pen-Test)
  • Re: ASP.NET and Active Directory
    ... > We've now been asked to integrate with active directory so that users on ... > userid (which should match the old website login). ... switch from anonymous to Integrated Windows in the IIS server. ... you will also need to use "Integrate Windows security option" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Documentation and adding users
    ... Then you manage all users in Active Directory. ... What I would like is to be able to print the html ... > help file, or of some ... >>..doc file on MS website that contains this information? ...
    (microsoft.public.sharepoint.windowsservices)

Loading