This commit is contained in:
Virtuworks 2013-03-19 16:15:46 -04:00
commit 88d5bd7c73
5 changed files with 106 additions and 9 deletions

View file

@ -1314,8 +1314,18 @@ namespace WebsitePanel.EnterpriseServer
// load organization
Organization org = GetOrganization(itemId);
if (org == null)
{
return -1;
}
StringDictionary serviceSettings = ServerController.GetServiceSettings(org.ServiceId);
if (serviceSettings == null)
{
return -1;
}
// check package
int packageCheck = SecurityContext.CheckPackage(org.PackageId, DemandPackage.IsActive);
@ -1329,7 +1339,7 @@ namespace WebsitePanel.EnterpriseServer
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
string upn = string.Format("{0}@{1}", name, domain);
string sAMAccountName = BuildAccountName(org.OrganizationId, name, org.ServiceId);
string sAMAccountName = AppendOrgId(serviceSettings) ? BuildAccountNameWithOrgId(org.OrganizationId, name, org.ServiceId) : BuildAccountName(org.OrganizationId, name, org.ServiceId);
TaskManager.Write("accountName :" + sAMAccountName);
TaskManager.Write("upn :" + upn);
@ -1367,7 +1377,23 @@ namespace WebsitePanel.EnterpriseServer
return userId;
}
/// <summary> Checks should or not user name include organization id. </summary>
/// <param name="serviceSettings"> The service settings. </param>
/// <returns> True - if organization id should be appended. </returns>
private static bool AppendOrgId(StringDictionary serviceSettings)
{
if (!serviceSettings.ContainsKey("usernameformat"))
{
return false;
}
if (!serviceSettings["usernameformat"].Equals("Append OrgId", StringComparison.CurrentCultureIgnoreCase))
{
return false;
}
return true;
}
public static int ImportUser(int itemId, string accountName, string displayName, string name, string domain, string password, string subscriberNumber)
{
@ -1474,6 +1500,40 @@ namespace WebsitePanel.EnterpriseServer
return accountName;
}
/// <summary> Building account name with organization Id. </summary>
/// <param name="orgId"> The organization identifier. </param>
/// <param name="name"> The name. </param>
/// <param name="serviceId"> The service identifier. </param>
/// <returns> The account name with organization Id. </returns>
private static string BuildAccountNameWithOrgId(string orgId, string name, int serviceId)
{
int maxLen = 19 - orgId.Length;
// try to choose name
int i = 0;
while (true)
{
string num = i > 0 ? i.ToString() : "";
int len = maxLen - num.Length;
if (name.Length > len)
{
name = name.Substring(0, len);
}
string accountName = name + num + "_" + orgId;
// check if already exists
if (!AccountExists(accountName, serviceId))
{
return accountName;
}
i++;
}
}
private static string genSamLogin(string login, string strCounter)
{
int maxLogin = 20;

View file

@ -126,4 +126,13 @@
<data name="lblTemporyDomainName.Text" xml:space="preserve">
<value>Tempory Domain Name:</value>
</data>
<data name="lblUserNameFormat.Text" xml:space="preserve">
<value>Username Format:</value>
</data>
<data name="listItemStandard.Text" xml:space="preserve">
<value>Standard</value>
</data>
<data name="listItemAppendOrgId.Text" xml:space="preserve">
<value>Append OrgID</value>
</data>
</root>

View file

@ -23,4 +23,13 @@
<asp:RequiredFieldValidator ControlToValidate="txtTemporyDomainName" ErrorMessage="*" />
</td>
</tr>
<tr>
<td class="SubHead" nowrap="nowrap"><asp:Label runat="server" ID="UserNameFormatLabel" meta:resourcekey="lblUserNameFormat"/></td>
<td>
<asp:DropDownList runat="server" ID="UserNameFormatDropDown">
<asp:ListItem Value="1" meta:resourcekey="listItemStandard"/>
<asp:ListItem Value="2" meta:resourcekey="listItemAppendOrgId"/>
</asp:DropDownList>
</td>
</tr>
</table>

View file

@ -35,6 +35,7 @@ namespace WebsitePanel.Portal.ProviderControls
public const string RootOU = "RootOU";
public const string PrimaryDomainController = "PrimaryDomainController";
public const string TemporyDomainName = "TempDomain";
public const string UserNameFormat = "UserNameFormat";
protected void Page_Load(object sender, EventArgs e)
{
@ -46,6 +47,12 @@ namespace WebsitePanel.Portal.ProviderControls
txtPrimaryDomainController.Text = settings[PrimaryDomainController];
txtRootOU.Text = settings[RootOU];
txtTemporyDomainName.Text = settings[TemporyDomainName];
if (settings.ContainsKey(UserNameFormat))
{
UserNameFormatDropDown.SelectedValue =
UserNameFormatDropDown.Items.FindByText(settings[UserNameFormat]).Value;
}
}
public void SaveSettings(System.Collections.Specialized.StringDictionary settings)
@ -53,6 +60,7 @@ namespace WebsitePanel.Portal.ProviderControls
settings[RootOU] = txtRootOU.Text.Trim();
settings[PrimaryDomainController] = txtPrimaryDomainController.Text.Trim();
settings[TemporyDomainName] = txtTemporyDomainName.Text.Trim();
settings[UserNameFormat] = UserNameFormatDropDown.SelectedItem.Text;
}
}
}

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1378
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -11,12 +10,6 @@
namespace WebsitePanel.Portal.ProviderControls {
/// <summary>
/// Organizations_Settings class.
/// </summary>
/// <remarks>
/// Auto-generated class.
/// </remarks>
public partial class Organizations_Settings {
/// <summary>
@ -81,5 +74,23 @@ namespace WebsitePanel.Portal.ProviderControls {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtTemporyDomainName;
/// <summary>
/// UserNameFormatLabel 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 UserNameFormatLabel;
/// <summary>
/// UserNameFormatDropDown 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.DropDownList UserNameFormatDropDown;
}
}