AD Integration enabled on the IIS7 provider. This will allow to store site

content on a remote (highly available) filesystem and enabled the scenario
of webfarm with a shared IIS configuration as well.

The netbios domain name will need to be set in the configuration of the provider.
and off course "Create Active Directory accounts" checked as well
This commit is contained in:
robvde 2012-07-12 18:14:40 +04:00
parent 43b73aee66
commit c1e2aa8477
8 changed files with 159 additions and 37 deletions

View file

@ -2715,6 +2715,12 @@ namespace WebsitePanel.EnterpriseServer
//
WebServer server = GetWebServer(item.ServiceId);
StringDictionary webSettings = ServerController.GetServiceSettings(item.ServiceId);
if (webSettings["WmSvc.NETBIOS"] != null)
{
accountName = webSettings["WmSvc.NETBIOS"].ToString() + "\\" + accountName;
}
//
if (server.CheckWebManagementAccountExists(accountName))
{

View file

@ -40,6 +40,8 @@ namespace WebsitePanel.Providers.OS
private string fullName;
private string description = "WebsitePanel system account";
private string password;
private string msIIS_FTPDir = "";
private string msIIS_FTPRoot = "";
private bool passwordCantChange;
private bool passwordNeverExpires;
private bool accountDisabled;
@ -98,5 +100,18 @@ namespace WebsitePanel.Providers.OS
get { return memberOf; }
set { memberOf = value; }
}
public string MsIIS_FTPDir
{
get { return msIIS_FTPDir; }
set { msIIS_FTPDir = value; }
}
public string MsIIS_FTPRoot
{
get { return msIIS_FTPRoot; }
set { msIIS_FTPRoot = value; }
}
}
}

View file

@ -325,6 +325,7 @@ namespace WebsitePanel.Providers.Web
public class WebManagementServiceSettings
{
public string Port { get; set; }
public string NETBIOS { get; set; }
public string ServiceUrl { get; set; }
public int RequiresWindowsCredentials { get; set; }
}
@ -3500,7 +3501,7 @@ namespace WebsitePanel.Providers.Web
bool adEnabled = ServerSettings.ADEnabled;
// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
// against the web server
ServerSettings.ADEnabled = false;
//ServerSettings.ADEnabled = false;
if (IdentityCredentialsMode == "IISMNGR")
{
@ -3521,7 +3522,7 @@ namespace WebsitePanel.Providers.Web
bool adEnabled = ServerSettings.ADEnabled;
// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
// against the web server
ServerSettings.ADEnabled = false;
//ServerSettings.ADEnabled = false;
//
ResultObject result = new ResultObject { IsSuccess = true };
@ -3556,7 +3557,7 @@ namespace WebsitePanel.Providers.Web
bool adEnabled = ServerSettings.ADEnabled;
// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
// against the web server
ServerSettings.ADEnabled = false;
//ServerSettings.ADEnabled = false;
//
string fqWebPath = String.Format("/{0}", siteName);
@ -3565,6 +3566,32 @@ namespace WebsitePanel.Providers.Web
Log.WriteInfo("Site Name: {0}; Account Name: {1}; Account Password: {2}; FqWebPath: {3};",
siteName, accountName, accountPassword, fqWebPath);
string contentPath = string.Empty;
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
WebSite site = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
//
contentPath = webObjectsSvc.GetPhysicalPath(srvman, site);
//
Log.WriteInfo("Site Content Path: {0};", contentPath);
}
string FTPRoot = string.Empty;
string FTPDir = string.Empty;
if (contentPath.IndexOf("\\\\") != -1)
{
string[] Tmp = contentPath.Split('\\');
FTPRoot = "\\\\" + Tmp[2] + "\\" + Tmp[3];
FTPDir = contentPath.Replace(FTPRoot, "");
}
//
string accountNameSid = string.Empty;
//
if (IdentityCredentialsMode == "IISMNGR")
{
@ -3583,38 +3610,31 @@ namespace WebsitePanel.Providers.Web
PasswordNeverExpires = true,
AccountDisabled = false,
Password = accountPassword,
System = true
System = true,
MsIIS_FTPDir = FTPDir,
MsIIS_FTPRoot = FTPRoot
},
ServerSettings,
String.Empty,
String.Empty);
UsersOU,
GroupsOU);
// Convert account name to the full-qualified one
accountName = GetFullQualifiedAccountName(accountName);
accountNameSid = GetFullQualifiedAccountNameSid(accountName);
//
Log.WriteInfo("FQ Account Name: {0};", accountName);
}
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
//
ManagementAuthorization.Grant(accountName, fqWebPath, false);
//
WebSite site = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
//
string contentPath = webObjectsSvc.GetPhysicalPath(srvman, site);
//
Log.WriteInfo("Site Content Path: {0};", contentPath);
//
if (IdentityCredentialsMode == "IISMNGR")
{
SecurityUtils.GrantNtfsPermissionsBySid(contentPath, SystemSID.LOCAL_SERVICE, permissions, true, true);
}
else
{
SecurityUtils.GrantNtfsPermissions(contentPath, accountName, permissions, true, true, ServerSettings, String.Empty, String.Empty);
}
// Restore setting back
ServerSettings.ADEnabled = adEnabled;
SecurityUtils.GrantNtfsPermissions(contentPath, accountNameSid, NTFSPermission.Modify, true, true, ServerSettings, UsersOU, GroupsOU);
}
}
@ -3625,7 +3645,7 @@ namespace WebsitePanel.Providers.Web
bool adEnabled = ServerSettings.ADEnabled;
// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
// against the web server
ServerSettings.ADEnabled = false;
//ServerSettings.ADEnabled = false;
// Trace input parameters
Log.WriteInfo("Account Name: {0}; Account Password: {1};", accountName, accountPassword);
@ -3653,7 +3673,7 @@ namespace WebsitePanel.Providers.Web
bool adEnabled = ServerSettings.ADEnabled;
// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
// against the web server
ServerSettings.ADEnabled = false;
//ServerSettings.ADEnabled = false;
//
string fqWebPath = String.Format("/{0}", siteName);
// Trace input parameters
@ -3676,11 +3696,20 @@ namespace WebsitePanel.Providers.Web
SecurityUtils.RemoveNtfsPermissionsBySid(contentPath, SystemSID.LOCAL_SERVICE);
}
else
{
if (adEnabled)
{
ManagementAuthorization.Revoke(GetFullQualifiedAccountName(accountName), fqWebPath);
SecurityUtils.RemoveNtfsPermissions(contentPath, accountName, ServerSettings, UsersOU, GroupsOU);
SecurityUtils.DeleteUser(accountName, ServerSettings, UsersOU);
}
else
{
ManagementAuthorization.Revoke(GetFullQualifiedAccountName(accountName), fqWebPath);
SecurityUtils.RemoveNtfsPermissions(contentPath, accountName, ServerSettings, String.Empty, String.Empty);
SecurityUtils.DeleteUser(accountName, ServerSettings, String.Empty);
}
}
// Restore setting back
ServerSettings.ADEnabled = adEnabled;
}
@ -3749,9 +3778,13 @@ namespace WebsitePanel.Providers.Web
// Retrieve account name
if (scopeCollection.Count > 0)
{
/*
iisObject.SetValue<string>(
WebSite.WmSvcAccountName,
GetNonQualifiedAccountName((String)scopeCollection[0]["name"]));
*/
iisObject.SetValue<string>(
WebSite.WmSvcAccountName, (String)scopeCollection[0]["name"]);
//
iisObject.SetValue<string>(
WebSite.WmSvcServiceUrl, ProviderSettings["WmSvc.ServiceUrl"]);
@ -3906,6 +3939,31 @@ namespace WebsitePanel.Providers.Web
return domainName != null ? domainName + "\\" + accountName : accountName;
}
protected string GetFullQualifiedAccountNameSid(string accountName)
{
//
if (!ServerSettings.ADEnabled)
return String.Format(@"{0}\{1}", Environment.MachineName, 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 SSL

View file

@ -507,6 +507,11 @@ namespace WebsitePanel.Providers.Utils
{
if (serverSettings.ADEnabled)
{
if (user.Name.IndexOf("\\") != -1)
{
string[] tmpStr = user.Name.Split('\\');
user.Name = tmpStr[1];
}
//check is user name less than 20 symbols
if (user.Name.Length > 20)
@ -538,6 +543,13 @@ namespace WebsitePanel.Providers.Utils
SetObjectProperty(objUser, "UserPrincipalName", user.Name);
SetObjectProperty(objUser, "sAMAccountName", user.Name);
SetObjectProperty(objUser, "UserPassword", user.Password);
if (user.MsIIS_FTPDir != string.Empty)
{
SetObjectProperty(objUser, "msIIS-FTPDir", user.MsIIS_FTPDir);
SetObjectProperty(objUser, "msIIS-FTPRoot", user.MsIIS_FTPRoot);
}
objUser.Properties["userAccountControl"].Value =
ADAccountOptions.UF_NORMAL_ACCOUNT | ADAccountOptions.UF_PASSWD_NOTREQD;
objUser.CommitChanges();

View file

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="lblADIntegration.Text" xml:space="preserve">
<value>Active Directory Integration:</value>
@ -246,4 +246,7 @@
<data name="ipAddress.SelectValueText" xml:space="preserve">
<value>&lt;All unassigned&gt;</value>
</data>
<data name="lblWmSvcNETBIOS.Text" xml:space="preserve">
<value>NETBIOS Domain name:</value>
</data>
</root>

View file

@ -312,6 +312,14 @@
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" meta:resourcekey="lblWmSvcNETBIOS" Text="NETBIOS Domain:"></asp:Label>
</td>
<td class="Normal">
<asp:TextBox runat="server" ID="txtWmSvcNETBIOS" CssClass="NormalTextBox" Width="70px" />
</td>
</tr>
</table>
</fieldset>

View file

@ -165,6 +165,7 @@ namespace WebsitePanel.Portal.ProviderControls
//
txtWmSvcServicePort.Text = settings["WmSvc.Port"];
txtWmSvcNETBIOS.Text = settings["WmSvc.NETBIOS"];
//
string wmsvcServiceUrl = settings["WmSvc.ServiceUrl"];
//
@ -235,6 +236,7 @@ namespace WebsitePanel.Portal.ProviderControls
settings["ProtectedGroupsFile"] = txtProtectedGroupsFile.Text.Trim();
settings["SecureFoldersModuleAssembly"] = txtSecureFoldersModuleAsm.Text.Trim();
settings["WmSvc.NETBIOS"] = txtWmSvcNETBIOS.Text.Trim();
settings["WmSvc.ServiceUrl"] = txtWmSvcServiceUrl.Text.Trim();
settings["WmSvc.Port"] = Utils.ParseInt(txtWmSvcServicePort.Text.Trim(), 0).ToString();
settings["WmSvc.CredentialsMode"] = ddlWmSvcCredentialsMode.SelectedValue;

View file

@ -480,6 +480,24 @@ namespace WebsitePanel.Portal.ProviderControls {
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList ddlWmSvcCredentialsMode;
/// <summary>
/// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
/// txtWmSvcNETBIOS control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtWmSvcNETBIOS;
/// <summary>
/// secColdFusion control.
/// </summary>