Initial project's source code check-in.
This commit is contained in:
commit
b03b0b373f
4573 changed files with 981205 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Authorization
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class AuthorizationGlobals
|
||||
{
|
||||
public const int AccessType = 0;
|
||||
public const string AuthorizationRuleAlreadyExistsError = "AuthorizationRuleAlreadyExistsError";
|
||||
public const int AuthorizationRuleCollection = 0;
|
||||
public const string AuthorizationRuleDoesNotExistError = "AuthorizationRuleDoesNotExistError";
|
||||
public const string AuthorizationSectionName = "system.ftpServer/security/authorization";
|
||||
public const string ConfigurationError = "ConfigurationError";
|
||||
public const int Permissions = 3;
|
||||
public const int ReadOnly = 1;
|
||||
public const int Roles = 1;
|
||||
public const int Users = 2;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Authorization
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using System;
|
||||
|
||||
internal class AuthorizationRule : ConfigurationElement
|
||||
{
|
||||
private static readonly string AccessTypeAttribute = "accessType";
|
||||
private static readonly string PermissionsAttribute = "permissions";
|
||||
private static readonly string RolesAttribute = "roles";
|
||||
private static readonly string UsersAttribute = "users";
|
||||
|
||||
public AuthorizationRuleAccessType AccessType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (AuthorizationRuleAccessType) base[AccessTypeAttribute];
|
||||
}
|
||||
set
|
||||
{
|
||||
base[AccessTypeAttribute] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public PermissionsFlags Permissions
|
||||
{
|
||||
get
|
||||
{
|
||||
return (PermissionsFlags) base[PermissionsAttribute];
|
||||
}
|
||||
set
|
||||
{
|
||||
base[PermissionsAttribute] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Roles
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base[RolesAttribute];
|
||||
}
|
||||
set
|
||||
{
|
||||
base[RolesAttribute] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Users
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base[UsersAttribute];
|
||||
}
|
||||
set
|
||||
{
|
||||
base[UsersAttribute] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Authorization
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum AuthorizationRuleAccessType
|
||||
{
|
||||
Allow,
|
||||
Deny
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Authorization
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
internal class AuthorizationRuleCollection : ConfigurationElementCollectionBase<AuthorizationRule>
|
||||
{
|
||||
public AuthorizationRule Add(AuthorizationRuleAccessType accessType, string users, string roles, PermissionsFlags permissions)
|
||||
{
|
||||
AuthorizationRule element = base.CreateElement();
|
||||
element.AccessType = accessType;
|
||||
if (!string.IsNullOrEmpty(users))
|
||||
{
|
||||
element.Users = users;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(roles))
|
||||
{
|
||||
element.Roles = roles;
|
||||
}
|
||||
element.Permissions = permissions;
|
||||
return base.Add(element);
|
||||
}
|
||||
|
||||
protected override AuthorizationRule CreateNewElement(string elementTagName)
|
||||
{
|
||||
return new AuthorizationRule();
|
||||
}
|
||||
|
||||
public AuthorizationRule this[string users, string roles, PermissionsFlags permissions]
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < base.Count; i++)
|
||||
{
|
||||
AuthorizationRule rule = base[i];
|
||||
if ((string.Equals(rule.Users, users, StringComparison.OrdinalIgnoreCase) && string.Equals(rule.Roles, roles, StringComparison.OrdinalIgnoreCase)) && (rule.Permissions == permissions))
|
||||
{
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Authorization
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
|
||||
internal sealed class AuthorizationSection : ConfigurationSection
|
||||
{
|
||||
private AuthorizationRuleCollection _rules;
|
||||
|
||||
public AuthorizationRuleCollection Rules
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._rules == null)
|
||||
{
|
||||
this._rules = (AuthorizationRuleCollection) base.GetCollection(typeof(AuthorizationRuleCollection));
|
||||
}
|
||||
return this._rules;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class ActiveDirectoryElement : ConfigurationElement
|
||||
{
|
||||
public TimeSpan AdCacheRefresh
|
||||
{
|
||||
get
|
||||
{
|
||||
return (TimeSpan) base["adCacheRefresh"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["adCacheRefresh"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string AdPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["adPassword"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["adPassword"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string AdUserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["adUserName"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["adUserName"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class AnonymousAuthenticationElement : ConfigurationElement
|
||||
{
|
||||
public string DefaultLogonDomain
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["defaultLogonDomain"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["defaultLogonDomain"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationLogonMethod LogonMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
return (AuthenticationLogonMethod) base["logonMethod"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["logonMethod"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["password"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["password"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["userName"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["userName"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
|
||||
internal class AuthenticationElement : ConfigurationElement
|
||||
{
|
||||
private AnonymousAuthenticationElement _anonymousAuthentication;
|
||||
private BasicAuthenticationElement _basicAuthentication;
|
||||
private CustomAuthenticationElement _customAuthentication;
|
||||
|
||||
public AnonymousAuthenticationElement AnonymousAuthentication
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._anonymousAuthentication == null)
|
||||
{
|
||||
this._anonymousAuthentication = (AnonymousAuthenticationElement) base.GetChildElement("anonymousAuthentication", typeof(AnonymousAuthenticationElement));
|
||||
}
|
||||
return this._anonymousAuthentication;
|
||||
}
|
||||
}
|
||||
|
||||
public BasicAuthenticationElement BasicAuthentication
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._basicAuthentication == null)
|
||||
{
|
||||
this._basicAuthentication = (BasicAuthenticationElement) base.GetChildElement("basicAuthentication", typeof(BasicAuthenticationElement));
|
||||
}
|
||||
return this._basicAuthentication;
|
||||
}
|
||||
}
|
||||
|
||||
public CustomAuthenticationElement CustomAuthentication
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._customAuthentication == null)
|
||||
{
|
||||
this._customAuthentication = (CustomAuthenticationElement) base.GetChildElement("customAuthentication", typeof(CustomAuthenticationElement));
|
||||
}
|
||||
return this._customAuthentication;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class BasicAuthenticationElement : ConfigurationElement
|
||||
{
|
||||
public bool AllowGuest
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowGuest"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowGuest"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DefaultLogonDomain
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["defaultLogonDomain"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["defaultLogonDomain"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationLogonMethod LogonMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
return (AuthenticationLogonMethod) base["logonMethod"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["logonMethod"] = (int) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class ConnectionsElement : ConfigurationElement
|
||||
{
|
||||
public int ControlChannelTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["controlChannelTimeout"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["controlChannelTimeout"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int DataChannelTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["dataChannelTimeout"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["dataChannelTimeout"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DisableSocketPooling
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["disableSocketPooling"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["disableSocketPooling"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long MaxConnections
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["maxConnections"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["maxConnections"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int MinBytesPerSecond
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["minBytesPerSecond"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["minBytesPerSecond"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ResetOnMaxConnections
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["resetOnMaxConnections"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["resetOnMaxConnections"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ServerListenBacklog
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["serverListenBacklog"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["serverListenBacklog"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int UnauthenticatedTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["unauthenticatedTimeout"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["unauthenticatedTimeout"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum ControlChannelPolicy
|
||||
{
|
||||
SslAllow,
|
||||
SslRequire,
|
||||
SslRequireCredentialsOnly
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
|
||||
internal class CustomAuthenticationElement : ConfigurationElement
|
||||
{
|
||||
private ProviderCollection _providers;
|
||||
|
||||
public ProviderCollection Providers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._providers == null)
|
||||
{
|
||||
this._providers = (ProviderCollection) base.GetCollection("providers", typeof(ProviderCollection));
|
||||
}
|
||||
return this._providers;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class CustomAuthenticationProvider : ConfigurationElement
|
||||
{
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["name"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["name"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
internal class CustomAuthenticationProviderCollection : ConfigurationElementCollectionBase<CustomAuthenticationProvider>
|
||||
{
|
||||
public CustomAuthenticationProvider Add(string name, bool enabled)
|
||||
{
|
||||
CustomAuthenticationProvider element = base.CreateElement();
|
||||
element.Name = name;
|
||||
element.Enabled = enabled;
|
||||
return base.Add(element);
|
||||
}
|
||||
|
||||
protected override CustomAuthenticationProvider CreateNewElement(string elementTagName)
|
||||
{
|
||||
return new CustomAuthenticationProvider();
|
||||
}
|
||||
|
||||
public new CustomAuthenticationProvider this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < base.Count; i++)
|
||||
{
|
||||
CustomAuthenticationProvider provider = base[i];
|
||||
if (string.Equals(provider.Name, name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum DataChannelPolicy
|
||||
{
|
||||
SslAllow,
|
||||
SslRequire,
|
||||
SslDeny
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class DataChannelSecurityElement : ConfigurationElement
|
||||
{
|
||||
public bool MatchClientAddressForPasv
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["matchClientAddressForPasv"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["matchClientAddressForPasv"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MatchClientAddressForPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["matchClientAddressForPort"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["matchClientAddressForPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class DirectoryBrowseElement : ConfigurationElement
|
||||
{
|
||||
public ShowFlags ShowFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ShowFlags) base["showFlags"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["showFlags"] = (int) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class FileHandlingElement : ConfigurationElement
|
||||
{
|
||||
public bool AllowReadUploadsInProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowReadUploadsInProgress"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowReadUploadsInProgress"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowReplaceOnRename
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowReplaceOnRename"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowReplaceOnRename"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool KeepPartialUploads
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["keepPartialUploads"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["keepPartialUploads"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class FirewallElement : ConfigurationElement
|
||||
{
|
||||
public string ExternalIpAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["externalIpAddress"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["externalIpAddress"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int HighDataChannelPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["highDataChannelPort"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["highDataChannelPort"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int LowDataChannelPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int) base["lowDataChannelPort"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["lowDataChannelPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum FtpLogExtFileFlags
|
||||
{
|
||||
BytesRecv = 0x2000,
|
||||
BytesSent = 0x1000,
|
||||
ClientIP = 4,
|
||||
ClientPort = 0x2000000,
|
||||
ComputerName = 0x20,
|
||||
Date = 1,
|
||||
FtpStatus = 0x400,
|
||||
FtpSubStatus = 0x200000,
|
||||
FullPath = 0x800000,
|
||||
Host = 0x100000,
|
||||
Info = 0x1000000,
|
||||
Method = 0x80,
|
||||
ServerIP = 0x40,
|
||||
ServerPort = 0x8000,
|
||||
Session = 0x400000,
|
||||
SiteName = 0x10,
|
||||
Time = 2,
|
||||
TimeTaken = 0x4000,
|
||||
UriStem = 0x100,
|
||||
UserName = 8,
|
||||
Win32Status = 0x800
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class FtpProtocolElement : ConfigurationElement
|
||||
{
|
||||
public bool AllowUTF8FileNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowUTF8FileNames"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowUTF8FileNames"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
internal class FtpSite : ConfigurationElement
|
||||
{
|
||||
private ConnectionsElement _connections;
|
||||
private DataChannelSecurityElement _dataChannelSecurity;
|
||||
private DirectoryBrowseElement _directoryBrowse;
|
||||
private FileHandlingElement _fileHandling;
|
||||
private FirewallElement _firewall;
|
||||
private ConfigurationMethod _flushLogMethod;
|
||||
private LogFileElement _logFile;
|
||||
private MessagesElement _messages;
|
||||
private SecurityElement _security;
|
||||
private SessionCollection _sessions;
|
||||
private ConfigurationMethod _startMethod;
|
||||
private ConfigurationMethod _stopMethod;
|
||||
private UserIsolationElement _userIsolation;
|
||||
public const int E_NOT_FOUND = -2147023728;
|
||||
public const int E_OBJECT_NOT_EXIST = -2147020584;
|
||||
private const uint ERROR_ALREADY_EXISTS = 2147942583;
|
||||
private string siteServiceId;
|
||||
|
||||
public string SiteServiceId
|
||||
{
|
||||
get { return siteServiceId; }
|
||||
set { siteServiceId = value; }
|
||||
}
|
||||
|
||||
public void FlushLog()
|
||||
{
|
||||
if (this._flushLogMethod == null)
|
||||
{
|
||||
this._flushLogMethod = base.Methods["FlushLog"];
|
||||
}
|
||||
this._flushLogMethod.CreateInstance().Execute();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (this._startMethod == null)
|
||||
{
|
||||
this._startMethod = base.Methods["Start"];
|
||||
}
|
||||
this._startMethod.CreateInstance().Execute();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (this._stopMethod == null)
|
||||
{
|
||||
this._stopMethod = base.Methods["Stop"];
|
||||
}
|
||||
this._stopMethod.CreateInstance().Execute();
|
||||
}
|
||||
|
||||
public bool AllowUTF8
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowUTF8"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowUTF8"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionsElement Connections
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._connections == null)
|
||||
{
|
||||
this._connections = (ConnectionsElement) base.GetChildElement("connections", typeof(ConnectionsElement));
|
||||
}
|
||||
return this._connections;
|
||||
}
|
||||
}
|
||||
|
||||
public DataChannelSecurityElement DataChannelSecurity
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._dataChannelSecurity == null)
|
||||
{
|
||||
this._dataChannelSecurity = (DataChannelSecurityElement) base.GetChildElement("dataChannelSecurity", typeof(DataChannelSecurityElement));
|
||||
}
|
||||
return this._dataChannelSecurity;
|
||||
}
|
||||
}
|
||||
|
||||
public DirectoryBrowseElement DirectoryBrowse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._directoryBrowse == null)
|
||||
{
|
||||
this._directoryBrowse = (DirectoryBrowseElement) base.GetChildElement("directoryBrowse", typeof(DirectoryBrowseElement));
|
||||
}
|
||||
return this._directoryBrowse;
|
||||
}
|
||||
}
|
||||
|
||||
public FileHandlingElement FileHandling
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._fileHandling == null)
|
||||
{
|
||||
this._fileHandling = (FileHandlingElement) base.GetChildElement("fileHandling", typeof(FileHandlingElement));
|
||||
}
|
||||
return this._fileHandling;
|
||||
}
|
||||
}
|
||||
|
||||
public FirewallElement FirewallSupport
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._firewall == null)
|
||||
{
|
||||
this._firewall = (FirewallElement)base.GetChildElement("firewallSupport", typeof(FirewallElement));
|
||||
}
|
||||
return this._firewall;
|
||||
}
|
||||
}
|
||||
|
||||
public uint LastStartupStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint) base["lastStartupStatus"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["lastStartupStatus"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LogFileElement LogFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._logFile == null)
|
||||
{
|
||||
this._logFile = (LogFileElement)base.GetChildElement("logFile", typeof(LogFileElement));
|
||||
}
|
||||
return this._logFile;
|
||||
}
|
||||
}
|
||||
|
||||
public MessagesElement Messages
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._messages == null)
|
||||
{
|
||||
this._messages = (MessagesElement) base.GetChildElement("messages", typeof(MessagesElement));
|
||||
}
|
||||
return this._messages;
|
||||
}
|
||||
}
|
||||
|
||||
public SecurityElement Security
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._security == null)
|
||||
{
|
||||
this._security = (SecurityElement) base.GetChildElement("security", typeof(SecurityElement));
|
||||
}
|
||||
return this._security;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ServerAutoStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["serverAutoStart"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["serverAutoStart"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SessionCollection Sessions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._sessions == null)
|
||||
{
|
||||
this._sessions = (SessionCollection) base.GetCollection("sessions", typeof(SessionCollection));
|
||||
}
|
||||
return this._sessions;
|
||||
}
|
||||
}
|
||||
|
||||
public SiteState State
|
||||
{
|
||||
get
|
||||
{
|
||||
SiteState unknown = SiteState.Unknown;
|
||||
int num = 0;
|
||||
bool flag = false;
|
||||
while (!flag && (++num < 10))
|
||||
{
|
||||
try
|
||||
{
|
||||
unknown = (SiteState)base["state"];
|
||||
flag = true;
|
||||
continue;
|
||||
}
|
||||
catch (COMException exception)
|
||||
{
|
||||
if (exception.ErrorCode != -2147020584)
|
||||
{
|
||||
return unknown;
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return unknown;
|
||||
}
|
||||
set
|
||||
{
|
||||
base["state"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public UserIsolationElement UserIsolation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._userIsolation == null)
|
||||
{
|
||||
this._userIsolation = (UserIsolationElement) base.GetChildElement("userIsolation", typeof(UserIsolationElement));
|
||||
}
|
||||
return this._userIsolation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class LogFileElement : ConfigurationElement
|
||||
{
|
||||
public string CustomLogPluginClsid
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["customLogPluginClsid"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["customLogPluginClsid"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Directory
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["directory"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["directory"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalTimeRollover
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["localTimeRollover"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["localTimeRollover"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public FtpLogExtFileFlags LogExtFileFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return (FtpLogExtFileFlags) base["logExtFileFlags"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["logExtFileFlags"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public LoggingRolloverPeriod Period
|
||||
{
|
||||
get
|
||||
{
|
||||
return (LoggingRolloverPeriod) base["period"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["period"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public long TruncateSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["truncateSize"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["truncateSize"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class LoggingElement : ConfigurationElement
|
||||
{
|
||||
private LogFileElement _logFile;
|
||||
|
||||
public bool CentralLogFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["centralLogFile"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["centralLogFile"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LogFileElement LogFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._logFile == null)
|
||||
{
|
||||
this._logFile = (LogFileElement) base.GetChildElement("logFile", typeof(LogFileElement));
|
||||
}
|
||||
return this._logFile;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LogInUTF8
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["logInUTF8"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["logInUTF8"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SelectiveLogging SelectiveLogging
|
||||
{
|
||||
get
|
||||
{
|
||||
return (SelectiveLogging) base["selectiveLogging"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["selectiveLogging"] = (int) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class MessagesElement : ConfigurationElement
|
||||
{
|
||||
public bool AllowLocalDetailedErrors
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["allowLocalDetailedErrors"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["allowLocalDetailedErrors"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string BannerMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["bannerMessage"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["bannerMessage"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ExitMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["exitMessage"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["exitMessage"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ExpandVariables
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["expandVariables"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["expandVariables"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string GreetingMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["greetingMessage"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["greetingMessage"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string MaxClientsMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["maxClientsMessage"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["maxClientsMessage"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SuppressDefaultBanner
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["suppressDefaultBanner"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["suppressDefaultBanner"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum Mode
|
||||
{
|
||||
StartInUsersDirectory,
|
||||
IsolateRootDirectoryOnly,
|
||||
ActiveDirectory,
|
||||
IsolateAllDirectories,
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum PermissionsFlags
|
||||
{
|
||||
Read = 1,
|
||||
Write = 2
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
internal class ProviderCollection : ConfigurationElementCollectionBase<ProviderElement>
|
||||
{
|
||||
public ProviderElement Add(string name, bool enabled)
|
||||
{
|
||||
ProviderElement element = base.CreateElement();
|
||||
element.Name = name;
|
||||
element.Enabled = enabled;
|
||||
return base.Add(element);
|
||||
}
|
||||
|
||||
protected override ProviderElement CreateNewElement(string elementTagName)
|
||||
{
|
||||
return new ProviderElement();
|
||||
}
|
||||
|
||||
public new ProviderElement this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < base.Count; i++)
|
||||
{
|
||||
ProviderElement element = base[i];
|
||||
if (string.Equals(element.Name, name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class ProviderElement : ConfigurationElement
|
||||
{
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["name"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["name"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
|
||||
internal class SecurityElement : ConfigurationElement
|
||||
{
|
||||
private AuthenticationElement _authentication;
|
||||
private SslElement _ssl;
|
||||
private SslClientCertificatesElement _sslClientCertificates;
|
||||
|
||||
public AuthenticationElement Authentication
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._authentication == null)
|
||||
{
|
||||
this._authentication = (AuthenticationElement) base.GetChildElement("authentication", typeof(AuthenticationElement));
|
||||
}
|
||||
return this._authentication;
|
||||
}
|
||||
}
|
||||
|
||||
public SslElement Ssl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ssl == null)
|
||||
{
|
||||
this._ssl = (SslElement) base.GetChildElement("ssl", typeof(SslElement));
|
||||
}
|
||||
return this._ssl;
|
||||
}
|
||||
}
|
||||
|
||||
public SslClientCertificatesElement SslClientCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._sslClientCertificates == null)
|
||||
{
|
||||
this._sslClientCertificates = (SslClientCertificatesElement) base.GetChildElement("sslClientCertificates", typeof(SslClientCertificatesElement));
|
||||
}
|
||||
return this._sslClientCertificates;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum SelectiveLogging
|
||||
{
|
||||
LogAll,
|
||||
LogSuccessful,
|
||||
LogError,
|
||||
LogNothing
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class SessionCollection : ConfigurationElementCollectionBase<SessionElement>
|
||||
{
|
||||
protected override SessionElement CreateNewElement(string elementTagName)
|
||||
{
|
||||
return new SessionElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class SessionElement : ConfigurationElement
|
||||
{
|
||||
private ConfigurationMethod _terminateMethod;
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
if (this._terminateMethod == null)
|
||||
{
|
||||
this._terminateMethod = base.Methods["Terminate"];
|
||||
}
|
||||
this._terminateMethod.CreateInstance().Execute();
|
||||
}
|
||||
|
||||
public long BytesReceived
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["bytesReceived"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["bytesReceived"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long BytesSent
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["bytesSent"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["bytesSent"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandStartTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["commandStartTime"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["commandStartTime"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string CurrentCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["currentCommand"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["currentCommand"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long LastErrorStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["lastErrorStatus"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["lastErrorStatus"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PreviousCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["previousCommand"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["previousCommand"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long SessionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long) base["sessionId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["sessionId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SessionStartTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["sessionStartTime"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["sessionStartTime"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["userName"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["userName"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum ShowFlags
|
||||
{
|
||||
DisplayAvailableBytes = 0x10,
|
||||
DisplayVirtualDirectories = 0x20,
|
||||
LongDate = 2,
|
||||
None = 0,
|
||||
StyleUnix = 4
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
public enum SiteState
|
||||
{
|
||||
Starting,
|
||||
Started,
|
||||
Stopping,
|
||||
Stopped,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class SslClientCertificatesElement : ConfigurationElement
|
||||
{
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["enabled"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["enabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan RevocationFreshnessTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return (TimeSpan) base["revocationFreshnessTime"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["revocationFreshnessTime"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan RevocationUrlRetrievalTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return (TimeSpan) base["revocationUrlRetrievalTimeout"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["revocationUrlRetrievalTimeout"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseAdMapper
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["useAdMapper"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["useAdMapper"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationFlags ValidationFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ValidationFlags) base["validationFlags"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["validationFlags"] = (int) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class SslElement : ConfigurationElement
|
||||
{
|
||||
public ControlChannelPolicy ControlChannelPolicy
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ControlChannelPolicy) base["controlChannelPolicy"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["controlChannelPolicy"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public DataChannelPolicy DataChannelPolicy
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DataChannelPolicy) base["dataChannelPolicy"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["dataChannelPolicy"] = (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerCertHash
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["serverCertHash"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["serverCertHash"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerCertStoreName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) base["serverCertStoreName"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["serverCertStoreName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Ssl128
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool) base["ssl128"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["ssl128"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
|
||||
internal class UserIsolationElement : ConfigurationElement
|
||||
{
|
||||
private ActiveDirectoryElement _activeDirectory;
|
||||
|
||||
public ActiveDirectoryElement ActiveDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._activeDirectory == null)
|
||||
{
|
||||
this._activeDirectory = (ActiveDirectoryElement) base.GetChildElement("activeDirectory", typeof(ActiveDirectoryElement));
|
||||
}
|
||||
return this._activeDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
public Mode Mode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Mode) base["mode"];
|
||||
}
|
||||
set
|
||||
{
|
||||
base["mode"] = (int) value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70.Config
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum ValidationFlags
|
||||
{
|
||||
CertChainCacheOnlyUrlRetrieval = 4,
|
||||
CertChainRevocationCheckCacheOnly = 2,
|
||||
CertNoUsageCheck = 8,
|
||||
NoRevocationCheck = 1
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70
|
||||
{
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using Microsoft.Web.Administration;
|
||||
using Microsoft.Web.Management.Ftp.Configuration;
|
||||
using Microsoft.Web.Management.Server;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Web.UI;
|
||||
|
||||
internal static class FtpHelper
|
||||
{
|
||||
public const string ConfigurationError = "ConfigurationError";
|
||||
public const string FtpProtocol = "ftp";
|
||||
private const string GetSettingsExceptionError = "GetSettingsExceptionError";
|
||||
private const string SiteIsNotFtpSiteExceptionError = "SiteIsNotFtpSiteExceptionError";
|
||||
private const string szOID_ENHANCED_KEY_USAGE = "2.5.29.37";
|
||||
private const string szOID_PKIX_KP_SERVER_AUTH = "1.3.6.1.5.5.7.3.1";
|
||||
|
||||
public static bool CanAuthenticateServer(X509Certificate2 certificate)
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (X509Extension extension in certificate.Extensions)
|
||||
{
|
||||
if (string.Equals(extension.Oid.Value, "2.5.29.37", StringComparison.Ordinal))
|
||||
{
|
||||
flag = true;
|
||||
X509EnhancedKeyUsageExtension extension2 = extension as X509EnhancedKeyUsageExtension;
|
||||
if (extension2 != null)
|
||||
{
|
||||
OidEnumerator enumerator = extension2.EnhancedKeyUsages.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (string.Equals(enumerator.Current.Value, "1.3.6.1.5.5.7.3.1", StringComparison.Ordinal))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return !flag;
|
||||
}
|
||||
|
||||
public static string ConvertDistinguishedNameToString(X500DistinguishedName dnString)
|
||||
{
|
||||
string name = dnString.Name;
|
||||
bool flag = false;
|
||||
string[] strArray = dnString.Decode(X500DistinguishedNameFlags.UseNewLines).Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strArray.Length > 0)
|
||||
{
|
||||
flag = true;
|
||||
string pairAndValue = string.Empty;
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
pairAndValue = strArray[i];
|
||||
Pair pair = ConvertStringToPair(pairAndValue);
|
||||
if (string.Equals((string) pair.First, "CN", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
name = (string) pair.Second;
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = (string) ConvertStringToPair(name).Second;
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
name = dnString.Name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private static Pair ConvertStringToPair(string pairAndValue)
|
||||
{
|
||||
Pair pair = new Pair(pairAndValue, pairAndValue);
|
||||
int length = -1;
|
||||
length = pairAndValue.IndexOf("=", StringComparison.Ordinal);
|
||||
if ((length != -1) && (pairAndValue.Length >= (length + 1)))
|
||||
{
|
||||
string x = pairAndValue.Substring(0, length);
|
||||
string y = pairAndValue.Substring(length + 1);
|
||||
pair = new Pair(x, y);
|
||||
}
|
||||
return pair;
|
||||
}
|
||||
|
||||
public static ConfigurationSection GetAppHostSection(ServerManager serverManager, string sectionName, Type type, ManagementConfigurationPath configPath)
|
||||
{
|
||||
if ((serverManager == null) || (configPath == null))
|
||||
{
|
||||
throw new ArgumentNullException("ConfigurationError");
|
||||
}
|
||||
|
||||
Configuration applicationHostConfiguration = serverManager.GetApplicationHostConfiguration();
|
||||
string effectiveConfigurationPath = configPath.GetEffectiveConfigurationPath(ManagementScope.Server);
|
||||
ConfigurationSection section = applicationHostConfiguration.GetSection(sectionName, type, effectiveConfigurationPath);
|
||||
if (section == null)
|
||||
{
|
||||
throw new NullReferenceException("ConfigurationError");
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
public static FtpSite GetFtpSite(ManagementConfigurationPath configPath, ServerManager serverManager)
|
||||
{
|
||||
FtpSite ftpSiteDefaultElement = null;
|
||||
if (configPath.PathType == ConfigurationPathType.Server)
|
||||
{
|
||||
ftpSiteDefaultElement = GetFtpSiteDefaultElement(serverManager.SiteDefaults);
|
||||
}
|
||||
else
|
||||
{
|
||||
Site site = serverManager.Sites[configPath.SiteName];
|
||||
if (site == null)
|
||||
{
|
||||
WebManagementServiceException exception = new WebManagementServiceException("GetSettingsExceptionError", string.Empty);
|
||||
throw exception;
|
||||
}
|
||||
if (!IsFtpSite(site))
|
||||
{
|
||||
WebManagementServiceException exception2 = new WebManagementServiceException("SiteIsNotFtpSiteExceptionError", string.Empty);
|
||||
throw exception2;
|
||||
}
|
||||
ftpSiteDefaultElement = GetFtpSiteElement(site);
|
||||
}
|
||||
if (ftpSiteDefaultElement == null)
|
||||
{
|
||||
WebManagementServiceException exception3 = new WebManagementServiceException("GetSettingsExceptionError", string.Empty);
|
||||
throw exception3;
|
||||
}
|
||||
return ftpSiteDefaultElement;
|
||||
}
|
||||
|
||||
public static FtpSite GetFtpSiteDefaultElement(SiteDefaults siteDefaults)
|
||||
{
|
||||
return (FtpSite) siteDefaults.GetChildElement("ftpServer", typeof(FtpSite));
|
||||
}
|
||||
|
||||
public static FtpSite GetFtpSiteElement(Site site)
|
||||
{
|
||||
return (FtpSite) site.GetChildElement("ftpServer", typeof(FtpSite));
|
||||
}
|
||||
|
||||
public static bool IsFtpSite(Site site)
|
||||
{
|
||||
foreach (Binding binding in site.Bindings)
|
||||
{
|
||||
if (string.Equals(binding.Protocol, "ftp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70
|
||||
{
|
||||
internal class FtpSiteGlobals
|
||||
{
|
||||
//
|
||||
public const int BindingProtocol = 0;
|
||||
//
|
||||
public const int SslCertificate_FriendlyName = 0;
|
||||
//
|
||||
public const int Authorization_Users = 1;
|
||||
//
|
||||
public const int BindingInformation = 1;
|
||||
//
|
||||
public const int SslCertificate_Hash = 1;
|
||||
//
|
||||
public const int Authorization_Roles = 2;
|
||||
//
|
||||
public const int SslCertificate_IssuedTo = 2;
|
||||
//
|
||||
public const int BindingIndex = 2;
|
||||
//
|
||||
public const int Authorization_Permission = 3;
|
||||
//
|
||||
public const int Site_Name = 100;
|
||||
//
|
||||
public const int Site_ID = 103;
|
||||
//
|
||||
public const int Site_SingleBinding = 104;
|
||||
//
|
||||
public const int Site_Bindings = 105;
|
||||
//
|
||||
public const int VirtualDirectory_PhysicalPath = 300;
|
||||
//
|
||||
public const int VirtualDirectory_UserName = 301;
|
||||
//
|
||||
public const int VirtualDirectory_Password = 302;
|
||||
//
|
||||
public const int VirtualDirectory_Password_Set = 303;
|
||||
//
|
||||
public const int FtpSite_AutoStart = 350;
|
||||
//
|
||||
public const int FtpSite_Status = 351;
|
||||
//
|
||||
public const int Connections_UnauthenticatedTimeout = 400;
|
||||
//
|
||||
public const int Connections_ControlChannelTimeout = 401;
|
||||
//
|
||||
public const int Connections_DisableSocketPooling = 402;
|
||||
//
|
||||
public const int Connections_ServerListenBacklog = 403;
|
||||
//
|
||||
public const int Connections_DataChannelTimeout = 404;
|
||||
//
|
||||
public const int Connections_MinBytesPerSecond = 405;
|
||||
//
|
||||
public const int Connections_MaxConnections = 406;
|
||||
//
|
||||
public const int Connections_ResetOnMaxConnection = 407;
|
||||
//
|
||||
public const int Ssl_ServerCertHash = 410;
|
||||
//
|
||||
public const int Ssl_ControlChannelPolicy = 411;
|
||||
//
|
||||
public const int Ssl_DataChannelPolicy = 412;
|
||||
//
|
||||
public const int Ssl_Ssl128 = 413;
|
||||
//
|
||||
public const int Authentication_AnonymousEnabled = 420;
|
||||
//
|
||||
public const int Authentication_BasicEnabled = 421;
|
||||
//
|
||||
public const int Authorization_Rule = 422;
|
||||
//
|
||||
public const string FtpServerElementName = "ftpServer";
|
||||
//
|
||||
public const string SearchHostHeader = "SearchHostHeader";
|
||||
//
|
||||
public const string SearchIPAddress = "SearchIPAddress";
|
||||
//
|
||||
public const string SearchPhysicalPath = "SearchPhysicalPath";
|
||||
//
|
||||
public const string SearchPort = "SearchPort";
|
||||
//
|
||||
public const string SearchSiteName = "SearchSiteName";
|
||||
}
|
||||
}
|
981
WebsitePanel/Sources/WebsitePanel.Providers.FTP.IIs70/MsFTP.cs
Normal file
981
WebsitePanel/Sources/WebsitePanel.Providers.FTP.IIs70/MsFTP.cs
Normal file
|
@ -0,0 +1,981 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using WebsitePanel.Providers.FTP.IIs70;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Authorization;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using WebsitePanel.Providers.Utils;
|
||||
using WebsitePanel.Providers.Utils.LogParser;
|
||||
using WebsitePanel.Server.Utils;
|
||||
using Microsoft.Web.Management.Server;
|
||||
using Microsoft.Win32;
|
||||
using IisFtpSite = WebsitePanel.Providers.FTP.IIs70.Config.FtpSite;
|
||||
using IisSite = Microsoft.Web.Administration.Site;
|
||||
|
||||
namespace WebsitePanel.Providers.FTP
|
||||
{
|
||||
public class MsFTP : HostingServiceProviderBase, IFtpServer
|
||||
{
|
||||
private SitesModuleService ftpSitesService;
|
||||
private static readonly string DefaultFtpSiteFolder = @"%SystemDrive%\inetpub\ftproot";
|
||||
private static readonly string DefaultFtpSiteLogsFolder = @"%SystemDrive%\inetpub\logs\LogFiles";
|
||||
public const string DEFAULT_LOG_EXT_FILE_FIELDS = @"Date,Time,ClientIP,UserName,SiteName,ComputerName,
|
||||
ServerIP,Method,UriStem,FtpStatus,Win32Status,BytesSent,BytesRecv,TimeTaken,ServerPort,Host,FtpSubStatus,
|
||||
Session,FullPath,Info,ClientPort";
|
||||
|
||||
private static string[] FTP70_SERVICE_CMD_LIST = new string[] {
|
||||
"DataChannelClosed",
|
||||
"DataChannelOpened",
|
||||
"ControlChannelOpened"
|
||||
};
|
||||
|
||||
public const string EMPTY_LOG_FIELD = "-";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MsFTP"/> class.
|
||||
/// </summary>
|
||||
public MsFTP()
|
||||
{
|
||||
if (IsMsFTPInstalled())
|
||||
{
|
||||
this.ftpSitesService = new SitesModuleService();
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
protected string SiteId
|
||||
{
|
||||
get { return ProviderSettings["SiteId"]; }
|
||||
}
|
||||
|
||||
protected string SharedIP
|
||||
{
|
||||
get { return ProviderSettings["SharedIP"]; }
|
||||
}
|
||||
|
||||
protected string FtpGroupName
|
||||
{
|
||||
get { return ProviderSettings["FtpGroupName"]; }
|
||||
}
|
||||
|
||||
protected string UsersOU
|
||||
{
|
||||
get { return ProviderSettings["ADUsersOU"]; }
|
||||
}
|
||||
|
||||
protected string GroupsOU
|
||||
{
|
||||
get { return ProviderSettings["ADGroupsOU"]; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IFtpServer Members
|
||||
|
||||
/// <summary>
|
||||
/// Changes site's state.
|
||||
/// </summary>
|
||||
/// <param name="siteId">Site's id to change state for.</param>
|
||||
/// <param name="state">State to be set.</param>
|
||||
/// <exception cref="ArgumentException">Is thrown in case site name is null or empty.</exception>
|
||||
public void ChangeSiteState(string siteId, ServerState state)
|
||||
{
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
{
|
||||
throw new ArgumentException("Site name is null or empty.");
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ServerState.Continuing:
|
||||
case ServerState.Started:
|
||||
this.ftpSitesService.StartSite(siteId);
|
||||
break;
|
||||
case ServerState.Stopped:
|
||||
case ServerState.Paused:
|
||||
this.ftpSitesService.StopSite(siteId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets state for ftp site with supplied id.
|
||||
/// </summary>
|
||||
/// <param name="siteId">Site's id to get state for.</param>
|
||||
/// <returns>Ftp site's state.</returns>
|
||||
/// <exception cref="ArgumentException">Is thrown in case site name is null or empty.</exception>
|
||||
public ServerState GetSiteState(string siteId)
|
||||
{
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
{
|
||||
throw new ArgumentException("Site name is null or empty.");
|
||||
}
|
||||
|
||||
return this.ftpSitesService.GetSiteState(siteId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether site with given name exists.
|
||||
/// </summary>
|
||||
/// <param name="siteId">Site's name to check.</param>
|
||||
/// <returns>true - if it exists; false - otherwise.</returns>
|
||||
/// <exception cref="ArgumentException">Is thrown in case site name is null or empty.</exception>
|
||||
public bool SiteExists(string siteId)
|
||||
{
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
{
|
||||
throw new ArgumentException("Site name is null or empty.");
|
||||
}
|
||||
// In case site id doesn't contain default ftp site name we consider it as not existent.
|
||||
return this.ftpSitesService.SiteExists(siteId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of available ftp sites.
|
||||
/// </summary>
|
||||
/// <returns>List of available ftp sites.</returns>
|
||||
public FtpSite[] GetSites()
|
||||
{
|
||||
List<FtpSite> ftpSites = new List<FtpSite>();
|
||||
|
||||
foreach (string ftpSiteName in this.ftpSitesService.GetSitesNames())
|
||||
{
|
||||
ftpSites.Add(this.GetSite(ftpSiteName));
|
||||
}
|
||||
|
||||
return ftpSites.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets ftp site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteId">Ftp site's name to get.</param>
|
||||
/// <returns>Ftp site.</returns>
|
||||
/// <exception cref="ArgumentException"> Is thrown in case site name is null or empty. </exception>
|
||||
public FtpSite GetSite(string siteId)
|
||||
{
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
{
|
||||
throw new ArgumentException("Site name is null or empty.");
|
||||
}
|
||||
|
||||
FtpSite ftpSite = new FtpSite();
|
||||
ftpSite.SiteId = siteId;
|
||||
ftpSite.Name = siteId;
|
||||
this.FillFtpSiteFromIis(ftpSite);
|
||||
|
||||
return ftpSite;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates ftp site.
|
||||
/// </summary>
|
||||
/// <param name="site">Ftp site to be created.</param>
|
||||
/// <returns>Created site id.</returns>
|
||||
/// <exception cref="ArgumentNullException">Is thrown in case supplied argument is null.</exception>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Is thrown in case site id or its name is null or empty or if site id is not equal to default ftp site name.
|
||||
/// </exception>
|
||||
public string CreateSite(FtpSite site)
|
||||
{
|
||||
if (site == null)
|
||||
{
|
||||
throw new ArgumentNullException("site");
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(site.SiteId) || String.IsNullOrEmpty(site.Name))
|
||||
{
|
||||
throw new ArgumentException("Site id or name is null or empty.");
|
||||
}
|
||||
|
||||
this.CheckFtpServerBindings(site);
|
||||
|
||||
PropertyBag siteBag = this.ftpSitesService.GetSiteDefaults();
|
||||
// Set site name
|
||||
siteBag[FtpSiteGlobals.Site_Name] = site.Name;
|
||||
// Set site physical path
|
||||
siteBag[FtpSiteGlobals.VirtualDirectory_PhysicalPath] = site.ContentPath;
|
||||
PropertyBag ftpBinding = new PropertyBag();
|
||||
// Set site binding protocol
|
||||
ftpBinding[FtpSiteGlobals.BindingProtocol] = "ftp";
|
||||
// fill binding summary info
|
||||
ftpBinding[FtpSiteGlobals.BindingInformation] = site.Bindings[0].ToString();
|
||||
|
||||
// Set site binding
|
||||
siteBag[FtpSiteGlobals.Site_SingleBinding] = ftpBinding;
|
||||
|
||||
// Auto-start
|
||||
siteBag[FtpSiteGlobals.FtpSite_AutoStart] = true;
|
||||
|
||||
// Set anonumous authentication
|
||||
siteBag[FtpSiteGlobals.Authentication_AnonymousEnabled] = true;
|
||||
siteBag[FtpSiteGlobals.Authentication_BasicEnabled] = true;
|
||||
|
||||
this.ftpSitesService.AddSite(siteBag);
|
||||
|
||||
AuthorizationRuleCollection rules = this.ftpSitesService.GetAuthorizationRuleCollection(site.Name);
|
||||
rules.Add(AuthorizationRuleAccessType.Allow, "*", String.Empty, PermissionsFlags.Read);
|
||||
|
||||
IisFtpSite iisFtpSite = this.ftpSitesService.GetIisFtpSite(site.Name);
|
||||
iisFtpSite.UserIsolation.Mode = Mode.StartInUsersDirectory;
|
||||
iisFtpSite.Security.Ssl.ControlChannelPolicy = ControlChannelPolicy.SslAllow;
|
||||
iisFtpSite.Security.Ssl.DataChannelPolicy = DataChannelPolicy.SslAllow;
|
||||
|
||||
this.FillIisFromFtpSite(site);
|
||||
|
||||
this.ftpSitesService.CommitChanges();
|
||||
|
||||
// Do not start the site because it is started during creation.
|
||||
try
|
||||
{
|
||||
this.ChangeSiteState(site.Name, ServerState.Started);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore the error if happened.
|
||||
}
|
||||
return site.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates site with given information.
|
||||
/// </summary>
|
||||
/// <param name="site">Ftp site.</param>
|
||||
public void UpdateSite(FtpSite site)
|
||||
{
|
||||
// Check server bindings.
|
||||
CheckFtpServerBindings(site);
|
||||
|
||||
this.FillIisFromFtpSite(site);
|
||||
|
||||
this.ftpSitesService.CommitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes site with specified name.
|
||||
/// </summary>
|
||||
/// <param name="siteId">Site's name to be deleted.</param>
|
||||
public void DeleteSite(string siteId)
|
||||
{
|
||||
this.ftpSitesService.DeleteSite(siteId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether account with given name exists.
|
||||
/// </summary>
|
||||
/// <param name="accountName">Account name to check.</param>
|
||||
/// <returns>true - if it exists; false - otherwise.</returns>
|
||||
public bool AccountExists(string accountName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(accountName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check acocunt on FTP server
|
||||
bool ftpExists = this.ftpSitesService.VirtualDirectoryExists(this.SiteId, accountName);
|
||||
|
||||
// check account in the system
|
||||
bool systemExists = SecurityUtils.UserExists(accountName, ServerSettings, UsersOU);
|
||||
return (ftpExists || systemExists);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets available ftp accounts.
|
||||
/// </summary>
|
||||
/// <returns>List of avaialble accounts.</returns>
|
||||
public FtpAccount[] GetAccounts()
|
||||
{
|
||||
List<FtpAccount> accounts = new List<FtpAccount>();
|
||||
|
||||
foreach (string directory in this.ftpSitesService.GetVirtualDirectoriesNames(this.SiteId))
|
||||
{
|
||||
// Skip root virtual directory
|
||||
if (String.Equals(directory, "/"))
|
||||
continue;
|
||||
//
|
||||
accounts.Add(this.GetAccount(directory.Substring(1)));
|
||||
}
|
||||
|
||||
return accounts.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets account with given name.
|
||||
/// </summary>
|
||||
/// <param name="accountName">Account's name to get.</param>
|
||||
/// <returns>Ftp account.</returns>
|
||||
public FtpAccount GetAccount(string accountName)
|
||||
{
|
||||
FtpAccount acc = new FtpAccount();
|
||||
acc.Name = accountName;
|
||||
this.FillFtpAccountFromIis(acc);
|
||||
return acc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates ftp account under root ftp site.
|
||||
/// </summary>
|
||||
/// <param name="account">Ftp account to create.</param>
|
||||
public void CreateAccount(FtpAccount account)
|
||||
{
|
||||
// Create user account.
|
||||
SystemUser user = new SystemUser();
|
||||
user.Name = account.Name;
|
||||
user.FullName = account.Name;
|
||||
user.Description = "WebsitePanel System Account";
|
||||
user.MemberOf = new string[] { FtpGroupName };
|
||||
user.Password = account.Password;
|
||||
user.PasswordCantChange = true;
|
||||
user.PasswordNeverExpires = true;
|
||||
user.AccountDisabled = !account.Enabled;
|
||||
user.System = true;
|
||||
|
||||
// Create in the operating system.
|
||||
if (SecurityUtils.UserExists(user.Name, ServerSettings, UsersOU))
|
||||
{
|
||||
SecurityUtils.DeleteUser(user.Name, ServerSettings, UsersOU);
|
||||
}
|
||||
SecurityUtils.CreateUser(user, ServerSettings, UsersOU, GroupsOU);
|
||||
|
||||
// Prepare account's home folder.
|
||||
this.EnsureUserHomeFolderExists(account.Folder, account.Name, account.CanRead, account.CanWrite);
|
||||
|
||||
// Future account will be given virtual directory under default ftp web site.
|
||||
this.ftpSitesService.CreateFtpAccount(this.SiteId, account);
|
||||
//
|
||||
this.ftpSitesService.ConfigureConnectAs(account.Folder, this.SiteId, account.VirtualPath,
|
||||
this.GetQualifiedAccountName(account.Name), account.Password, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates ftp account.
|
||||
/// </summary>
|
||||
/// <param name="account">Accoun to update.</param>
|
||||
public void UpdateAccount(FtpAccount account)
|
||||
{
|
||||
// Change user account state and password (if required).
|
||||
SystemUser user = SecurityUtils.GetUser(account.Name, ServerSettings, UsersOU);
|
||||
user.Password = account.Password;
|
||||
user.AccountDisabled = !account.Enabled;
|
||||
SecurityUtils.UpdateUser(user, ServerSettings, UsersOU, GroupsOU);
|
||||
// Update iis configuration.
|
||||
this.FillIisFromFtpAccount(account);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes account with given name.
|
||||
/// </summary>
|
||||
/// <param name="accountName">Account's name to be deleted.</param>
|
||||
public void DeleteAccount(string accountName)
|
||||
{
|
||||
string virtualDirectory = String.Format("/{0}", accountName);
|
||||
string currentPhysicalPath = this.ftpSitesService.GetSitePhysicalPath(this.SiteId, virtualDirectory);
|
||||
|
||||
// Delete virtual directory
|
||||
this.ftpSitesService.DeleteFtpAccount(this.SiteId, virtualDirectory);
|
||||
|
||||
this.ftpSitesService.CommitChanges();
|
||||
|
||||
// Remove permissions
|
||||
RemoveFtpFolderPermissions(currentPhysicalPath, accountName);
|
||||
|
||||
// Delete system user account
|
||||
if (SecurityUtils.UserExists(accountName, ServerSettings, UsersOU))
|
||||
{
|
||||
SecurityUtils.DeleteUser(accountName, ServerSettings, UsersOU);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills iis configuration from ftp account.
|
||||
/// </summary>
|
||||
/// <param name="ftpAccount">Ftp account to fill from.</param>
|
||||
private void FillIisFromFtpAccount(FtpAccount ftpAccount)
|
||||
{
|
||||
// Remove permissions if required.
|
||||
string currentPhysicalPath = this.ftpSitesService.GetSitePhysicalPath(this.SiteId, String.Format("/{0}", ftpAccount.Name));
|
||||
if (String.Compare(currentPhysicalPath, ftpAccount.Folder, true) != 0)
|
||||
{
|
||||
RemoveFtpFolderPermissions(currentPhysicalPath, ftpAccount.Name);
|
||||
}
|
||||
|
||||
// Set new permissions
|
||||
EnsureUserHomeFolderExists(ftpAccount.Folder, ftpAccount.Name, ftpAccount.CanRead, ftpAccount.CanWrite);
|
||||
// Update physical path.
|
||||
this.ftpSitesService.SetSitePhysicalPath(this.SiteId, ftpAccount.VirtualPath, ftpAccount.Folder);
|
||||
|
||||
// Configure connect as feature.
|
||||
this.ftpSitesService.ConfigureConnectAs(ftpAccount.Folder, this.SiteId, ftpAccount.VirtualPath,
|
||||
this.GetQualifiedAccountName(ftpAccount.Name), ftpAccount.Password, false);
|
||||
|
||||
// Update authorization rules.
|
||||
AuthorizationRuleCollection authRulesCollection = this.ftpSitesService.GetAuthorizationRuleCollection(String.Format("{0}/{1}", this.SiteId, ftpAccount.Name));
|
||||
AuthorizationRule realtedRule = null;
|
||||
foreach(AuthorizationRule rule in authRulesCollection)
|
||||
{
|
||||
IList<string> users = rule.Users.Split(',');
|
||||
if (users.Contains(ftpAccount.Name))
|
||||
{
|
||||
realtedRule = rule;
|
||||
}
|
||||
}
|
||||
if (realtedRule != null)
|
||||
{
|
||||
PermissionsFlags permissions = 0;
|
||||
if (ftpAccount.CanRead)
|
||||
{
|
||||
permissions |= PermissionsFlags.Read;
|
||||
}
|
||||
if (ftpAccount.CanWrite)
|
||||
{
|
||||
permissions |= PermissionsFlags.Write;
|
||||
}
|
||||
if (ftpAccount.CanRead || ftpAccount.CanWrite)
|
||||
{
|
||||
realtedRule.Permissions = permissions;
|
||||
}
|
||||
}
|
||||
|
||||
this.ftpSitesService.CommitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills ftp account from iis configuration.
|
||||
/// </summary>
|
||||
/// <param name="ftpAccount">Ftp account to fill.</param>
|
||||
private void FillFtpAccountFromIis(FtpAccount ftpAccount)
|
||||
{
|
||||
//
|
||||
ftpAccount.Folder = this.ftpSitesService.GetSitePhysicalPath(this.SiteId, String.Format("/{0}", ftpAccount.Name));
|
||||
|
||||
AuthorizationRuleCollection authRulesCollection = this.ftpSitesService.GetAuthorizationRuleCollection(String.Format("{0}/{1}", this.SiteId, ftpAccount.Name));
|
||||
ftpAccount.CanRead = false;
|
||||
ftpAccount.CanWrite = false;
|
||||
foreach(AuthorizationRule rule in authRulesCollection)
|
||||
{
|
||||
if (rule.AccessType == AuthorizationRuleAccessType.Allow)
|
||||
{
|
||||
foreach(string userName in rule.Users.Split(','))
|
||||
{
|
||||
if (String.Compare(userName, ftpAccount.Name, true) == 0)
|
||||
{
|
||||
ftpAccount.CanWrite = (rule.Permissions & PermissionsFlags.Write) == PermissionsFlags.Write;
|
||||
ftpAccount.CanRead = (rule.Permissions & PermissionsFlags.Read) == PermissionsFlags.Read;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load user account.
|
||||
SystemUser user = SecurityUtils.GetUser(ftpAccount.Name, ServerSettings, UsersOU);
|
||||
if (user != null)
|
||||
{
|
||||
ftpAccount.Enabled = !user.AccountDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills ftp site with data from iis ftp site.
|
||||
/// </summary>
|
||||
/// <param name="ftpSite">Ftp site to fill.</param>
|
||||
private void FillFtpSiteFromIis(FtpSite ftpSite)
|
||||
{
|
||||
IisFtpSite iisFtpSite = this.ftpSitesService.GetIisFtpSite(ftpSite.SiteId);
|
||||
if (iisFtpSite != null)
|
||||
{
|
||||
// Security settings.
|
||||
ftpSite.AllowAnonymous = iisFtpSite.Security.Authentication.AnonymousAuthentication.Enabled;
|
||||
ftpSite.AnonymousUsername = iisFtpSite.Security.Authentication.AnonymousAuthentication.UserName;
|
||||
ftpSite.AnonymousUserPassword = iisFtpSite.Security.Authentication.AnonymousAuthentication.Password;
|
||||
// Logging settings.
|
||||
ftpSite[FtpSite.MSFTP7_SITE_ID] = iisFtpSite.SiteServiceId;
|
||||
if (iisFtpSite.LogFile.Enabled)
|
||||
{
|
||||
ftpSite.LogFileDirectory = iisFtpSite.LogFile.Directory;
|
||||
ftpSite[FtpSite.MSFTP7_LOG_EXT_FILE_FIELDS] = iisFtpSite.LogFile.LogExtFileFlags.ToString();
|
||||
}
|
||||
}
|
||||
// Bindings
|
||||
ftpSite.Bindings = this.ftpSitesService.GetSiteBindings(ftpSite.SiteId);
|
||||
// Physical path
|
||||
ftpSite.ContentPath = this.ftpSitesService.GetSitePhysicalPath(ftpSite.SiteId, "/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills iis configuration with information from ftp site.
|
||||
/// </summary>
|
||||
/// <param name="ftpSite">Ftp site that holds information.</param>
|
||||
private void FillIisFromFtpSite(FtpSite ftpSite)
|
||||
{
|
||||
IisFtpSite iisFtpSite = this.ftpSitesService.GetIisFtpSite(ftpSite.SiteId);
|
||||
string logExtFileFields = ftpSite[FtpSite.MSFTP7_LOG_EXT_FILE_FIELDS];
|
||||
|
||||
if (iisFtpSite != null)
|
||||
{
|
||||
// Security settings.
|
||||
iisFtpSite.Security.Authentication.AnonymousAuthentication.Enabled = ftpSite.AllowAnonymous;
|
||||
iisFtpSite.Security.Authentication.AnonymousAuthentication.UserName = ftpSite.AnonymousUsername;
|
||||
iisFtpSite.Security.Authentication.AnonymousAuthentication.Password = ftpSite.AnonymousUserPassword;
|
||||
// enable logging
|
||||
iisFtpSite.LogFile.Enabled = true;
|
||||
// set logging fields
|
||||
if (!String.IsNullOrEmpty(logExtFileFields))
|
||||
iisFtpSite.LogFile.LogExtFileFlags = (FtpLogExtFileFlags)Enum.Parse(typeof(FtpLogExtFileFlags), logExtFileFields);
|
||||
// set log files directory
|
||||
if (!String.IsNullOrEmpty(ftpSite.LogFileDirectory))
|
||||
iisFtpSite.LogFile.Directory = ftpSite.LogFileDirectory;
|
||||
}
|
||||
// Set new bindings.
|
||||
this.CheckFtpServerBindings(ftpSite);
|
||||
this.ftpSitesService.SetSiteBindings(ftpSite.Name, ftpSite.Bindings);
|
||||
// Physical path
|
||||
this.ftpSitesService.SetSitePhysicalPath(ftpSite.SiteId, "/", ftpSite.ContentPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that home folder for ftp account exists.
|
||||
/// </summary>
|
||||
/// <param name="folder">Path to home folder.</param>
|
||||
/// <param name="accountName">Account name.</param>
|
||||
/// <param name="allowRead">A value which specifies whether read operation is allowed or not.</param>
|
||||
/// <param name="allowWrite">A value which specifies whether write operation is allowed or not.</param>
|
||||
private void EnsureUserHomeFolderExists(string folder, string accountName, bool allowRead, bool allowWrite)
|
||||
{
|
||||
// create folder
|
||||
if (!FileUtils.DirectoryExists(folder))
|
||||
{
|
||||
FileUtils.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
if (!allowRead && !allowWrite)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NTFSPermission permissions = allowRead ? NTFSPermission.Read : NTFSPermission.Write;
|
||||
|
||||
if (allowRead && allowWrite)
|
||||
{
|
||||
permissions = NTFSPermission.Modify;
|
||||
}
|
||||
|
||||
// Set ntfs permissions
|
||||
SecurityUtils.GrantNtfsPermissions(folder, accountName, permissions, true, true,
|
||||
ServerSettings, UsersOU, GroupsOU);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes user specific permissions from folder.
|
||||
/// </summary>
|
||||
/// <param name="path">Folder to operate on.</param>
|
||||
/// <param name="accountName">User's name.</param>
|
||||
private void RemoveFtpFolderPermissions(string path, string accountName)
|
||||
{
|
||||
if (!FileUtils.DirectoryExists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Anonymous account
|
||||
SecurityUtils.RemoveNtfsPermissions(path, accountName, ServerSettings, UsersOU, GroupsOU);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if bindings listed in given site already in use.
|
||||
/// </summary>
|
||||
/// <param name="site">Site to check.</param>
|
||||
/// <exception cref="InvalidOperationException">Is thrown in case supplied site contains bindings that are already in use.</exception>
|
||||
private void CheckFtpServerBindings(FtpSite site)
|
||||
{
|
||||
if (this.IsFtpServerBindingsInUse(site))
|
||||
{
|
||||
throw new InvalidOperationException("Some of ftp site's bindings are already in use.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value which shows whether supplied site contains bindings that are already in use.
|
||||
/// </summary>
|
||||
/// <param name="site">Site to check.</param>
|
||||
/// <returns>true - if any of supplied bindinds is in use; false -otherwise.</returns>
|
||||
private bool IsFtpServerBindingsInUse(FtpSite site)
|
||||
{
|
||||
if (site == null)
|
||||
{
|
||||
throw new ArgumentNullException("site");
|
||||
}
|
||||
|
||||
// check for server bindings
|
||||
foreach (FtpSite existentSite in this.GetSites())
|
||||
{
|
||||
if (existentSite.Name != site.Name)
|
||||
{
|
||||
foreach (ServerBinding usedBinding in existentSite.Bindings)
|
||||
{
|
||||
foreach (ServerBinding requestedBinding in site.Bindings)
|
||||
{
|
||||
if (usedBinding.IP == requestedBinding.IP && usedBinding.Port == usedBinding.Port)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets fully qualified name with respect to enabled active directory.
|
||||
/// </summary>
|
||||
/// <param name="accountName">Account name.</param>
|
||||
/// <returns>Fully qualified acount/domain name.</returns>
|
||||
private string GetQualifiedAccountName(string accountName)
|
||||
{
|
||||
if (!ServerSettings.ADEnabled)
|
||||
{
|
||||
return accountName;
|
||||
}
|
||||
|
||||
if (accountName.IndexOf("\\") != -1)
|
||||
{
|
||||
return accountName; // already has domain information
|
||||
}
|
||||
|
||||
// DO IT FOR ACTIVE DIRECTORY MODE ONLY
|
||||
string domainName = null;
|
||||
try
|
||||
{
|
||||
DirectoryContext objContext = new DirectoryContext(DirectoryContextType.Domain, ServerSettings.ADRootDomain);
|
||||
Domain objDomain = Domain.GetDomain(objContext);
|
||||
domainName = objDomain.Name;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("Get domain name error", ex);
|
||||
}
|
||||
|
||||
return domainName != null ? domainName + "\\" + accountName : accountName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IHostingServiceProvier methods
|
||||
/// <summary>
|
||||
/// Installs Ftp7 provider.
|
||||
/// </summary>
|
||||
/// <returns>Error messages.</returns>
|
||||
public override string[] Install()
|
||||
{
|
||||
List<string> messages = new List<string>();
|
||||
|
||||
FtpSite site = null;
|
||||
string folder = FileUtils.EvaluateSystemVariables(DefaultFtpSiteFolder);
|
||||
string logsDirectory = FileUtils.EvaluateSystemVariables(DefaultFtpSiteLogsFolder);
|
||||
// Create site folder.
|
||||
if (!FileUtils.DirectoryExists(folder))
|
||||
{
|
||||
FileUtils.CreateDirectory(folder);
|
||||
}
|
||||
// Create logs folder.
|
||||
if (!FileUtils.DirectoryExists(logsDirectory))
|
||||
{
|
||||
FileUtils.CreateDirectory(logsDirectory);
|
||||
}
|
||||
|
||||
site = new FtpSite();
|
||||
|
||||
site.Name = this.SiteId;
|
||||
site.SiteId = this.SiteId;
|
||||
site.ContentPath = DefaultFtpSiteFolder;
|
||||
site.Bindings = new ServerBinding[1];
|
||||
// set default log directory
|
||||
site.LogFileDirectory = DefaultFtpSiteLogsFolder;
|
||||
// set default logging fields
|
||||
site[FtpSite.MSFTP7_LOG_EXT_FILE_FIELDS] = DEFAULT_LOG_EXT_FILE_FIELDS;
|
||||
|
||||
if (!String.IsNullOrEmpty(this.SharedIP))
|
||||
{
|
||||
site.Bindings[0] = new ServerBinding(this.SharedIP, "21", String.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
site.Bindings[0] = new ServerBinding("*", "21", "*");
|
||||
//// Get information on local server.
|
||||
//IPHostEntry localServerHostEntry = Dns.GetHostEntry(Dns.GetHostName());
|
||||
//foreach (IPAddress address in localServerHostEntry.AddressList)
|
||||
//{
|
||||
// if (address.AddressFamily == AddressFamily.InterNetwork)
|
||||
// {
|
||||
// site.Bindings[0] = new ServerBinding(address.ToString(), "21", String.Empty);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
if (this.IsFtpServerBindingsInUse(site))
|
||||
{
|
||||
messages.Add("Cannot create ftp site because requested bindings are already in use.");
|
||||
return messages.ToArray();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SecurityUtils.EnsureOrganizationalUnitsExist(ServerSettings, UsersOU, GroupsOU);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
messages.Add(String.Format("Could not check/create Organizational Units: {0}", ex.Message));
|
||||
return messages.ToArray();
|
||||
}
|
||||
|
||||
// create folder if it not exists
|
||||
if (String.IsNullOrEmpty(SiteId))
|
||||
{
|
||||
messages.Add("Please, select FTP site to create accounts on");
|
||||
}
|
||||
else
|
||||
{
|
||||
// create FTP group name
|
||||
if (String.IsNullOrEmpty(FtpGroupName))
|
||||
{
|
||||
messages.Add("FTP Group can not be blank");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// create group
|
||||
if (!SecurityUtils.GroupExists(FtpGroupName, ServerSettings, GroupsOU))
|
||||
{
|
||||
SystemGroup group = new SystemGroup();
|
||||
group.Name = FtpGroupName;
|
||||
group.Members = new string[] { };
|
||||
group.Description = "WebsitePanel System Group";
|
||||
|
||||
SecurityUtils.CreateGroup(group, ServerSettings, UsersOU, GroupsOU);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
messages.Add(String.Format("There was an error while adding '{0}' group: {1}",
|
||||
FtpGroupName, ex.Message));
|
||||
return messages.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.ftpSitesService.SiteExists(this.SiteId))
|
||||
{
|
||||
this.CreateSite(site);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.UpdateSite(site);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// set permissions on the site root
|
||||
SecurityUtils.GrantNtfsPermissions(site.ContentPath, FtpGroupName,
|
||||
NTFSPermission.Read, true, true, ServerSettings,
|
||||
UsersOU, GroupsOU);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
messages.Add(String.Format("Can not set permissions on '{0}' folder: {1}",
|
||||
site.ContentPath, ex.Message));
|
||||
return messages.ToArray();
|
||||
}
|
||||
}
|
||||
return messages.ToArray();
|
||||
}
|
||||
|
||||
public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
|
||||
{
|
||||
foreach (ServiceProviderItem item in items)
|
||||
{
|
||||
if (item is FtpAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
// make FTP account read-only
|
||||
FtpAccount account = GetAccount(item.Name);
|
||||
account.Enabled = enabled;
|
||||
UpdateAccount(account);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("Error switching '{0}' {1}", item.Name, item.GetType().Name), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DeleteServiceItems(ServiceProviderItem[] items)
|
||||
{
|
||||
foreach (ServiceProviderItem item in items)
|
||||
{
|
||||
if (item is FtpAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
// delete FTP account from default FTP site
|
||||
DeleteAccount(item.Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(ServiceProviderItem[] items, DateTime since)
|
||||
{
|
||||
ServiceProviderItemBandwidth[] itemsBandwidth = new ServiceProviderItemBandwidth[items.Length];
|
||||
|
||||
// calculate bandwidth for Default FTP Site
|
||||
FtpSite ftpSite = GetSite(SiteId);
|
||||
string siteId = String.Concat("FTPSVC", ftpSite[FtpSite.MSFTP7_SITE_ID]);
|
||||
string logsPath = Path.Combine(ftpSite.LogFileDirectory, siteId);
|
||||
|
||||
// create parser object
|
||||
// and update statistics
|
||||
LogParser parser = new LogParser("Ftp", siteId, logsPath, "s-sitename", "cs-username");
|
||||
// Subscribe to the events because FTP 7.0 has several differences that should be taken into account
|
||||
// and processed in a specific way
|
||||
parser.ProcessKeyFields += new ProcessKeyFieldsEventHandler(LogParser_ProcessKeyFields);
|
||||
parser.CalculateStatisticsLine += new CalculateStatsLineEventHandler(LogParser_CalculateStatisticsLine);
|
||||
//
|
||||
parser.ParseLogs();
|
||||
|
||||
// update items with diskspace
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
ServiceProviderItem item = items[i];
|
||||
|
||||
// create new bandwidth object
|
||||
itemsBandwidth[i] = new ServiceProviderItemBandwidth();
|
||||
itemsBandwidth[i].ItemId = item.Id;
|
||||
itemsBandwidth[i].Days = new DailyStatistics[0];
|
||||
|
||||
if (item is FtpAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
// get daily statistics
|
||||
itemsBandwidth[i].Days = parser.GetDailyStatistics(since, new string[] { siteId, item.Name });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemsBandwidth;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LogParser event handlers and helper routines
|
||||
|
||||
private bool IsFtpServiceCommand(string command)
|
||||
{
|
||||
return (Array.IndexOf(FTP70_SERVICE_CMD_LIST, command) > -1);
|
||||
}
|
||||
|
||||
private void LogParser_ProcessKeyFields(string[] key_fields, string[] key_values, string[] log_fields,
|
||||
string[] log_values)
|
||||
{
|
||||
int cs_method = Array.IndexOf(log_fields, "cs-method");
|
||||
int cs_uri_stem = Array.IndexOf(log_fields, "cs-uri-stem");
|
||||
int cs_username = Array.IndexOf(key_fields, "cs-username");
|
||||
//
|
||||
if (cs_username > -1)
|
||||
{
|
||||
string valueStr = EMPTY_LOG_FIELD;
|
||||
// this trick allows to calculate USER command bytes as well
|
||||
// in spite that "cs-username" field is empty for the command
|
||||
if (key_values[cs_username] != EMPTY_LOG_FIELD)
|
||||
valueStr = key_values[cs_username];
|
||||
else if (cs_method > -1 && cs_uri_stem > -1 && log_values[cs_method] == "USER")
|
||||
valueStr = log_values[cs_uri_stem];
|
||||
//
|
||||
key_values[cs_username] = valueStr.Substring(valueStr.IndexOf(@"\") + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogParser_CalculateStatisticsLine(StatsLine line, string[] fields, string[] values)
|
||||
{
|
||||
int cs_method = Array.IndexOf(fields, "cs-method");
|
||||
// bandwidth calculation ignores FTP 7.0 serviced commands
|
||||
if (cs_method > -1 && !IsFtpServiceCommand(values[cs_method]))
|
||||
{
|
||||
int cs_bytes = Array.IndexOf(fields, "cs-bytes");
|
||||
int sc_bytes = Array.IndexOf(fields, "sc-bytes");
|
||||
// skip empty cs-bytes value processing
|
||||
if (cs_bytes > -1 && values[cs_bytes] != "0")
|
||||
line.BytesReceived += Int64.Parse(values[cs_bytes]);
|
||||
// skip empty sc-bytes value processing
|
||||
if (sc_bytes > -1 && values[sc_bytes] != "0")
|
||||
line.BytesSent += Int64.Parse(values[sc_bytes]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected bool IsMsFTPInstalled()
|
||||
{
|
||||
int value = 0;
|
||||
RegistryKey root = Registry.LocalMachine;
|
||||
RegistryKey rk = root.OpenSubKey("SOFTWARE\\Microsoft\\InetStp");
|
||||
if (rk != null)
|
||||
{
|
||||
value = (int)rk.GetValue("MajorVersion", null);
|
||||
rk.Close();
|
||||
}
|
||||
|
||||
RegistryKey ftp = root.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\ftpsvc");
|
||||
bool res = value == 7 && ftp != null;
|
||||
if (ftp != null)
|
||||
ftp.Close();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public override bool IsInstalled()
|
||||
{
|
||||
return IsMsFTPInstalled();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebsitePanel.Providers.FTP.IIs70")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("WebsitePanel.Providers.FTP.IIs70")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("237c80af-034d-4a0b-bac6-56f655d9ed0d")]
|
|
@ -0,0 +1,244 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70
|
||||
{
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using Microsoft.Web.Administration;
|
||||
using Microsoft.Web.Management.Ftp;
|
||||
using Microsoft.Web.Management.Ftp.Configuration;
|
||||
using Microsoft.Web.Management.Server;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
internal class SitesHelper
|
||||
{
|
||||
public const string FtpProtocol = "ftp";
|
||||
|
||||
public static void DeserializeFtpSiteProperties(FtpSite ftpSite, PropertyBag bag)
|
||||
{
|
||||
foreach (int num in bag.ModifiedKeys)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case FtpSiteGlobals.Connections_UnauthenticatedTimeout:
|
||||
ftpSite.Connections.UnauthenticatedTimeout = (int)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_ControlChannelTimeout:
|
||||
ftpSite.Connections.ControlChannelTimeout = (int)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_DisableSocketPooling:
|
||||
ftpSite.Connections.DisableSocketPooling = (bool)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_ServerListenBacklog:
|
||||
ftpSite.Connections.ServerListenBacklog = (int)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_DataChannelTimeout:
|
||||
ftpSite.Connections.DataChannelTimeout = (int)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_MinBytesPerSecond:
|
||||
ftpSite.Connections.MinBytesPerSecond = (int)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_MaxConnections:
|
||||
ftpSite.Connections.MaxConnections = (long)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Connections_ResetOnMaxConnection:
|
||||
ftpSite.Connections.ResetOnMaxConnections = (bool)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Ssl_ServerCertHash:
|
||||
ftpSite.Security.Ssl.ServerCertHash = (string)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Ssl_ControlChannelPolicy:
|
||||
ftpSite.Security.Ssl.ControlChannelPolicy = (ControlChannelPolicy)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Ssl_DataChannelPolicy:
|
||||
ftpSite.Security.Ssl.DataChannelPolicy = (DataChannelPolicy)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Authentication_AnonymousEnabled:
|
||||
ftpSite.Security.Authentication.AnonymousAuthentication.Enabled = (bool)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.Authentication_BasicEnabled:
|
||||
ftpSite.Security.Authentication.BasicAuthentication.Enabled = (bool)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.FtpSite_AutoStart:
|
||||
ftpSite.ServerAutoStart = (bool)bag[num];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeserializeSiteProperties(Site site, PropertyBag bag)
|
||||
{
|
||||
foreach (int num in bag.ModifiedKeys)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case FtpSiteGlobals.Site_Name:
|
||||
string str = (string) bag[num];
|
||||
site.Name = str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Application element = site.Applications["/"];
|
||||
if (element == null)
|
||||
{
|
||||
element = site.Applications.CreateElement();
|
||||
element.Path = "/";
|
||||
site.Applications.Add(element);
|
||||
}
|
||||
VirtualDirectory directory = element.VirtualDirectories["/"];
|
||||
if (directory == null)
|
||||
{
|
||||
directory = element.VirtualDirectories.CreateElement();
|
||||
directory.Path = "/";
|
||||
element.VirtualDirectories.Add(directory);
|
||||
}
|
||||
DeserializeVirtualDirectoryProperties(directory, bag);
|
||||
DeserializeFtpSiteProperties(FtpHelper.GetFtpSiteElement(site), bag);
|
||||
}
|
||||
|
||||
public static void DeserializeVirtualDirectoryProperties(VirtualDirectory vDir, PropertyBag bag)
|
||||
{
|
||||
foreach (int num in bag.ModifiedKeys)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case FtpSiteGlobals.VirtualDirectory_PhysicalPath:
|
||||
vDir.PhysicalPath = (string)bag[num];
|
||||
break;
|
||||
case FtpSiteGlobals.VirtualDirectory_UserName:
|
||||
if (PasswordExistsAndSet(bag))
|
||||
{
|
||||
string str2 = (string)bag[num];
|
||||
if (!String.IsNullOrEmpty(str2))
|
||||
vDir.UserName = str2;
|
||||
}
|
||||
break;
|
||||
case FtpSiteGlobals.VirtualDirectory_Password:
|
||||
if (PasswordExistsAndSet(bag))
|
||||
{
|
||||
string str3 = (string)bag[FtpSiteGlobals.VirtualDirectory_Password];
|
||||
if (String.IsNullOrEmpty(str3))
|
||||
goto PASS_DELETE;
|
||||
//
|
||||
vDir.Password = str3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
vDir.UserName = string.Empty;
|
||||
PASS_DELETE:
|
||||
vDir.GetAttribute("password").Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList GetAllBindings(BindingCollection bindings)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
int num = 0;
|
||||
foreach (Binding binding in bindings)
|
||||
{
|
||||
PropertyBag bag = new PropertyBag();
|
||||
bag[FtpSiteGlobals.BindingProtocol] = binding.Protocol;
|
||||
bag[FtpSiteGlobals.BindingInformation] = binding.BindingInformation;
|
||||
bag[FtpSiteGlobals.BindingIndex] = num;
|
||||
list.Add(bag);
|
||||
num++;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList GetFtpBindings(BindingCollection bindings)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
foreach (Binding binding in bindings)
|
||||
{
|
||||
if (string.Equals(binding.Protocol.Trim(), "ftp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
list.Add(binding.BindingInformation);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static bool PasswordExistsAndSet(PropertyBag bag)
|
||||
{
|
||||
return (bag.Contains(FtpSiteGlobals.VirtualDirectory_Password_Set) && ((bool)bag[FtpSiteGlobals.VirtualDirectory_Password_Set]));
|
||||
}
|
||||
|
||||
public static void SerializeFtpSiteProperties(FtpSite ftpSite, PropertyBag bag)
|
||||
{
|
||||
bag[FtpSiteGlobals.FtpSite_AutoStart] = ftpSite.ServerAutoStart;
|
||||
bag[FtpSiteGlobals.Connections_UnauthenticatedTimeout] = ftpSite.Connections.UnauthenticatedTimeout;
|
||||
bag[FtpSiteGlobals.Connections_ControlChannelTimeout] = ftpSite.Connections.ControlChannelTimeout;
|
||||
bag[FtpSiteGlobals.Connections_DisableSocketPooling] = ftpSite.Connections.DisableSocketPooling;
|
||||
bag[FtpSiteGlobals.Connections_ServerListenBacklog] = ftpSite.Connections.ServerListenBacklog;
|
||||
bag[FtpSiteGlobals.Connections_DataChannelTimeout] = ftpSite.Connections.DataChannelTimeout;
|
||||
bag[FtpSiteGlobals.Connections_MinBytesPerSecond] = ftpSite.Connections.MinBytesPerSecond;
|
||||
bag[FtpSiteGlobals.Connections_MaxConnections] = ftpSite.Connections.MaxConnections;
|
||||
bag[FtpSiteGlobals.Connections_ResetOnMaxConnection] = ftpSite.Connections.ResetOnMaxConnections;
|
||||
bag[FtpSiteGlobals.Ssl_ServerCertHash] = ftpSite.Security.Ssl.ServerCertHash;
|
||||
bag[FtpSiteGlobals.Ssl_ControlChannelPolicy] = (int)ftpSite.Security.Ssl.ControlChannelPolicy;
|
||||
bag[FtpSiteGlobals.Ssl_DataChannelPolicy] = (int)ftpSite.Security.Ssl.DataChannelPolicy;
|
||||
bag[FtpSiteGlobals.Ssl_Ssl128] = ftpSite.Security.Ssl.Ssl128;
|
||||
bag[FtpSiteGlobals.Authentication_AnonymousEnabled] = ftpSite.Security.Authentication.AnonymousAuthentication.Enabled;
|
||||
bag[FtpSiteGlobals.Authentication_BasicEnabled] = ftpSite.Security.Authentication.BasicAuthentication.Enabled;
|
||||
}
|
||||
|
||||
public static PropertyBag SerializeSite(Site site)
|
||||
{
|
||||
PropertyBag bag = new PropertyBag();
|
||||
bag[FtpSiteGlobals.Site_Name] = site.Name;
|
||||
bag[FtpSiteGlobals.Site_ID] = site.Id;
|
||||
Application application = site.Applications["/"];
|
||||
bag[FtpSiteGlobals.VirtualDirectory_PhysicalPath] = string.Empty;
|
||||
if (application != null)
|
||||
{
|
||||
VirtualDirectory directory = application.VirtualDirectories["/"];
|
||||
if (directory != null)
|
||||
{
|
||||
bag[FtpSiteGlobals.VirtualDirectory_PhysicalPath] = directory.PhysicalPath;
|
||||
bag[FtpSiteGlobals.VirtualDirectory_UserName] = directory.UserName;
|
||||
bag[FtpSiteGlobals.VirtualDirectory_Password] = directory.Password;
|
||||
}
|
||||
}
|
||||
bag[FtpSiteGlobals.Site_Bindings] = GetFtpBindings(site.Bindings);
|
||||
FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);
|
||||
bag[FtpSiteGlobals.FtpSite_Status] = (int)ftpSiteElement.State;
|
||||
return bag;
|
||||
}
|
||||
|
||||
public static PropertyBag SerializeSiteDefaults(ServerManager serverManager)
|
||||
{
|
||||
FtpSite ftpSiteDefaultElement = FtpHelper.GetFtpSiteDefaultElement(serverManager.SiteDefaults);
|
||||
PropertyBag bag = new PropertyBag(true);
|
||||
SerializeFtpSiteProperties(ftpSiteDefaultElement, bag);
|
||||
return bag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,854 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using WebsitePanel.Providers;
|
||||
using WebsitePanel.Providers.FTP;
|
||||
using WebsitePanel.Providers.Utils;
|
||||
using WebsitePanel.Server.Utils;
|
||||
|
||||
namespace WebsitePanel.Providers.FTP.IIs70
|
||||
{
|
||||
using Microsoft.Web.Administration;
|
||||
using Microsoft.Web.Management.Ftp;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Authorization;
|
||||
using WebsitePanel.Providers.FTP.IIs70.Config;
|
||||
using Microsoft.Web.Management.Server;
|
||||
using Microsoft.Web.Management.Utility;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
internal sealed class SitesModuleService : IDisposable
|
||||
{
|
||||
private ServerManager ServerManager;
|
||||
|
||||
public SitesModuleService()
|
||||
{
|
||||
ServerManager = new ServerManager();
|
||||
}
|
||||
|
||||
#region Helper routines
|
||||
private void AddAuthorizationRules(string siteName, PropertyBag authBag)
|
||||
{
|
||||
PermissionsFlags permissions = (PermissionsFlags) authBag[3];
|
||||
string str = (string) authBag[1];
|
||||
string str2 = (string) authBag[2];
|
||||
AuthorizationRuleCollection authorizationRuleCollection = this.GetAuthorizationRuleCollection(siteName);
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
authorizationRuleCollection.Add(AuthorizationRuleAccessType.Allow, str, string.Empty, permissions);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(str2))
|
||||
{
|
||||
authorizationRuleCollection.Add(AuthorizationRuleAccessType.Allow, string.Empty, str2, permissions);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets authorization collection for a given site.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get authorization collection for.</param>
|
||||
/// <returns>Authorization collection.</returns>
|
||||
public AuthorizationRuleCollection GetAuthorizationRuleCollection(string siteName)
|
||||
{
|
||||
AuthorizationSection section = (AuthorizationSection)FtpHelper.GetAppHostSection(ServerManager, "system.ftpServer/security/authorization", typeof(AuthorizationSection), ManagementConfigurationPath.CreateSiteConfigurationPath(siteName));
|
||||
AuthorizationRuleCollection rules = section.Rules;
|
||||
if (rules == null)
|
||||
throw new Exception("ConfigurationError");
|
||||
return rules;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes authorization collection for a given site.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get authorization collection for.</param>
|
||||
/// <returns>Authorization collection.</returns>
|
||||
public void RemoveFtpAccountAuthSection(string accountPath)
|
||||
{
|
||||
//
|
||||
Configuration config = ServerManager.GetApplicationHostConfiguration();
|
||||
//
|
||||
config.RemoveLocationPath(accountPath);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void AddSite(PropertyBag bag)
|
||||
{
|
||||
// ensure bag not empty
|
||||
if (bag == null)
|
||||
throw new ArgumentNullException("bag");
|
||||
|
||||
// ensure site not exists
|
||||
string name = (string)bag[FtpSiteGlobals.Site_Name];
|
||||
if (ServerManager.Sites[name] != null)
|
||||
throw new Exception("SiteAlreadyExistsExceptionError");
|
||||
|
||||
// ensure site path
|
||||
string directory = (string)bag[FtpSiteGlobals.VirtualDirectory_PhysicalPath];
|
||||
if (!Directory.Exists(FileUtils.EvaluateSystemVariables(directory)))
|
||||
throw new Exception("SiteDirectoryDoesNotExistExceptionError");
|
||||
|
||||
// ensure site binding
|
||||
PropertyBag bag2 = (PropertyBag) bag[FtpSiteGlobals.Site_SingleBinding];
|
||||
if (bag2 == null)
|
||||
throw new ArgumentNullException("bindingBag");
|
||||
|
||||
string bindingInformation = (string)bag2[FtpSiteGlobals.BindingInformation];
|
||||
|
||||
SitesHelper.DeserializeSiteProperties(ServerManager.Sites.Add(name, "ftp", bindingInformation, directory), bag);
|
||||
// authorization
|
||||
PropertyBag authBag = (PropertyBag)bag[FtpSiteGlobals.Authorization_Rule];
|
||||
if (authBag != null)
|
||||
AddAuthorizationRules(name, authBag);
|
||||
|
||||
ServerManager.CommitChanges();
|
||||
Site site = ServerManager.Sites[name];
|
||||
try
|
||||
{
|
||||
FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);
|
||||
//
|
||||
if (ftpSiteElement.ServerAutoStart)
|
||||
ftpSiteElement.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList AddSiteBinding(string siteName, PropertyBag bindingBag)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException("siteName");
|
||||
}
|
||||
if (bindingBag == null)
|
||||
{
|
||||
throw new ArgumentNullException("bindingBag");
|
||||
}
|
||||
//
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistCannotAddBindingExceptionError");
|
||||
|
||||
string bindingProtocol = (string) bindingBag[0];
|
||||
string bindingInformation = (string) bindingBag[1];
|
||||
site.Bindings.Add(bindingInformation, bindingProtocol);
|
||||
ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings);
|
||||
|
||||
ServerManager.CommitChanges();
|
||||
|
||||
return allBindings;
|
||||
}
|
||||
|
||||
public ArrayList EditSiteBinding(string siteName, PropertyBag originalBindingBag, PropertyBag newBindingBag)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException("siteName");
|
||||
}
|
||||
if (originalBindingBag == null)
|
||||
{
|
||||
throw new ArgumentNullException("originalBindingBag");
|
||||
}
|
||||
if (newBindingBag == null)
|
||||
{
|
||||
throw new ArgumentNullException("newBindingBag");
|
||||
}
|
||||
//
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistCannotEditBindingExceptionError");
|
||||
|
||||
string b = (string) originalBindingBag[1];
|
||||
int num = (int) originalBindingBag[2];
|
||||
string str2 = (string) newBindingBag[1];
|
||||
int num2 = 0;
|
||||
bool flag = false;
|
||||
foreach (Binding binding in site.Bindings)
|
||||
{
|
||||
if (((num == num2) && string.Equals(binding.Protocol, "ftp", StringComparison.OrdinalIgnoreCase)) && string.Equals(binding.BindingInformation, b, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
binding.BindingInformation = str2;
|
||||
flag = true;
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (!flag)
|
||||
throw new Exception("SitesBindingDoesNotExistCannotEditBindingExceptionError");
|
||||
ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings);
|
||||
|
||||
ServerManager.CommitChanges();
|
||||
|
||||
return allBindings;
|
||||
}
|
||||
|
||||
public void EditSiteDefaults(PropertyBag bag)
|
||||
{
|
||||
if (bag == null)
|
||||
{
|
||||
throw new ArgumentNullException("bag");
|
||||
}
|
||||
SitesHelper.DeserializeFtpSiteProperties(FtpHelper.GetFtpSiteDefaultElement(ServerManager.SiteDefaults), bag);
|
||||
ServerManager.CommitChanges();
|
||||
}
|
||||
|
||||
public PropertyBag EditSiteProperties(PropertyBag bag)
|
||||
{
|
||||
if (bag == null)
|
||||
{
|
||||
throw new ArgumentNullException("bag");
|
||||
}
|
||||
string siteName = (string) bag[100];
|
||||
PropertyBag bindingBag = (PropertyBag) bag[0x68];
|
||||
if (bindingBag != null)
|
||||
{
|
||||
this.AddSiteBinding(siteName, bindingBag);
|
||||
}
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistCannotEditExceptionError");
|
||||
|
||||
SitesHelper.DeserializeSiteProperties(site, bag);
|
||||
PropertyBag authBag = (PropertyBag) bag[0x1a6];
|
||||
if (authBag != null)
|
||||
{
|
||||
this.AddAuthorizationRules(siteName, authBag);
|
||||
}
|
||||
//
|
||||
ServerManager.CommitChanges();
|
||||
//
|
||||
site = ServerManager.Sites[siteName];
|
||||
try
|
||||
{
|
||||
FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);
|
||||
if (ftpSiteElement.ServerAutoStart)
|
||||
{
|
||||
ftpSiteElement.Start();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return SitesHelper.SerializeSite(site);
|
||||
}
|
||||
|
||||
public ArrayList GetCertificates()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
X509Store store = null;
|
||||
try
|
||||
{
|
||||
store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
||||
store.Open(OpenFlags.OpenExistingOnly);
|
||||
foreach (X509Certificate2 certificate in store.Certificates)
|
||||
{
|
||||
if (FtpHelper.CanAuthenticateServer(certificate) && certificate.HasPrivateKey)
|
||||
{
|
||||
PropertyBag bag = new PropertyBag();
|
||||
bag[0] = certificate.FriendlyName;
|
||||
bag[1] = certificate.GetCertHashString();
|
||||
bag[2] = FtpHelper.ConvertDistinguishedNameToString(certificate.IssuerName);
|
||||
list.Add(bag);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
store.Close();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public PropertyBag GetSite(string siteName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException(siteName);
|
||||
}
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistExceptionError");
|
||||
|
||||
return SitesHelper.SerializeSite(site);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PropertyBag GetSiteDefaults()
|
||||
{
|
||||
return SitesHelper.SerializeSiteDefaults(ManagementUnit.ReadOnlyServerManager);
|
||||
}
|
||||
|
||||
public PropertyBag GetSiteProperties(string siteName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException(siteName);
|
||||
}
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistExceptionError");
|
||||
|
||||
PropertyBag bag = SitesHelper.SerializeSite(site);
|
||||
SitesHelper.SerializeFtpSiteProperties(FtpHelper.GetFtpSiteElement(site), bag);
|
||||
return bag;
|
||||
}
|
||||
|
||||
public ArrayList RemoveSiteBinding(string siteName, PropertyBag bindingBag)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException("siteName");
|
||||
}
|
||||
if (bindingBag == null)
|
||||
{
|
||||
throw new ArgumentNullException("bindingBag");
|
||||
}
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
if (site == null)
|
||||
throw new Exception("SiteDoesNotExistCannotRemoveBindingExceptionError");
|
||||
|
||||
string b = (string) bindingBag[1];
|
||||
int num = (int) bindingBag[2];
|
||||
int num2 = 0;
|
||||
Binding element = null;
|
||||
foreach (Binding binding2 in site.Bindings)
|
||||
{
|
||||
if (((num == num2) && string.Equals(binding2.Protocol, "ftp", StringComparison.OrdinalIgnoreCase)) && string.Equals(binding2.BindingInformation, b, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
binding2.BindingInformation = b;
|
||||
element = binding2;
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (element == null)
|
||||
throw new Exception("SitesBindingDoesNotExistCannotRemoveBindingExceptionError");
|
||||
|
||||
site.Bindings.Remove(element);
|
||||
ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings);
|
||||
//
|
||||
ServerManager.CommitChanges();
|
||||
|
||||
return allBindings;
|
||||
}
|
||||
|
||||
public void CommitChanges()
|
||||
{
|
||||
this.ServerManager.CommitChanges();
|
||||
this.ServerManager.Dispose();
|
||||
this.ServerManager = new ServerManager();
|
||||
}
|
||||
|
||||
public void DeleteFtpAccount(string siteName, string virtualDirectory)
|
||||
{
|
||||
// Ensure virtual directory is in correct format
|
||||
if (!virtualDirectory.StartsWith("/"))
|
||||
virtualDirectory = String.Concat("/", virtualDirectory);
|
||||
//
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site != null)
|
||||
{
|
||||
Application application = site.Applications["/"];
|
||||
if (application != null)
|
||||
{
|
||||
VirtualDirectory directory = application.VirtualDirectories[virtualDirectory];
|
||||
if (directory != null)
|
||||
{
|
||||
RemoveFtpAccountAuthSection(String.Format("{0}{1}", siteName, virtualDirectory));
|
||||
//
|
||||
application.VirtualDirectories.Remove(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
this.CommitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes virtual directory with given name under site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name that owns virtual directory.</param>
|
||||
/// <param name="virtualDirectory">Virtual direcotry's name to be deleted.</param>
|
||||
public void DeleteVirtualDirectory(string siteName, string virtualDirectory)
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site != null)
|
||||
{
|
||||
Application application = site.Applications["/"];
|
||||
if (application != null)
|
||||
|
||||
{
|
||||
VirtualDirectory directory = application.VirtualDirectories[virtualDirectory];
|
||||
if (directory != null)
|
||||
{
|
||||
application.VirtualDirectories.Remove(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.CommitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures connect as feature for supplied directory with specified user name and password.
|
||||
/// </summary>
|
||||
/// <param name="physicalPath">Physical path to impriove performance.</param>
|
||||
/// <param name="siteName">Site's id that owns the directory.</param>
|
||||
/// <param name="directoryName">Directory to configure connect as for.</param>
|
||||
/// <param name="username">User name.</param>
|
||||
/// <param name="password">Password.</param>
|
||||
/// <param name="commit">A value which shows whether changes should be commited.</param>
|
||||
public void ConfigureConnectAs(string physicalPath, string siteName, string directoryName,
|
||||
string username, string password, bool commit)
|
||||
{
|
||||
if (physicalPath.StartsWith(@"\\")
|
||||
&& !String.IsNullOrEmpty(username)
|
||||
&& !String.IsNullOrEmpty(password))
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site != null)
|
||||
{
|
||||
//
|
||||
Application application = site.Applications["/"];
|
||||
if (application != null)
|
||||
{
|
||||
VirtualDirectory accountDirectory = application.VirtualDirectories[directoryName];
|
||||
if (accountDirectory != null)
|
||||
{
|
||||
accountDirectory.UserName = username;
|
||||
accountDirectory.Password = password;
|
||||
if (commit)
|
||||
{
|
||||
this.CommitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates virtual directory under site with given name and sets authorization rules.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site name.</param>
|
||||
/// <param name="account">Account information.</param>
|
||||
public void CreateFtpAccount(string siteName, FtpAccount account)
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site !=null)
|
||||
{
|
||||
Application application = site.Applications["/"];
|
||||
if (application != null)
|
||||
{
|
||||
var ftpVirtualDir = String.Format("/{0}", account.Name);
|
||||
//
|
||||
VirtualDirectory accountDirectory = application.VirtualDirectories[ftpVirtualDir];
|
||||
//
|
||||
if (accountDirectory != null)
|
||||
{
|
||||
application.VirtualDirectories.Remove(accountDirectory);
|
||||
}
|
||||
VirtualDirectory createdVirtualDirectory = application.VirtualDirectories.Add(ftpVirtualDir, account.Folder);
|
||||
|
||||
|
||||
AuthorizationRuleCollection authRulesCollection = this.GetAuthorizationRuleCollection(String.Format("{0}/{1}", siteName, account.Name));
|
||||
List<AuthorizationRule> rulesToRemove = new List<AuthorizationRule>();
|
||||
foreach (AuthorizationRule rule in authRulesCollection)
|
||||
{
|
||||
if (rule.AccessType == AuthorizationRuleAccessType.Allow && (rule.Users == "?" || rule.Users == "*"))
|
||||
{
|
||||
rulesToRemove.Add(rule);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(AuthorizationRule rule in rulesToRemove)
|
||||
{
|
||||
authRulesCollection.Remove(rule);
|
||||
}
|
||||
|
||||
PermissionsFlags permissions = 0;
|
||||
if (account.CanRead)
|
||||
{
|
||||
permissions |= PermissionsFlags.Read;
|
||||
}
|
||||
if (account.CanWrite)
|
||||
{
|
||||
permissions |= PermissionsFlags.Write;
|
||||
}
|
||||
if (account.CanRead || account.CanWrite)
|
||||
{
|
||||
authRulesCollection.Add(AuthorizationRuleAccessType.Allow, account.Name, String.Empty, permissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.CommitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of virtual directories under site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site name under which to look for virtual directories.</param>
|
||||
/// <returns>List of virtual directories under site with given name.</returns>
|
||||
public IEnumerable<string> GetVirtualDirectoriesNames(string siteName)
|
||||
{
|
||||
List<string> virtualDirectoriesNames = new List<string>();
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site !=null)
|
||||
{
|
||||
Application application = site.Applications["/"];
|
||||
if (application != null)
|
||||
{
|
||||
foreach(VirtualDirectory directory in application.VirtualDirectories)
|
||||
{
|
||||
virtualDirectoriesNames.Add(directory.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return virtualDirectoriesNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether virtual directory under given site exists.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site name.</param>
|
||||
/// <param name="virtualDirectory">Virtual directory.</param>
|
||||
/// <returns>true - if exists; false - otherwise.</returns>
|
||||
public bool VirtualDirectoryExists(string siteName, string virtualDirectory)
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Application application = site.Applications["/"];
|
||||
if (application == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
VirtualDirectory directory = virtualDirectory.StartsWith("/")
|
||||
? application.VirtualDirectories[virtualDirectory] : application.VirtualDirectories["/" + virtualDirectory];
|
||||
if (directory == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets names of all ftp sites.
|
||||
/// </summary>
|
||||
/// <returns>Names of all ftp sites.</returns>
|
||||
public IEnumerable<string> GetSitesNames()
|
||||
{
|
||||
List<string> ftpSiteNames = new List<string>();
|
||||
// Add only ftp sites.
|
||||
foreach(Site site in this.ServerManager.Sites)
|
||||
{
|
||||
if (this.GetSiteBindings(site.Name).Length > 0)
|
||||
{
|
||||
ftpSiteNames.Add(site.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return ftpSiteNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets physical path of the ftp site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get physical path for.</param>
|
||||
/// <param name="virtualDirectory">Virtual directory name.</param>
|
||||
/// <returns>physical path of the ftp site with given name.</returns>
|
||||
public string GetSitePhysicalPath(string siteName, string virtualDirectory)
|
||||
{
|
||||
if (this.SiteExists(siteName))
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site == null)
|
||||
{
|
||||
throw new ArgumentException("Site with given name doesn't exist.", "siteName");
|
||||
}
|
||||
Application application = site.Applications["/"];
|
||||
if (application == null)
|
||||
{
|
||||
throw new InvalidOperationException("Site with given name doesn't have root application.");
|
||||
}
|
||||
VirtualDirectory directory = application.VirtualDirectories[virtualDirectory];
|
||||
if (directory == null)
|
||||
{
|
||||
throw new InvalidOperationException("Site with given name doesn't have root virtual directory.");
|
||||
}
|
||||
return directory.PhysicalPath;
|
||||
}
|
||||
throw new ArgumentException("Site with given name doesn't exist.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets physical path of the ftp site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get physical path for.</param>
|
||||
/// <param name="virtualDirectory">Virtual directory name.</param>
|
||||
/// <param name="physicalPath">New physical path.</param>
|
||||
public void SetSitePhysicalPath(string siteName, string virtualDirectory, string physicalPath)
|
||||
{
|
||||
if (this.SiteExists(siteName))
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site == null)
|
||||
{
|
||||
throw new ArgumentException("Site with given name doesn't exist.", "siteName");
|
||||
}
|
||||
Application application = site.Applications["/"];
|
||||
if (application == null)
|
||||
{
|
||||
throw new InvalidOperationException("Site with given name doesn't have root application.");
|
||||
}
|
||||
VirtualDirectory directory = application.VirtualDirectories[virtualDirectory];
|
||||
if (directory == null)
|
||||
{
|
||||
throw new InvalidOperationException("Site with given name doesn't have root virtual directory.");
|
||||
}
|
||||
directory.PhysicalPath = physicalPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets ftp site bindings.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get bindings for.</param>
|
||||
/// <returns>Ftp site bindings.</returns>
|
||||
/// <remarks>Site name must contain only default ftp site name.</remarks>
|
||||
public ServerBinding[] GetSiteBindings(string siteName)
|
||||
{
|
||||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
if (this.SiteExists(siteName))
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
foreach (Binding binding in site.Bindings)
|
||||
{
|
||||
// Add only ftp bindings
|
||||
if (string.Equals(binding.Protocol, "ftp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string[] parts = binding.BindingInformation.Split(':');
|
||||
bindings.Add(new ServerBinding(parts[0], parts[1], parts[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Site doesn't exist.");
|
||||
}
|
||||
return bindings.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets ftp site bindings.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to set bindings for.</param>
|
||||
/// <param name="bindings">Ftp bindings to set.</param>
|
||||
public void SetSiteBindings(string siteName, ServerBinding[] bindings)
|
||||
{
|
||||
if (this.SiteExists(siteName))
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
List<Binding> originalBindingsToRemove = new List<Binding>();
|
||||
foreach (Binding binding in site.Bindings)
|
||||
{
|
||||
if (string.Equals(binding.Protocol, "ftp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
originalBindingsToRemove.Add(binding);
|
||||
}
|
||||
}
|
||||
// Remove all ftp bindings.
|
||||
foreach (Binding binding in originalBindingsToRemove)
|
||||
{
|
||||
site.Bindings.Remove(binding);
|
||||
}
|
||||
// Add new ones.
|
||||
foreach(ServerBinding binding in bindings)
|
||||
{
|
||||
site.Bindings.Add(binding.ToString(), "ftp");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Site doesn't exist.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether site with given name exists.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to check.</param>
|
||||
/// <returns>true - if it exists; false - otherwise.</returns>
|
||||
public bool SiteExists(string siteName)
|
||||
{
|
||||
return this.VirtualDirectoryExists(siteName, "/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes site with specified name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to be deleted.</param>
|
||||
public void DeleteSite(string siteName)
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site != null)
|
||||
{
|
||||
this.ServerManager.Sites.Remove(site);
|
||||
this.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets state of the site with sepcified name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to get state for.</param>
|
||||
/// <returns>Site's state.</returns>
|
||||
public ServerState GetSiteState(string siteName)
|
||||
{
|
||||
FtpSite ftpSite = GetIisFtpSite(siteName);
|
||||
if (ftpSite == null)
|
||||
{
|
||||
return ServerState.Unknown;
|
||||
}
|
||||
return ConvertSiteStateToServerState(ftpSite.State);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to start.</param>
|
||||
/// <returns>New site's name.</returns>
|
||||
public int StartSite(string siteName)
|
||||
{
|
||||
Site ftpSiteElement = this.GetIisSite(siteName);
|
||||
if (ftpSiteElement == null)
|
||||
{
|
||||
return (int)SiteState.Unknown;
|
||||
}
|
||||
ftpSiteElement.Start();
|
||||
return (int) ftpSiteElement.State;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name to stop.</param>
|
||||
/// <returns>New site's name.</returns>
|
||||
public int StopSite(string siteName)
|
||||
{
|
||||
Site ftpSiteElement = this.GetIisSite(siteName);
|
||||
if (ftpSiteElement == null)
|
||||
{
|
||||
return (int)SiteState.Unknown;
|
||||
}
|
||||
ftpSiteElement.Stop();
|
||||
return (int) ftpSiteElement.State;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets ftp site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name.</param>
|
||||
/// <returns>Ftp site.</returns>
|
||||
public FtpSite GetIisFtpSite(string siteName)
|
||||
{
|
||||
Site site = this.GetIisSite(siteName);
|
||||
if (site == null)
|
||||
{
|
||||
throw new ArgumentException("Site with given name doesn't exist.", "siteName");
|
||||
}
|
||||
FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site);
|
||||
ftpSiteElement.SiteServiceId = Convert.ToString(site.Id);
|
||||
//
|
||||
return ftpSiteElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets site with given name.
|
||||
/// </summary>
|
||||
/// <param name="siteName">Site's name.</param>
|
||||
/// <returns>Iis site.</returns>
|
||||
public Site GetIisSite(string siteName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(siteName))
|
||||
{
|
||||
throw new ArgumentNullException("siteName");
|
||||
}
|
||||
Site site = ServerManager.Sites[siteName];
|
||||
return site;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts site state to server state.
|
||||
/// </summary>
|
||||
/// <param name="siteState">Site state to convert.</param>
|
||||
/// <returns>Server state.</returns>
|
||||
private static ServerState ConvertSiteStateToServerState(SiteState siteState)
|
||||
{
|
||||
switch(siteState)
|
||||
{
|
||||
case SiteState.Started:
|
||||
return ServerState.Started;
|
||||
case SiteState.Starting:
|
||||
return ServerState.Starting;
|
||||
case SiteState.Stopped:
|
||||
return ServerState.Stopped;
|
||||
case SiteState.Stopping:
|
||||
return ServerState.Stopping;
|
||||
default:
|
||||
return ServerState.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Disposes underlying resources explicitly.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (this.ServerManager != null)
|
||||
{
|
||||
this.ServerManager.Dispose();
|
||||
this.ServerManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A28BD694-C308-449F-8FD2-F08F3D54ABA0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WebsitePanel.Providers.FTP.IIs70</RootNamespace>
|
||||
<AssemblyName>WebsitePanel.Providers.FTP.IIs70</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Administration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Management, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Management.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Management.Ftp, Version=7.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Management.Ftp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Management.FtpClient, Version=7.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Management.FtpClient.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\VersionInfo.cs">
|
||||
<Link>VersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Authorization\AuthorizationGlobals.cs" />
|
||||
<Compile Include="Authorization\AuthorizationRule.cs" />
|
||||
<Compile Include="Authorization\AuthorizationRuleAccessType.cs" />
|
||||
<Compile Include="Authorization\AuthorizationRuleCollection.cs" />
|
||||
<Compile Include="Authorization\AuthorizationSection.cs" />
|
||||
<Compile Include="Configuration\ActiveDirectoryElement.cs" />
|
||||
<Compile Include="Configuration\AnonymousAuthenticationElement.cs" />
|
||||
<Compile Include="Configuration\AuthenticationElement.cs" />
|
||||
<Compile Include="Configuration\BasicAuthenticationElement.cs" />
|
||||
<Compile Include="Configuration\ConnectionsElement.cs" />
|
||||
<Compile Include="Configuration\ControlChannelPolicy.cs" />
|
||||
<Compile Include="Configuration\CustomAuthenticationElement.cs" />
|
||||
<Compile Include="Configuration\CustomAuthenticationProvider.cs" />
|
||||
<Compile Include="Configuration\CustomAuthenticationProviderCollection.cs" />
|
||||
<Compile Include="Configuration\DataChannelPolicy.cs" />
|
||||
<Compile Include="Configuration\DataChannelSecurityElement.cs" />
|
||||
<Compile Include="Configuration\DirectoryBrowseElement.cs" />
|
||||
<Compile Include="Configuration\FileHandlingElement.cs" />
|
||||
<Compile Include="Configuration\FirewallElement.cs" />
|
||||
<Compile Include="Configuration\FtpLogExtFileFlags.cs" />
|
||||
<Compile Include="Configuration\FtpProtocolElement.cs" />
|
||||
<Compile Include="Configuration\FtpSite.cs" />
|
||||
<Compile Include="Configuration\LogFileElement.cs" />
|
||||
<Compile Include="Configuration\LoggingElement.cs" />
|
||||
<Compile Include="Configuration\MessagesElement.cs" />
|
||||
<Compile Include="Configuration\Mode.cs" />
|
||||
<Compile Include="Configuration\PermissionsFlags.cs" />
|
||||
<Compile Include="Configuration\ProviderCollection.cs" />
|
||||
<Compile Include="Configuration\ProviderElement.cs" />
|
||||
<Compile Include="Configuration\SecurityElement.cs" />
|
||||
<Compile Include="Configuration\SelectiveLogging.cs" />
|
||||
<Compile Include="Configuration\SessionCollection.cs" />
|
||||
<Compile Include="Configuration\SessionElement.cs" />
|
||||
<Compile Include="Configuration\ShowFlags.cs" />
|
||||
<Compile Include="Configuration\SiteState.cs" />
|
||||
<Compile Include="Configuration\SslClientCertificatesElement.cs" />
|
||||
<Compile Include="Configuration\SslElement.cs" />
|
||||
<Compile Include="Configuration\UserIsolationElement.cs" />
|
||||
<Compile Include="Configuration\ValidationFlags.cs" />
|
||||
<Compile Include="FtpHelper.cs" />
|
||||
<Compile Include="FtpSiteGlobals.cs" />
|
||||
<Compile Include="MsFTP.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SitesHelper.cs" />
|
||||
<Compile Include="SitesModuleService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.Base\WebsitePanel.Providers.Base.csproj">
|
||||
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
|
||||
<Name>WebsitePanel.Providers.Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.Server.Utils\WebsitePanel.Server.Utils.csproj">
|
||||
<Project>{E91E52F3-9555-4D00-B577-2B1DBDD87CA7}</Project>
|
||||
<Name>WebsitePanel.Server.Utils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue