Merge: dev to default
This commit is contained in:
commit
19d6bae05e
1884 changed files with 65140 additions and 30708 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -45,6 +45,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public const string ROLE_ADMINISTRATOR = "Administrator";
|
||||
public const string ROLE_RESELLER = "Reseller";
|
||||
public const string ROLE_USER = "User";
|
||||
public const string ROLE_PLATFORMCSR = "PlatformCSR";
|
||||
public const string ROLE_PLATFORMHELPDESK = "PlatformHelpdesk";
|
||||
public const string ROLE_RESELLERCSR = "ResellerCSR";
|
||||
public const string ROLE_RESELLERHELPDESK = "ResellerHelpdesk";
|
||||
|
||||
public const string CONTEXT_USER_INFO = "CONTEXT_USER_INFO";
|
||||
|
||||
|
@ -62,8 +66,26 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// set roles array
|
||||
List<string> roles = new List<string>();
|
||||
roles.Add(SecurityContext.ROLE_USER);
|
||||
|
||||
if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator ||
|
||||
user.Role == UserRole.PlatformHelpdesk || user.Role == UserRole.ResellerHelpdesk)
|
||||
roles.Add(SecurityContext.ROLE_RESELLERHELPDESK);
|
||||
|
||||
if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator ||
|
||||
user.Role == UserRole.PlatformCSR || user.Role == UserRole.ResellerCSR)
|
||||
roles.Add(SecurityContext.ROLE_RESELLERCSR);
|
||||
|
||||
if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator ||
|
||||
user.Role == UserRole.PlatformHelpdesk)
|
||||
roles.Add(SecurityContext.ROLE_PLATFORMHELPDESK);
|
||||
|
||||
if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator ||
|
||||
user.Role == UserRole.PlatformCSR)
|
||||
roles.Add(SecurityContext.ROLE_PLATFORMCSR);
|
||||
|
||||
if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator)
|
||||
roles.Add(SecurityContext.ROLE_RESELLER);
|
||||
|
||||
if (user.Role == UserRole.Administrator)
|
||||
roles.Add(SecurityContext.ROLE_ADMINISTRATOR);
|
||||
|
||||
|
@ -152,9 +174,40 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// should make a check if the account has Admin role
|
||||
if (!User.IsInRole(ROLE_RESELLER))
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_SHOULD_BE_RESELLER;
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS;
|
||||
}
|
||||
|
||||
if ((demand & DemandAccount.IsPlatformCSR) == DemandAccount.IsPlatformCSR)
|
||||
{
|
||||
// should make a check if the account has Admin role
|
||||
if (!User.IsInRole(ROLE_PLATFORMCSR))
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS;
|
||||
}
|
||||
|
||||
if ((demand & DemandAccount.IsPlatformHelpdesk) == DemandAccount.IsPlatformHelpdesk)
|
||||
{
|
||||
// should make a check if the account has Admin role
|
||||
if (!User.IsInRole(ROLE_PLATFORMHELPDESK))
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
||||
if ((demand & DemandAccount.IsResellerHelpdesk) == DemandAccount.IsResellerHelpdesk)
|
||||
{
|
||||
// should make a check if the account has Admin role
|
||||
if (!User.IsInRole(ROLE_RESELLERHELPDESK))
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
||||
if ((demand & DemandAccount.IsResellerCSR) == DemandAccount.IsResellerCSR)
|
||||
{
|
||||
// should make a check if the account has Admin role
|
||||
if (!User.IsInRole(ROLE_RESELLERCSR))
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -190,7 +190,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@Username", username));
|
||||
}
|
||||
|
||||
public static int AddUser(int actorId, int ownerId, int roleId, int statusId, bool isDemo,
|
||||
public static int AddUser(int actorId, int ownerId, int roleId, int statusId, int loginStatusId, bool isDemo,
|
||||
bool isPeer, string comments, string username, string password,
|
||||
string firstName, string lastName, string email, string secondaryEmail,
|
||||
string address, string city, string country, string state, string zip,
|
||||
|
@ -208,6 +208,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@OwnerID", ownerId),
|
||||
new SqlParameter("@RoleID", roleId),
|
||||
new SqlParameter("@StatusId", statusId),
|
||||
new SqlParameter("@LoginStatusId", loginStatusId),
|
||||
new SqlParameter("@IsDemo", isDemo),
|
||||
new SqlParameter("@IsPeer", isPeer),
|
||||
new SqlParameter("@Comments", comments),
|
||||
|
@ -227,13 +228,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@fax", fax),
|
||||
new SqlParameter("@instantMessenger", instantMessenger),
|
||||
new SqlParameter("@htmlMail", htmlMail),
|
||||
new SqlParameter("@CompanyName", companyName),
|
||||
new SqlParameter("@EcommerceEnabled", ecommerceEnabled));
|
||||
new SqlParameter("@CompanyName", companyName),
|
||||
new SqlParameter("@EcommerceEnabled", ecommerceEnabled));
|
||||
|
||||
return Convert.ToInt32(prmUserId.Value);
|
||||
}
|
||||
|
||||
public static void UpdateUser(int actorId, int userId, int roleId, int statusId, bool isDemo,
|
||||
public static void UpdateUser(int actorId, int userId, int roleId, int statusId, int loginStatusId, bool isDemo,
|
||||
bool isPeer, string comments, string firstName, string lastName, string email, string secondaryEmail,
|
||||
string address, string city, string country, string state, string zip,
|
||||
string primaryPhone, string secondaryPhone, string fax, string instantMessenger, bool htmlMail,
|
||||
|
@ -245,6 +246,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@ActorId", actorId),
|
||||
new SqlParameter("@RoleID", roleId),
|
||||
new SqlParameter("@StatusId", statusId),
|
||||
new SqlParameter("@LoginStatusId", loginStatusId),
|
||||
new SqlParameter("@UserID", userId),
|
||||
new SqlParameter("@IsDemo", isDemo),
|
||||
new SqlParameter("@IsPeer", isPeer),
|
||||
|
@ -263,11 +265,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@fax", fax),
|
||||
new SqlParameter("@instantMessenger", instantMessenger),
|
||||
new SqlParameter("@htmlMail", htmlMail),
|
||||
new SqlParameter("@CompanyName", companyName),
|
||||
new SqlParameter("@EcommerceEnabled", ecommerceEnabled),
|
||||
new SqlParameter("@CompanyName", companyName),
|
||||
new SqlParameter("@EcommerceEnabled", ecommerceEnabled),
|
||||
new SqlParameter("@AdditionalParams", additionalParams));
|
||||
}
|
||||
|
||||
public static void UpdateUserFailedLoginAttempt(int userId, int lockOut, bool reset)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "UpdateUserFailedLoginAttempt",
|
||||
new SqlParameter("@UserID", userId),
|
||||
new SqlParameter("@LockOut", lockOut),
|
||||
new SqlParameter("@Reset", reset));
|
||||
}
|
||||
|
||||
public static void DeleteUser(int actorId, int userId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
|
@ -675,7 +686,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static void AddDnsRecord(int actorId, int serviceId, int serverId, int packageId, string recordType,
|
||||
string recordName, string recordData, int mxPriority, int ipAddressId)
|
||||
string recordName, string recordData, int mxPriority, int SrvPriority, int SrvWeight, int SrvPort, int ipAddressId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "AddDnsRecord",
|
||||
|
@ -687,11 +698,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@RecordName", recordName),
|
||||
new SqlParameter("@RecordData", recordData),
|
||||
new SqlParameter("@MXPriority", mxPriority),
|
||||
new SqlParameter("@SrvPriority", SrvPriority),
|
||||
new SqlParameter("@SrvWeight", SrvWeight),
|
||||
new SqlParameter("@SrvPort", SrvPort),
|
||||
new SqlParameter("@IpAddressId", ipAddressId));
|
||||
}
|
||||
|
||||
public static void UpdateDnsRecord(int actorId, int recordId, string recordType,
|
||||
string recordName, string recordData, int mxPriority, int ipAddressId)
|
||||
string recordName, string recordData, int mxPriority, int SrvPriority, int SrvWeight, int SrvPort, int ipAddressId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "UpdateDnsRecord",
|
||||
|
@ -701,9 +715,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@RecordName", recordName),
|
||||
new SqlParameter("@RecordData", recordData),
|
||||
new SqlParameter("@MXPriority", mxPriority),
|
||||
new SqlParameter("@SrvPriority", SrvPriority),
|
||||
new SqlParameter("@SrvWeight", SrvWeight),
|
||||
new SqlParameter("@SrvPort", SrvPort),
|
||||
new SqlParameter("@IpAddressId", ipAddressId));
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteDnsRecord(int actorId, int recordId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
|
@ -763,7 +781,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@domainName", domainName));
|
||||
}
|
||||
|
||||
public static int CheckDomain(int packageId, string domainName)
|
||||
public static int CheckDomain(int packageId, string domainName, bool isDomainPointer)
|
||||
{
|
||||
SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int);
|
||||
prmId.Direction = ParameterDirection.Output;
|
||||
|
@ -772,7 +790,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ObjectQualifier + "CheckDomain",
|
||||
prmId,
|
||||
new SqlParameter("@packageId", packageId),
|
||||
new SqlParameter("@domainName", domainName));
|
||||
new SqlParameter("@domainName", domainName),
|
||||
new SqlParameter("@isDomainPointer", isDomainPointer));
|
||||
|
||||
return Convert.ToInt32(prmId.Value);
|
||||
}
|
||||
|
@ -2057,33 +2076,36 @@ namespace WebsitePanel.EnterpriseServer
|
|||
#endregion
|
||||
|
||||
#region Exchange Server
|
||||
|
||||
|
||||
public static int AddExchangeAccount(int itemId, int accountType, string accountName,
|
||||
|
||||
public static int AddExchangeAccount(int itemId, int accountType, string accountName,
|
||||
string displayName, string primaryEmailAddress, bool mailEnabledPublicFolder,
|
||||
string mailboxManagerActions, string samAccountName, string accountPassword)
|
||||
{
|
||||
SqlParameter outParam = new SqlParameter("@AccountID", SqlDbType.Int);
|
||||
outParam.Direction = ParameterDirection.Output;
|
||||
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, string subscriberNumber)
|
||||
{
|
||||
SqlParameter outParam = new SqlParameter("@AccountID", SqlDbType.Int);
|
||||
outParam.Direction = ParameterDirection.Output;
|
||||
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddExchangeAccount",
|
||||
outParam,
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@AccountType", accountType),
|
||||
new SqlParameter("@AccountName", accountName),
|
||||
new SqlParameter("@DisplayName", displayName),
|
||||
new SqlParameter("@PrimaryEmailAddress", primaryEmailAddress),
|
||||
new SqlParameter("@MailEnabledPublicFolder", mailEnabledPublicFolder),
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddExchangeAccount",
|
||||
outParam,
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@AccountType", accountType),
|
||||
new SqlParameter("@AccountName", accountName),
|
||||
new SqlParameter("@DisplayName", displayName),
|
||||
new SqlParameter("@PrimaryEmailAddress", primaryEmailAddress),
|
||||
new SqlParameter("@MailEnabledPublicFolder", mailEnabledPublicFolder),
|
||||
new SqlParameter("@MailboxManagerActions", mailboxManagerActions),
|
||||
new SqlParameter("@SamAccountName", samAccountName),
|
||||
new SqlParameter("@AccountPassword", accountPassword)
|
||||
);
|
||||
new SqlParameter("@AccountPassword", accountPassword),
|
||||
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId),
|
||||
new SqlParameter("@SubscriberNumber", (string.IsNullOrEmpty(subscriberNumber) ? (object)DBNull.Value : (object)subscriberNumber))
|
||||
);
|
||||
|
||||
return Convert.ToInt32(outParam.Value);
|
||||
}
|
||||
|
||||
return Convert.ToInt32(outParam.Value);
|
||||
}
|
||||
|
||||
public static void AddExchangeAccountEmailAddress(int accountId, string emailAddress)
|
||||
{
|
||||
|
@ -2151,6 +2173,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteExchangeAccountEmailAddress(int accountId, string emailAddress)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
|
@ -2247,26 +2270,27 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Convert.ToBoolean(outParam.Value);
|
||||
}
|
||||
|
||||
public static void UpdateExchangeAccount(int accountId, string accountName, ExchangeAccountType accountType,
|
||||
public static void UpdateExchangeAccount(int accountId, string accountName, ExchangeAccountType accountType,
|
||||
string displayName, string primaryEmailAddress, bool mailEnabledPublicFolder,
|
||||
string mailboxManagerActions, string samAccountName, string accountPassword)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"UpdateExchangeAccount",
|
||||
new SqlParameter("@AccountID", accountId),
|
||||
new SqlParameter("@AccountName", accountName),
|
||||
new SqlParameter("@DisplayName", displayName),
|
||||
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, string subscriberNumber)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"UpdateExchangeAccount",
|
||||
new SqlParameter("@AccountID", accountId),
|
||||
new SqlParameter("@AccountName", accountName),
|
||||
new SqlParameter("@DisplayName", displayName),
|
||||
new SqlParameter("@AccountType", (int)accountType),
|
||||
new SqlParameter("@PrimaryEmailAddress", primaryEmailAddress),
|
||||
new SqlParameter("@MailEnabledPublicFolder", mailEnabledPublicFolder),
|
||||
new SqlParameter("@PrimaryEmailAddress", primaryEmailAddress),
|
||||
new SqlParameter("@MailEnabledPublicFolder", mailEnabledPublicFolder),
|
||||
new SqlParameter("@MailboxManagerActions", mailboxManagerActions),
|
||||
new SqlParameter("@Password", string.IsNullOrEmpty(accountPassword) ? (object)DBNull.Value : (object)accountPassword),
|
||||
new SqlParameter("@SamAccountName", samAccountName)
|
||||
|
||||
);
|
||||
}
|
||||
new SqlParameter("@SamAccountName", samAccountName),
|
||||
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId),
|
||||
new SqlParameter("@SubscriberNumber", (string.IsNullOrEmpty(subscriberNumber) ? (object)DBNull.Value : (object)subscriberNumber))
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetExchangeAccount(int itemId, int accountId)
|
||||
{
|
||||
|
@ -2279,6 +2303,29 @@ namespace WebsitePanel.EnterpriseServer
|
|||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetExchangeAccountByAccountName(int itemId, string accountName)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetExchangeAccountByAccountName",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@AccountName", accountName)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetExchangeAccountByMailboxPlanId(int itemId, int MailboxPlanId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetExchangeAccountByMailboxPlanId",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@MailboxPlanId", MailboxPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static IDataReader GetExchangeAccountEmailAddresses(int accountId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
|
@ -2390,6 +2437,97 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
#endregion
|
||||
|
||||
#region Exchange Mailbox Plans
|
||||
public static int AddExchangeMailboxPlan(int itemID, string mailboxPlan, bool enableActiveSync, bool enableIMAP, bool enableMAPI, bool enableOWA, bool enablePOP,
|
||||
bool isDefault, int issueWarningPct, int keepDeletedItemsDays, int mailboxSizeMB, int maxReceiveMessageSizeKB, int maxRecipients,
|
||||
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook)
|
||||
{
|
||||
SqlParameter outParam = new SqlParameter("@MailboxPlanId", SqlDbType.Int);
|
||||
outParam.Direction = ParameterDirection.Output;
|
||||
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddExchangeMailboxPlan",
|
||||
outParam,
|
||||
new SqlParameter("@ItemID", itemID),
|
||||
new SqlParameter("@MailboxPlan", mailboxPlan),
|
||||
new SqlParameter("@EnableActiveSync", enableActiveSync),
|
||||
new SqlParameter("@EnableIMAP", enableIMAP),
|
||||
new SqlParameter("@EnableMAPI", enableMAPI),
|
||||
new SqlParameter("@EnableOWA", enableOWA),
|
||||
new SqlParameter("@EnablePOP", enablePOP),
|
||||
new SqlParameter("@IsDefault", isDefault),
|
||||
new SqlParameter("@IssueWarningPct", issueWarningPct),
|
||||
new SqlParameter("@KeepDeletedItemsDays", keepDeletedItemsDays),
|
||||
new SqlParameter("@MailboxSizeMB", mailboxSizeMB),
|
||||
new SqlParameter("@MaxReceiveMessageSizeKB", maxReceiveMessageSizeKB),
|
||||
new SqlParameter("@MaxRecipients", maxRecipients),
|
||||
new SqlParameter("@MaxSendMessageSizeKB", maxSendMessageSizeKB),
|
||||
new SqlParameter("@ProhibitSendPct", prohibitSendPct),
|
||||
new SqlParameter("@ProhibitSendReceivePct", prohibitSendReceivePct),
|
||||
new SqlParameter("@HideFromAddressBook", hideFromAddressBook)
|
||||
);
|
||||
|
||||
return Convert.ToInt32(outParam.Value);
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteExchangeMailboxPlan(int mailboxPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"DeleteExchangeMailboxPlan",
|
||||
new SqlParameter("@MailboxPlanId", mailboxPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static IDataReader GetExchangeMailboxPlan(int mailboxPlanId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetExchangeMailboxPlan",
|
||||
new SqlParameter("@MailboxPlanId", mailboxPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetExchangeMailboxPlans(int itemId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetExchangeMailboxPlans",
|
||||
new SqlParameter("@ItemID", itemId)
|
||||
);
|
||||
}
|
||||
|
||||
public static void SetOrganizationDefaultExchangeMailboxPlan(int itemId, int mailboxPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"SetOrganizationDefaultExchangeMailboxPlan",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@MailboxPlanId", mailboxPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
public static void SetExchangeAccountMailboxPlan(int accountId, int mailboxPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"SetExchangeAccountMailboxplan",
|
||||
new SqlParameter("@AccountID", accountId),
|
||||
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Organizations
|
||||
|
||||
public static void DeleteOrganizationUser(int itemId)
|
||||
|
@ -3025,5 +3163,175 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Convert.ToBoolean(prmId.Value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Lync
|
||||
|
||||
public static void AddLyncUser(int accountId, int lyncUserPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddLyncUser",
|
||||
new[]
|
||||
{
|
||||
new SqlParameter("@AccountID", accountId),
|
||||
new SqlParameter("@LyncUserPlanID", lyncUserPlanId)
|
||||
});
|
||||
}
|
||||
|
||||
public static bool CheckLyncUserExists(int accountId)
|
||||
{
|
||||
int res = (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "CheckLyncUserExists",
|
||||
new SqlParameter("@AccountID", accountId));
|
||||
return res > 0;
|
||||
}
|
||||
|
||||
public static IDataReader GetLyncUsers(int itemId, string sortColumn, string sortDirection, int startRow, int count)
|
||||
{
|
||||
SqlParameter[] sqlParams = new SqlParameter[]
|
||||
{
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@SortColumn", sortColumn),
|
||||
new SqlParameter("@SortDirection", sortDirection),
|
||||
new SqlParameter("@StartRow", startRow),
|
||||
new SqlParameter("Count", count)
|
||||
};
|
||||
|
||||
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetLyncUsers", sqlParams);
|
||||
}
|
||||
|
||||
|
||||
public static IDataReader GetLyncUsersByPlanId(int itemId, int planId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetLyncUsersByPlanId",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@PlanId", planId)
|
||||
);
|
||||
}
|
||||
|
||||
public static int GetLyncUsersCount(int itemId)
|
||||
{
|
||||
SqlParameter[] sqlParams = new SqlParameter[]
|
||||
{
|
||||
new SqlParameter("@ItemID", itemId)
|
||||
};
|
||||
|
||||
return
|
||||
(int)
|
||||
SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetLyncUsersCount", sqlParams);
|
||||
}
|
||||
|
||||
public static void DeleteLyncUser(int accountId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"DeleteLyncUser",
|
||||
new[]
|
||||
{
|
||||
new SqlParameter("@AccountId", accountId)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static int AddLyncUserPlan(int itemID, LyncUserPlan lyncUserPlan)
|
||||
{
|
||||
SqlParameter outParam = new SqlParameter("@LyncUserPlanId", SqlDbType.Int);
|
||||
outParam.Direction = ParameterDirection.Output;
|
||||
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddLyncUserPlan",
|
||||
outParam,
|
||||
|
||||
new SqlParameter("@ItemID", itemID),
|
||||
new SqlParameter("@LyncUserPlanName", lyncUserPlan.LyncUserPlanName),
|
||||
new SqlParameter("@IM", lyncUserPlan.IM),
|
||||
new SqlParameter("@Mobility", lyncUserPlan.Mobility),
|
||||
new SqlParameter("@MobilityEnableOutsideVoice", lyncUserPlan.MobilityEnableOutsideVoice),
|
||||
new SqlParameter("@Federation", lyncUserPlan.Federation),
|
||||
new SqlParameter("@Conferencing", lyncUserPlan.Conferencing),
|
||||
new SqlParameter("@EnterpriseVoice", lyncUserPlan.EnterpriseVoice),
|
||||
new SqlParameter("@VoicePolicy", lyncUserPlan.VoicePolicy),
|
||||
new SqlParameter("@IsDefault", lyncUserPlan.IsDefault)
|
||||
);
|
||||
|
||||
return Convert.ToInt32(outParam.Value);
|
||||
}
|
||||
|
||||
public static void DeleteLyncUserPlan(int lyncUserPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"DeleteLyncUserPlan",
|
||||
new SqlParameter("@LyncUserPlanId", lyncUserPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetLyncUserPlan(int lyncUserPlanId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetLyncUserPlan",
|
||||
new SqlParameter("@LyncUserPlanId", lyncUserPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static IDataReader GetLyncUserPlans(int itemId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetLyncUserPlans",
|
||||
new SqlParameter("@ItemID", itemId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static void SetOrganizationDefaultLyncUserPlan(int itemId, int lyncUserPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"SetOrganizationDefaultLyncUserPlan",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@LyncUserPlanId", lyncUserPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetLyncUserPlanByAccountId(int AccountId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetLyncUserPlanByAccountId",
|
||||
new SqlParameter("@AccountID", AccountId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static void SetLyncUserLyncUserplan(int accountId, int lyncUserPlanId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"SetLyncUserLyncUserplan",
|
||||
new SqlParameter("@AccountID", accountId),
|
||||
new SqlParameter("@LyncUserPlanId", (lyncUserPlanId == 0) ? (object)DBNull.Value : (object)lyncUserPlanId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -38,158 +38,157 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
public class DnsServerController : IImportController, IBackupController
|
||||
{
|
||||
private static DNSServer GetDNSServer(int serviceId)
|
||||
{
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, serviceId);
|
||||
return dns;
|
||||
}
|
||||
private static DNSServer GetDNSServer(int serviceId)
|
||||
{
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, serviceId);
|
||||
return dns;
|
||||
}
|
||||
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName)
|
||||
{
|
||||
return AddZone(packageId, serviceId, zoneName, true);
|
||||
}
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName)
|
||||
{
|
||||
return AddZone(packageId, serviceId, zoneName, true);
|
||||
}
|
||||
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName, bool addPackageItem)
|
||||
{
|
||||
// get DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName, bool addPackageItem)
|
||||
{
|
||||
// get DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
|
||||
// check if zone already exists
|
||||
if (dns.ZoneExists(zoneName))
|
||||
return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS;
|
||||
// check if zone already exists
|
||||
if (dns.ZoneExists(zoneName))
|
||||
return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS;
|
||||
|
||||
//
|
||||
TaskManager.StartTask("DNS_ZONE", "ADD", zoneName);
|
||||
//
|
||||
int zoneItemId = default(int);
|
||||
//
|
||||
try
|
||||
{
|
||||
// get secondary DNS services
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(serviceId);
|
||||
string[] primaryIPAddresses = GetExternalIPAddressesFromString(primSettings["ListeningIPAddresses"]);
|
||||
//
|
||||
TaskManager.StartTask("DNS_ZONE", "ADD", zoneName);
|
||||
//
|
||||
int zoneItemId = default(int);
|
||||
//
|
||||
try
|
||||
{
|
||||
// get secondary DNS services
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(serviceId);
|
||||
string[] primaryIPAddresses = GetExternalIPAddressesFromString(primSettings["ListeningIPAddresses"]);
|
||||
|
||||
List<string> secondaryIPAddresses = new List<string>();
|
||||
List<int> secondaryServiceIds = new List<int>();
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
List<string> secondaryIPAddresses = new List<string>();
|
||||
List<int> secondaryServiceIds = new List<int>();
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
|
||||
secondaryServiceIds.Add(secondaryId);
|
||||
StringDictionary secondarySettings = ServerController.GetServiceSettings(secondaryId);
|
||||
secondaryServiceIds.Add(secondaryId);
|
||||
StringDictionary secondarySettings = ServerController.GetServiceSettings(secondaryId);
|
||||
|
||||
// add secondary IPs to the master array
|
||||
secondaryIPAddresses.AddRange(
|
||||
GetExternalIPAddressesFromString(secondarySettings["ListeningIPAddresses"]));
|
||||
}
|
||||
}
|
||||
// add secondary IPs to the master array
|
||||
secondaryIPAddresses.AddRange(
|
||||
GetExternalIPAddressesFromString(secondarySettings["ListeningIPAddresses"]));
|
||||
}
|
||||
}
|
||||
|
||||
// add "Allow zone transfers"
|
||||
string allowTransfers = primSettings["AllowZoneTransfers"];
|
||||
if (!String.IsNullOrEmpty(allowTransfers))
|
||||
{
|
||||
string[] ips = Utils.ParseDelimitedString(allowTransfers, '\n', ' ', ',', ';');
|
||||
foreach (string ip in ips)
|
||||
{
|
||||
if (!secondaryIPAddresses.Contains(ip))
|
||||
secondaryIPAddresses.Add(ip);
|
||||
}
|
||||
}
|
||||
// add "Allow zone transfers"
|
||||
string allowTransfers = primSettings["AllowZoneTransfers"];
|
||||
if (!String.IsNullOrEmpty(allowTransfers))
|
||||
{
|
||||
string[] ips = Utils.ParseDelimitedString(allowTransfers, '\n', ' ', ',', ';');
|
||||
foreach (string ip in ips)
|
||||
{
|
||||
if (!secondaryIPAddresses.Contains(ip))
|
||||
secondaryIPAddresses.Add(ip);
|
||||
}
|
||||
}
|
||||
|
||||
// add primary zone
|
||||
dns.AddPrimaryZone(zoneName, secondaryIPAddresses.ToArray());
|
||||
// add primary zone
|
||||
dns.AddPrimaryZone(zoneName, secondaryIPAddresses.ToArray());
|
||||
|
||||
// get DNS zone records
|
||||
List<GlobalDnsRecord> records = ServerController.GetDnsRecordsTotal(packageId);
|
||||
// get DNS zone records
|
||||
List<GlobalDnsRecord> records = ServerController.GetDnsRecordsTotal(packageId);
|
||||
|
||||
// get name servers
|
||||
PackageSettings packageSettings = PackageController.GetPackageSettings(packageId, PackageSettings.NAME_SERVERS);
|
||||
string[] nameServers = new string[] { };
|
||||
if (!String.IsNullOrEmpty(packageSettings["NameServers"]))
|
||||
nameServers = packageSettings["NameServers"].Split(';');
|
||||
// get name servers
|
||||
PackageSettings packageSettings = PackageController.GetPackageSettings(packageId, PackageSettings.NAME_SERVERS);
|
||||
string[] nameServers = new string[] { };
|
||||
if (!String.IsNullOrEmpty(packageSettings["NameServers"]))
|
||||
nameServers = packageSettings["NameServers"].Split(';');
|
||||
|
||||
// build records list
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
// build records list
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
|
||||
string primaryNameServer = "ns." + zoneName;
|
||||
string primaryNameServer = "ns." + zoneName;
|
||||
|
||||
if (nameServers.Length > 0)
|
||||
primaryNameServer = nameServers[0];
|
||||
if (nameServers.Length > 0)
|
||||
primaryNameServer = nameServers[0];
|
||||
|
||||
// update SOA record
|
||||
// update SOA record
|
||||
|
||||
string hostmaster = primSettings["ResponsiblePerson"];
|
||||
if (String.IsNullOrEmpty(hostmaster))
|
||||
{
|
||||
hostmaster = "hostmaster." + zoneName;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostmaster = Utils.ReplaceStringVariable(hostmaster, "domain_name", zoneName);
|
||||
}
|
||||
string hostmaster = primSettings["ResponsiblePerson"];
|
||||
if (String.IsNullOrEmpty(hostmaster))
|
||||
{
|
||||
hostmaster = "hostmaster." + zoneName;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostmaster = Utils.ReplaceStringVariable(hostmaster, "domain_name", zoneName);
|
||||
}
|
||||
|
||||
dns.UpdateSoaRecord(zoneName, "", primaryNameServer, hostmaster);
|
||||
dns.UpdateSoaRecord(zoneName, "", primaryNameServer, hostmaster);
|
||||
|
||||
// add name servers
|
||||
foreach (string nameServer in nameServers)
|
||||
{
|
||||
DnsRecord ns = new DnsRecord();
|
||||
ns.RecordType = DnsRecordType.NS;
|
||||
ns.RecordName = "";
|
||||
ns.RecordData = nameServer;
|
||||
// add name servers
|
||||
foreach (string nameServer in nameServers)
|
||||
{
|
||||
DnsRecord ns = new DnsRecord();
|
||||
ns.RecordType = DnsRecordType.NS;
|
||||
ns.RecordName = "";
|
||||
ns.RecordData = nameServer;
|
||||
|
||||
zoneRecords.Add(ns);
|
||||
}
|
||||
zoneRecords.Add(ns);
|
||||
}
|
||||
|
||||
// add all other records
|
||||
zoneRecords.AddRange(
|
||||
BuildDnsResourceRecords(records, zoneName, ""));
|
||||
// add all other records
|
||||
zoneRecords.AddRange(BuildDnsResourceRecords(records, zoneName, ""));
|
||||
|
||||
// add zone records
|
||||
dns.AddZoneRecords(zoneName, zoneRecords.ToArray());
|
||||
// add zone records
|
||||
dns.AddZoneRecords(zoneName, zoneRecords.ToArray());
|
||||
|
||||
|
||||
// add secondary zones
|
||||
foreach (int secondaryId in secondaryServiceIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
// add secondary zone
|
||||
DNSServer secDns = GetDNSServer(secondaryId);
|
||||
secDns.AddSecondaryZone(zoneName, primaryIPAddresses);
|
||||
RegisterZoneItems(packageId, secondaryId, zoneName, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex, "Error adding secondary zone (service ID = " + secondaryId + ")");
|
||||
}
|
||||
}
|
||||
// add secondary zones
|
||||
foreach (int secondaryId in secondaryServiceIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
// add secondary zone
|
||||
DNSServer secDns = GetDNSServer(secondaryId);
|
||||
secDns.AddSecondaryZone(zoneName, primaryIPAddresses);
|
||||
RegisterZoneItems(packageId, secondaryId, zoneName, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex, "Error adding secondary zone (service ID = " + secondaryId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (!addPackageItem)
|
||||
return 0;
|
||||
// add service item
|
||||
zoneItemId = RegisterZoneItems(packageId, serviceId, zoneName, true);
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
//
|
||||
return zoneItemId;
|
||||
}
|
||||
if (!addPackageItem)
|
||||
return 0;
|
||||
// add service item
|
||||
zoneItemId = RegisterZoneItems(packageId, serviceId, zoneName, true);
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
//
|
||||
return zoneItemId;
|
||||
}
|
||||
|
||||
|
||||
private static int RegisterZoneItems(int spaceId, int serviceId, string zoneName, bool primaryZone)
|
||||
|
@ -202,131 +201,138 @@ namespace WebsitePanel.EnterpriseServer
|
|||
int zoneItemId = PackageController.AddPackageItem(zone);
|
||||
return zoneItemId;
|
||||
}
|
||||
|
||||
|
||||
public static int DeleteZone(int zoneItemId)
|
||||
{
|
||||
// delete DNS zone if applicable
|
||||
{
|
||||
// delete DNS zone if applicable
|
||||
DnsZone zoneItem = (DnsZone)PackageController.GetPackageItem(zoneItemId);
|
||||
//
|
||||
if (zoneItem != null)
|
||||
{
|
||||
TaskManager.StartTask("DNS_ZONE", "DELETE", zoneItem.Name);
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
// delete DNS zone
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
//
|
||||
if (zoneItem != null)
|
||||
{
|
||||
TaskManager.StartTask("DNS_ZONE", "DELETE", zoneItem.Name);
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
// delete DNS zone
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
|
||||
// delete secondary zones
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(zoneItem.ServiceId);
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
// delete secondary zones
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(zoneItem.ServiceId);
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
|
||||
DNSServer secDns = new DNSServer();
|
||||
ServiceProviderProxy.Init(secDns, secondaryId);
|
||||
DNSServer secDns = new DNSServer();
|
||||
ServiceProviderProxy.Init(secDns, secondaryId);
|
||||
|
||||
secDns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
// problem when deleting secondary zone
|
||||
TaskManager.WriteError(ex1, "Error deleting secondary DNS zone");
|
||||
}
|
||||
}
|
||||
}
|
||||
secDns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
// problem when deleting secondary zone
|
||||
TaskManager.WriteError(ex1, "Error deleting secondary DNS zone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
TaskManager.WriteError(ex2, "Error deleting primary DNS zone");
|
||||
}
|
||||
try
|
||||
{
|
||||
dns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
TaskManager.WriteError(ex2, "Error deleting primary DNS zone");
|
||||
}
|
||||
|
||||
// delete service item
|
||||
PackageController.DeletePackageItem(zoneItemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
// delete service item
|
||||
PackageController.DeletePackageItem(zoneItemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static List<DnsRecord> BuildDnsResourceRecords(List<GlobalDnsRecord> records,
|
||||
string domainName, string serviceIP)
|
||||
{
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
public static List<DnsRecord> BuildDnsResourceRecords(List<GlobalDnsRecord> records, string domainName, string serviceIP)
|
||||
{
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
|
||||
foreach (GlobalDnsRecord record in records)
|
||||
{
|
||||
DnsRecord rr = new DnsRecord();
|
||||
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
|
||||
rr.RecordName = record.RecordName;
|
||||
foreach (GlobalDnsRecord record in records)
|
||||
{
|
||||
DnsRecord rr = new DnsRecord();
|
||||
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
|
||||
rr.RecordName = record.RecordName;
|
||||
|
||||
if (record.RecordType == "A")
|
||||
{
|
||||
rr.RecordData = String.IsNullOrEmpty(record.RecordData) ? record.ExternalIP : record.RecordData;
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "ip", record.ExternalIP);
|
||||
|
||||
if (record.RecordType == "A")
|
||||
{
|
||||
rr.RecordData = String.IsNullOrEmpty(record.RecordData) ? record.ExternalIP : record.RecordData;
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "ip", record.ExternalIP);
|
||||
if (String.IsNullOrEmpty(rr.RecordData) && !String.IsNullOrEmpty(serviceIP))
|
||||
rr.RecordData = serviceIP;
|
||||
}
|
||||
else if (record.RecordType == "SRV")
|
||||
{
|
||||
rr.SrvPriority = record.SrvPriority;
|
||||
rr.SrvWeight = record.SrvWeight;
|
||||
rr.SrvPort = record.SrvPort;
|
||||
rr.RecordText = record.RecordData;
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
else
|
||||
{
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(rr.RecordData) && !String.IsNullOrEmpty(serviceIP))
|
||||
rr.RecordData = serviceIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
// substitute variables
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "domain_name", domainName);
|
||||
|
||||
// substitute variables
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "domain_name", domainName);
|
||||
// add MX priority
|
||||
if (record.RecordType == "MX")
|
||||
rr.MxPriority = record.MxPriority;
|
||||
|
||||
// add MX priority
|
||||
if (record.RecordType == "MX")
|
||||
rr.MxPriority = record.MxPriority;
|
||||
if (!String.IsNullOrEmpty(rr.RecordData))
|
||||
zoneRecords.Add(rr);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(rr.RecordData))
|
||||
zoneRecords.Add(rr);
|
||||
}
|
||||
return zoneRecords;
|
||||
}
|
||||
|
||||
return zoneRecords;
|
||||
}
|
||||
public static string[] GetExternalIPAddressesFromString(string str)
|
||||
{
|
||||
List<string> ips = new List<string>();
|
||||
|
||||
public static string[] GetExternalIPAddressesFromString(string str)
|
||||
{
|
||||
List<string> ips = new List<string>();
|
||||
if (str != null && str.Trim() != "")
|
||||
{
|
||||
string[] sips = str.Split(',');
|
||||
foreach (string sip in sips)
|
||||
{
|
||||
IPAddressInfo ip = ServerController.GetIPAddress(Int32.Parse(sip));
|
||||
if (ip != null)
|
||||
ips.Add(ip.ExternalIP);
|
||||
}
|
||||
}
|
||||
|
||||
if (str != null && str.Trim() != "")
|
||||
{
|
||||
string[] sips = str.Split(',');
|
||||
foreach (string sip in sips)
|
||||
{
|
||||
IPAddressInfo ip = ServerController.GetIPAddress(Int32.Parse(sip));
|
||||
if (ip != null)
|
||||
ips.Add(ip.ExternalIP);
|
||||
}
|
||||
}
|
||||
|
||||
return ips.ToArray();
|
||||
}
|
||||
return ips.ToArray();
|
||||
}
|
||||
|
||||
#region IImportController Members
|
||||
|
||||
|
@ -350,7 +356,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public void ImportItem(int packageId, int itemTypeId, Type itemType,
|
||||
ResourceGroupInfo group, string itemName)
|
||||
ResourceGroupInfo group, string itemName)
|
||||
{
|
||||
// get service id
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
|
||||
|
@ -395,11 +401,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
|
||||
{
|
||||
if (!(item is DnsZone))
|
||||
return 0;
|
||||
if (!(item is DnsZone))
|
||||
return 0;
|
||||
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(item.ServiceId);
|
||||
DNSServer dns = GetDNSServer(item.ServiceId);
|
||||
|
||||
// zone records serialized
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
|
@ -424,31 +430,31 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public int RestoreItem(string tempFolder, XmlNode itemNode, int itemId, Type itemType,
|
||||
string itemName, int packageId, int serviceId, ResourceGroupInfo group)
|
||||
{
|
||||
if (itemType != typeof(DnsZone))
|
||||
return 0;
|
||||
if (itemType != typeof(DnsZone))
|
||||
return 0;
|
||||
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
|
||||
// check service item
|
||||
if (!dns.ZoneExists(itemName))
|
||||
{
|
||||
// create primary and secondary zones
|
||||
AddZone(packageId, serviceId, itemName, false);
|
||||
// check service item
|
||||
if (!dns.ZoneExists(itemName))
|
||||
{
|
||||
// create primary and secondary zones
|
||||
AddZone(packageId, serviceId, itemName, false);
|
||||
|
||||
// restore records
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
List<DnsRecord> records = new List<DnsRecord>();
|
||||
foreach (XmlNode childNode in itemNode.ChildNodes)
|
||||
{
|
||||
if (childNode.Name == "DnsRecord")
|
||||
{
|
||||
records.Add((DnsRecord)serializer.Deserialize(new XmlNodeReader(childNode)));
|
||||
}
|
||||
}
|
||||
// restore records
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
List<DnsRecord> records = new List<DnsRecord>();
|
||||
foreach (XmlNode childNode in itemNode.ChildNodes)
|
||||
{
|
||||
if (childNode.Name == "DnsRecord")
|
||||
{
|
||||
records.Add((DnsRecord)serializer.Deserialize(new XmlNodeReader(childNode)));
|
||||
}
|
||||
}
|
||||
|
||||
dns.AddZoneRecords(itemName, records.ToArray());
|
||||
}
|
||||
dns.AddZoneRecords(itemName, records.ToArray());
|
||||
}
|
||||
|
||||
// check if meta-item exists
|
||||
int zoneId = 0;
|
||||
|
@ -470,7 +476,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// restore domains
|
||||
RestoreDomainByZone(itemName, packageId, zoneId);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,896 +0,0 @@
|
|||
// 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.Web;
|
||||
using WebsitePanel.Providers.ExchangeHostedEdition;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.Common;
|
||||
using WebsitePanel.Providers;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
public class ExchangeHostedEditionController
|
||||
{
|
||||
// messages
|
||||
public const string GeneralError = "GeneralError";
|
||||
public const string ExchangeServiceNotEnabledError = "ExchangeServiceNotEnabledError";
|
||||
public const string ProgramIdIsNotSetError = "ProgramIdIsNotSetError";
|
||||
public const string OfferIdIsNotSetError = "OfferIdIsNotSetError";
|
||||
public const string CreateOrganizationError = "CreateOrganizationError";
|
||||
public const string OrganizationNotFoundError = "OrganizationNotFoundError";
|
||||
public const string SendOrganizationSummaryError = "SendOrganizationSummaryError";
|
||||
public const string SendOrganizationTemplateNotSetError = "SendOrganizationTemplateNotSetError";
|
||||
public const string AddDomainError = "AddDomainError";
|
||||
public const string AddDomainQuotaExceededError = "AddDomainQuotaExceededError";
|
||||
public const string AddDomainExistsError = "AddDomainExistsError";
|
||||
public const string AddDomainAlreadyUsedError = "AddDomainAlreadyUsedError";
|
||||
public const string DeleteDomainError = "DeleteDomainError";
|
||||
public const string UpdateQuotasError = "UpdateQuotasError";
|
||||
public const string UpdateQuotasWrongQuotaError = "UpdateQuotasWrongQuotaError";
|
||||
public const string UpdateCatchAllError = "UpdateCatchAllError";
|
||||
public const string UpdateServicePlanError = "UpdateServicePlanError";
|
||||
public const string DeleteOrganizationError = "DeleteOrganizationError";
|
||||
|
||||
public const string TempDomainSetting = "temporaryDomain";
|
||||
public const string ExchangeControlPanelUrlSetting = "ecpURL";
|
||||
|
||||
// other constants
|
||||
public const string TaskManagerSource = "ExchangeHostedEdition";
|
||||
|
||||
public static IntResult CreateOrganization(int packageId, string organizationId,
|
||||
string domain, string adminName, string adminEmail, string adminPassword)
|
||||
{
|
||||
IntResult result = new IntResult();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "CREATE_ORGANIZATION");
|
||||
TaskManager.WriteParameter("packageId", packageId);
|
||||
TaskManager.WriteParameter("organizationId", organizationId);
|
||||
TaskManager.WriteParameter("domain", domain);
|
||||
TaskManager.WriteParameter("adminName", adminName);
|
||||
TaskManager.WriteParameter("adminEmail", adminEmail);
|
||||
TaskManager.WriteParameter("adminPassword", adminPassword);
|
||||
|
||||
// get Exchange service ID
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.ExchangeHostedEdition);
|
||||
if(serviceId < 1)
|
||||
return Error<IntResult>(ExchangeServiceNotEnabledError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<IntResult>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<IntResult>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(serviceId);
|
||||
|
||||
// load service settings to know ProgramID, OfferID
|
||||
StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
|
||||
string programId = serviceSettings["programID"];
|
||||
string offerId = serviceSettings["offerID"];
|
||||
|
||||
// check settings
|
||||
if(String.IsNullOrEmpty(programId))
|
||||
result.ErrorCodes.Add(ProgramIdIsNotSetError);
|
||||
if (String.IsNullOrEmpty(offerId))
|
||||
result.ErrorCodes.Add(OfferIdIsNotSetError);
|
||||
|
||||
if (result.ErrorCodes.Count > 0)
|
||||
{
|
||||
result.IsSuccess = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
#region Create organization
|
||||
int itemId = -1;
|
||||
ExchangeOrganization org = null;
|
||||
try
|
||||
{
|
||||
// create organization
|
||||
exchange.CreateOrganization(organizationId, programId, offerId, domain, adminName, adminEmail, adminPassword);
|
||||
|
||||
// save item into meta-base
|
||||
org = new ExchangeOrganization();
|
||||
org.Name = organizationId;
|
||||
org.PackageId = packageId;
|
||||
org.ServiceId = serviceId;
|
||||
itemId = PackageController.AddPackageItem(org);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
return Error<IntResult>(CreateOrganizationError);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update organization quotas
|
||||
// update max org quotas
|
||||
UpdateOrganizationQuotas(org);
|
||||
|
||||
// override quotas
|
||||
ResultObject quotasResult = ExchangeHostedEditionController.UpdateOrganizationQuotas(itemId,
|
||||
org.MaxMailboxCountQuota,
|
||||
org.MaxContactCountQuota,
|
||||
org.MaxDistributionListCountQuota);
|
||||
|
||||
if (!quotasResult.IsSuccess)
|
||||
return Error<IntResult>(quotasResult, CreateOrganizationError);
|
||||
#endregion
|
||||
|
||||
#region Add temporary domain
|
||||
// load settings
|
||||
PackageSettings settings = GetExchangePackageSettings(org);
|
||||
string tempDomainTemplate = settings[TempDomainSetting];
|
||||
if (!String.IsNullOrEmpty(tempDomainTemplate))
|
||||
{
|
||||
// add temp domain
|
||||
string tempDomain = String.Format("{0}.{1}", domain, tempDomainTemplate);
|
||||
AddOrganizationDomain(itemId, tempDomain);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
result.Value = itemId;
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<IntResult>(GeneralError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ExchangeOrganization> GetOrganizations(int packageId)
|
||||
{
|
||||
List<ServiceProviderItem> items = PackageController.GetPackageItemsByType(
|
||||
packageId, typeof(ExchangeOrganization), false);
|
||||
|
||||
return items.ConvertAll<ExchangeOrganization>(i => { return (ExchangeOrganization)i; });
|
||||
}
|
||||
|
||||
public static ExchangeOrganization GetOrganizationDetails(int itemId)
|
||||
{
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return null; // organization item not found
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// get organization details
|
||||
ExchangeOrganization org = exchange.GetOrganizationDetails(item.Name);
|
||||
|
||||
//ExchangeOrganization org = new ExchangeOrganization
|
||||
//{
|
||||
// Id = item.Id,
|
||||
// PackageId = item.PackageId,
|
||||
// ServiceId = item.ServiceId,
|
||||
// Name = item.Name,
|
||||
// AdministratorEmail = "admin@email.com",
|
||||
// AdministratorName = "Administrator Mailbox",
|
||||
// CatchAllAddress = "",
|
||||
// ContactCount = 1,
|
||||
// ContactCountQuota = 2,
|
||||
// MaxContactCountQuota = 3,
|
||||
// DistinguishedName = "DN=....",
|
||||
// DistributionListCount = 2,
|
||||
// DistributionListCountQuota = 3,
|
||||
// MaxDistributionListCountQuota = 3,
|
||||
// MaxDomainsCountQuota = 4,
|
||||
// ExchangeControlPanelUrl = "http://ecp.domain.com",
|
||||
// MailboxCount = 3,
|
||||
// MailboxCountQuota = 4,
|
||||
// MaxMailboxCountQuota = 4,
|
||||
// ProgramId = "HostedExchange",
|
||||
// OfferId = "2",
|
||||
// ServicePlan = "HostedExchange_Basic",
|
||||
// Domains = GetOrganizationDomains(item.Id).ToArray()
|
||||
//};
|
||||
|
||||
// update item props
|
||||
org.Id = item.Id;
|
||||
org.PackageId = item.PackageId;
|
||||
org.ServiceId = item.ServiceId;
|
||||
org.Name = item.Name;
|
||||
org.CatchAllAddress = item.CatchAllAddress;
|
||||
|
||||
// update max quotas
|
||||
UpdateOrganizationQuotas(org);
|
||||
|
||||
// process summary information
|
||||
org.SummaryInformation = GetExchangeOrganizationSummary(org);
|
||||
|
||||
// process domains
|
||||
PackageSettings settings = GetExchangePackageSettings(org);
|
||||
if(settings != null)
|
||||
{
|
||||
// get settings
|
||||
string tempDomain = settings[TempDomainSetting];
|
||||
string ecpUrl = settings[ExchangeControlPanelUrlSetting];
|
||||
|
||||
// iterate through domains
|
||||
foreach (ExchangeOrganizationDomain domain in org.Domains)
|
||||
{
|
||||
if (tempDomain != null && domain.Name.EndsWith("." + tempDomain, StringComparison.InvariantCultureIgnoreCase))
|
||||
domain.IsTemp = true;
|
||||
if (domain.IsDefault && ecpUrl != null)
|
||||
org.ExchangeControlPanelUrl = Utils.ReplaceStringVariable(ecpUrl, "domain_name", domain.Name);
|
||||
}
|
||||
}
|
||||
|
||||
// return org
|
||||
return org;
|
||||
}
|
||||
|
||||
public static void UpdateOrganizationQuotas(ExchangeOrganization org)
|
||||
{
|
||||
// load default package quotas
|
||||
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
|
||||
if (!cntx.Groups.ContainsKey(ResourceGroups.ExchangeHostedEdition))
|
||||
return;
|
||||
|
||||
org.MaxMailboxCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_MAILBOXES].QuotaAllocatedValue;
|
||||
org.MaxContactCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_CONTACTS].QuotaAllocatedValue;
|
||||
org.MaxDistributionListCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_DISTRIBUTIONLISTS].QuotaAllocatedValue;
|
||||
org.MaxDomainsCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_DOMAINS].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
public static List<ExchangeOrganizationDomain> GetOrganizationDomains(int itemId)
|
||||
{
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return null; // organization item not found
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// get organization domains
|
||||
List<ExchangeOrganizationDomain> domains = new List<ExchangeOrganizationDomain>();
|
||||
domains.AddRange(exchange.GetOrganizationDomains(item.Name));
|
||||
return domains;
|
||||
|
||||
//return new List<ExchangeOrganizationDomain>
|
||||
//{
|
||||
// new ExchangeOrganizationDomain { Identity = "org101\\domain1.com", Name = "domain1.com", IsDefault = true, IsTemp = false },
|
||||
// new ExchangeOrganizationDomain { Identity = "org101\\org101.tempdomain.com", Name = "org101.tempdomain.com", IsDefault = false, IsTemp = true },
|
||||
// new ExchangeOrganizationDomain { Identity = "org101\\myseconddomain.com", Name = "myseconddomain.com", IsDefault = false, IsTemp = false }
|
||||
//};
|
||||
}
|
||||
|
||||
public static string GetExchangeOrganizationSummary(int itemId)
|
||||
{
|
||||
// load organization details
|
||||
ExchangeOrganization org = GetOrganizationDetails(itemId);
|
||||
if (org == null)
|
||||
return null; // organization not found
|
||||
|
||||
return GetExchangeOrganizationSummary(org);
|
||||
}
|
||||
|
||||
private static string GetExchangeOrganizationSummary(ExchangeOrganization org)
|
||||
{
|
||||
// evaluate template
|
||||
MailTemplate template = EvaluateOrganizationSummaryTemplate(org);
|
||||
if (template == null || template.Body == null)
|
||||
return null;
|
||||
|
||||
return template.IsHtml ? template.Body : template.Body.Replace("\n", "<br/>");
|
||||
}
|
||||
|
||||
private static MailTemplate EvaluateOrganizationSummaryTemplate(ExchangeOrganization org)
|
||||
{
|
||||
#region create template context
|
||||
Hashtable items = new Hashtable();
|
||||
|
||||
// add organization
|
||||
items["org"] = org;
|
||||
|
||||
// add package information
|
||||
PackageInfo space = PackageController.GetPackage(org.PackageId);
|
||||
items["space"] = space;
|
||||
|
||||
// add user information
|
||||
UserInfo user = UserController.GetUser(space.UserId);
|
||||
items["user"] = user;
|
||||
#endregion
|
||||
|
||||
#region load template
|
||||
// load template settings
|
||||
UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.EXCHANGE_HOSTED_EDITION_ORGANIZATION_SUMMARY);
|
||||
if(settings == null)
|
||||
return null;
|
||||
|
||||
// create template
|
||||
MailTemplate template = new MailTemplate();
|
||||
|
||||
// from
|
||||
template.From = settings["From"];
|
||||
|
||||
// BCC
|
||||
template.Bcc = settings["CC"];
|
||||
|
||||
// subject
|
||||
template.Subject = settings["Subject"];
|
||||
|
||||
// body
|
||||
template.IsHtml = user.HtmlMail;
|
||||
string bodySetting = template.IsHtml ? "HtmlBody" : "TextBody";
|
||||
template.Body = settings[bodySetting];
|
||||
|
||||
// priority
|
||||
string priority = settings["Priority"];
|
||||
template.Priority = String.IsNullOrEmpty(priority)
|
||||
? MailPriority.Normal
|
||||
: (MailPriority)Enum.Parse(typeof(MailPriority), priority, true);
|
||||
#endregion
|
||||
|
||||
#region evaluate template
|
||||
if(template.Subject != null)
|
||||
template.Subject = PackageController.EvaluateTemplate(template.Subject, items);
|
||||
|
||||
if(template.Body != null)
|
||||
template.Body = PackageController.EvaluateTemplate(template.Body, items);
|
||||
#endregion
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
private static PackageSettings GetExchangePackageSettings(ExchangeOrganization org)
|
||||
{
|
||||
// load package settings
|
||||
return PackageController.GetPackageSettings(org.PackageId, PackageSettings.EXCHANGE_HOSTED_EDITION);
|
||||
}
|
||||
|
||||
public static ResultObject SendExchangeOrganizationSummary(int itemId, string toEmail)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "SEND_SUMMARY");
|
||||
TaskManager.WriteParameter("Item ID", itemId);
|
||||
TaskManager.WriteParameter("To e-mail", toEmail);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// load organization details
|
||||
ExchangeOrganization org = GetOrganizationDetails(item.Id);
|
||||
if(org == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
// get evaluated summary information
|
||||
MailTemplate msg = EvaluateOrganizationSummaryTemplate(org);
|
||||
if (msg == null)
|
||||
return Error<ResultObject>(SendOrganizationTemplateNotSetError);
|
||||
|
||||
// send message
|
||||
int sendResult = MailHelper.SendMessage(msg.From, toEmail, msg.Bcc, msg.Subject, msg.Body, msg.Priority, msg.IsHtml);
|
||||
if (sendResult < 0)
|
||||
return Error<ResultObject>((-sendResult).ToString());
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(SendOrganizationSummaryError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject AddOrganizationDomain(int itemId, string domainName)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "ADD_DOMAIN");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
TaskManager.WriteParameter("domain", domainName);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get organization details
|
||||
ExchangeOrganization org = GetOrganizationDetails(item.Id);
|
||||
if (org == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
// check domains quota
|
||||
if(org.MaxDomainsCountQuota > -1 && org.Domains.Length >= org.MaxDomainsCountQuota)
|
||||
return Error<IntResult>(AddDomainQuotaExceededError);
|
||||
|
||||
// check if the domain already exists
|
||||
DomainInfo domain = null;
|
||||
int checkResult = ServerController.CheckDomain(domainName);
|
||||
if (checkResult == BusinessErrorCodes.ERROR_DOMAIN_ALREADY_EXISTS)
|
||||
{
|
||||
// domain exists
|
||||
// check if it belongs to the same space
|
||||
domain = ServerController.GetDomain(domainName);
|
||||
if (domain == null)
|
||||
return Error<ResultObject>((-checkResult).ToString());
|
||||
|
||||
if (domain.PackageId != org.PackageId)
|
||||
return Error<ResultObject>((-checkResult).ToString());
|
||||
|
||||
// check if domain is already used in this organization
|
||||
foreach (ExchangeOrganizationDomain orgDomain in org.Domains)
|
||||
{
|
||||
if(String.Equals(orgDomain.Name, domainName, StringComparison.InvariantCultureIgnoreCase))
|
||||
return Error<ResultObject>(AddDomainAlreadyUsedError);
|
||||
}
|
||||
}
|
||||
else if (checkResult == BusinessErrorCodes.ERROR_RESTRICTED_DOMAIN)
|
||||
{
|
||||
return Error<ResultObject>((-checkResult).ToString());
|
||||
}
|
||||
|
||||
// create domain if required
|
||||
if (domain == null)
|
||||
{
|
||||
domain = new DomainInfo();
|
||||
domain.PackageId = org.PackageId;
|
||||
domain.DomainName = domainName;
|
||||
domain.IsInstantAlias = false;
|
||||
domain.IsSubDomain = false;
|
||||
|
||||
int domainId = ServerController.AddDomain(domain);
|
||||
if (domainId < 0)
|
||||
return Error<ResultObject>((-domainId).ToString());
|
||||
|
||||
// add domain
|
||||
domain.DomainId = domainId;
|
||||
}
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// add domain
|
||||
exchange.AddOrganizationDomain(item.Name, domainName);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(AddDomainError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject DeleteOrganizationDomain(int itemId, string domainName)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "DELETE_DOMAIN");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
TaskManager.WriteParameter("domain", domainName);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// delete domain
|
||||
exchange.DeleteOrganizationDomain(item.Name, domainName);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(DeleteDomainError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject UpdateOrganizationQuotas(int itemId, int mailboxesNumber, int contactsNumber, int distributionListsNumber)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "UPDATE_QUOTAS");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
TaskManager.WriteParameter("mailboxesNumber", mailboxesNumber);
|
||||
TaskManager.WriteParameter("contactsNumber", contactsNumber);
|
||||
TaskManager.WriteParameter("distributionListsNumber", distributionListsNumber);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// check quotas
|
||||
UpdateOrganizationQuotas(item);
|
||||
|
||||
if(item.MaxMailboxCountQuota > -1 && mailboxesNumber > item.MaxMailboxCountQuota)
|
||||
return Error<ResultObject>(UpdateQuotasWrongQuotaError);
|
||||
if (item.MaxContactCountQuota > -1 && contactsNumber > item.MaxContactCountQuota)
|
||||
return Error<ResultObject>(UpdateQuotasWrongQuotaError);
|
||||
if (item.MaxDistributionListCountQuota > -1 && distributionListsNumber > item.MaxDistributionListCountQuota)
|
||||
return Error<ResultObject>(UpdateQuotasWrongQuotaError);
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// update quotas
|
||||
exchange.UpdateOrganizationQuotas(item.Name, mailboxesNumber, contactsNumber, distributionListsNumber);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(UpdateQuotasError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject UpdateOrganizationCatchAllAddress(int itemId, string catchAllEmail)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "UPDATE_CATCHALL");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
TaskManager.WriteParameter("catchAllEmail", catchAllEmail);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// update catch-all
|
||||
exchange.UpdateOrganizationCatchAllAddress(item.Name, catchAllEmail);
|
||||
|
||||
// save new catch-all in the item
|
||||
item.CatchAllAddress = catchAllEmail;
|
||||
PackageController.UpdatePackageItem(item);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(UpdateCatchAllError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject UpdateOrganizationServicePlan(int itemId, int newServiceId)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "UPDATE_SERVICE");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
TaskManager.WriteParameter("newServiceId", newServiceId);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// load service settings to know ProgramID, OfferID
|
||||
StringDictionary serviceSettings = ServerController.GetServiceSettings(newServiceId);
|
||||
string programId = serviceSettings["programID"];
|
||||
string offerId = serviceSettings["offerID"];
|
||||
|
||||
// check settings
|
||||
if(String.IsNullOrEmpty(programId))
|
||||
result.ErrorCodes.Add(ProgramIdIsNotSetError);
|
||||
if (String.IsNullOrEmpty(offerId))
|
||||
result.ErrorCodes.Add(OfferIdIsNotSetError);
|
||||
|
||||
// update service plan
|
||||
exchange.UpdateOrganizationServicePlan(item.Name, programId, offerId);
|
||||
|
||||
// move item between services
|
||||
int moveResult = PackageController.MovePackageItem(itemId, newServiceId);
|
||||
if (moveResult < 0)
|
||||
return Error<ResultObject>((-moveResult).ToString());
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(UpdateServicePlanError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultObject DeleteOrganization(int itemId)
|
||||
{
|
||||
ResultObject result = new ResultObject();
|
||||
result.IsSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
// initialize task manager
|
||||
TaskManager.StartTask(TaskManagerSource, "DELETE_ORGANIZATION");
|
||||
TaskManager.WriteParameter("itemId", itemId);
|
||||
|
||||
// load organization item
|
||||
ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization;
|
||||
if (item == null)
|
||||
return Error<ResultObject>(OrganizationNotFoundError);
|
||||
|
||||
#region Check Space and Account
|
||||
// Check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
return Warning<ResultObject>((-accountCheck).ToString());
|
||||
|
||||
// Check space
|
||||
int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0)
|
||||
return Warning<ResultObject>((-packageCheck).ToString());
|
||||
#endregion
|
||||
|
||||
// get Exchange service
|
||||
ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId);
|
||||
|
||||
// delete organization
|
||||
exchange.DeleteOrganization(item.Name);
|
||||
|
||||
// delete meta-item
|
||||
PackageController.DeletePackageItem(itemId);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<ResultObject>(DeleteOrganizationError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
#region Private helpers
|
||||
public static ExchangeServerHostedEdition GetExchangeService(int serviceId)
|
||||
{
|
||||
ExchangeServerHostedEdition ws = new ExchangeServerHostedEdition();
|
||||
ServiceProviderProxy.Init(ws, serviceId);
|
||||
return ws;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Result object routines
|
||||
private static T Warning<T>(params string[] messageParts)
|
||||
{
|
||||
return Warning<T>(null, messageParts);
|
||||
}
|
||||
|
||||
private static T Warning<T>(ResultObject innerResult, params string[] messageParts)
|
||||
{
|
||||
return Result<T>(innerResult, false, messageParts);
|
||||
}
|
||||
|
||||
private static T Error<T>(params string[] messageParts)
|
||||
{
|
||||
return Error<T>(null, messageParts);
|
||||
}
|
||||
|
||||
private static T Error<T>(ResultObject innerResult, params string[] messageParts)
|
||||
{
|
||||
return Result<T>(innerResult, true, messageParts);
|
||||
}
|
||||
|
||||
private static T Result<T>(ResultObject innerResult, bool isError, params string[] messageParts)
|
||||
{
|
||||
object obj = Activator.CreateInstance<T>();
|
||||
ResultObject result = (ResultObject)obj;
|
||||
|
||||
// set error
|
||||
result.IsSuccess = !isError;
|
||||
|
||||
// add message
|
||||
if (messageParts != null)
|
||||
result.ErrorCodes.Add(String.Join(":", messageParts));
|
||||
|
||||
// copy errors from inner result
|
||||
if (innerResult != null)
|
||||
result.ErrorCodes.AddRange(innerResult.ErrorCodes);
|
||||
|
||||
return (T)obj;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -74,7 +74,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
int res = ServerController.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, ip, 0);
|
||||
int res = ServerController.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, ip, 0, 0, 0, 0);
|
||||
if (res != 0)
|
||||
{
|
||||
CompleteTask(ret, CrmErrorCodes.CANNOT_CREATE_DNS_ZONE, null,
|
||||
|
|
|
@ -0,0 +1,826 @@
|
|||
// Copyright (c) 2012, 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.Collections.Specialized;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using WebsitePanel.Providers;
|
||||
using WebsitePanel.Providers.Common;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.Lync;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
|
||||
{
|
||||
public class LyncController
|
||||
{
|
||||
|
||||
|
||||
public static LyncServer GetLyncServer(int lyncServiceId, int organizationServiceId)
|
||||
{
|
||||
LyncServer ws = new LyncServer();
|
||||
|
||||
ServiceProviderProxy.Init(ws, lyncServiceId);
|
||||
|
||||
string[] lyncSettings = ws.ServiceProviderSettingsSoapHeaderValue.Settings;
|
||||
|
||||
List<string> resSettings = new List<string>(lyncSettings);
|
||||
|
||||
ExtendLyncSettings(resSettings, "primarydomaincontroller", GetProviderProperty(organizationServiceId, "primarydomaincontroller"));
|
||||
ExtendLyncSettings(resSettings, "rootou", GetProviderProperty(organizationServiceId, "rootou"));
|
||||
ws.ServiceProviderSettingsSoapHeaderValue.Settings = resSettings.ToArray();
|
||||
return ws;
|
||||
}
|
||||
|
||||
private static string GetProviderProperty(int organizationServiceId, string property)
|
||||
{
|
||||
|
||||
Organizations orgProxy = new Organizations();
|
||||
|
||||
ServiceProviderProxy.Init(orgProxy, organizationServiceId);
|
||||
|
||||
string[] organizationSettings = orgProxy.ServiceProviderSettingsSoapHeaderValue.Settings;
|
||||
|
||||
string value = string.Empty;
|
||||
foreach (string str in organizationSettings)
|
||||
{
|
||||
string[] props = str.Split('=');
|
||||
if (props[0].ToLower() == property)
|
||||
{
|
||||
value = str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void ExtendLyncSettings(List<string> lyncSettings, string property, string value)
|
||||
{
|
||||
bool isAdded = false;
|
||||
for (int i = 0; i < lyncSettings.Count; i++)
|
||||
{
|
||||
string[] props = lyncSettings[i].Split('=');
|
||||
if (props[0].ToLower() == property)
|
||||
{
|
||||
lyncSettings[i] = value;
|
||||
isAdded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAdded)
|
||||
{
|
||||
lyncSettings.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetLyncServiceID(int packageId)
|
||||
{
|
||||
return PackageController.GetPackageServiceId(packageId, ResourceGroups.Lync);
|
||||
}
|
||||
|
||||
|
||||
private static bool CheckQuota(int itemId)
|
||||
{
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
|
||||
|
||||
IntResult userCount = GetLyncUsersCount(itemId);
|
||||
|
||||
int allocatedUsers = cntx.Quotas[Quotas.LYNC_USERS].QuotaAllocatedValue;
|
||||
|
||||
return allocatedUsers == -1 || allocatedUsers > userCount.Value;
|
||||
}
|
||||
|
||||
|
||||
public static LyncUserResult CreateLyncUser(int itemId, int accountId, int lyncUserPlanId)
|
||||
{
|
||||
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "CREATE_LYNC_USER");
|
||||
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.NOT_AUTHORIZED);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
LyncUser retLyncUser = new LyncUser();
|
||||
bool isLyncUser;
|
||||
|
||||
isLyncUser = DataProvider.CheckLyncUserExists(accountId);
|
||||
if (isLyncUser)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.USER_IS_ALREADY_LYNC_USER);
|
||||
return res;
|
||||
}
|
||||
|
||||
OrganizationUser user;
|
||||
user = OrganizationController.GetAccount(itemId, accountId);
|
||||
if (user == null)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_GET_ACCOUNT);
|
||||
return res;
|
||||
}
|
||||
|
||||
user = OrganizationController.GetUserGeneralSettings(itemId, accountId);
|
||||
if (string.IsNullOrEmpty(user.FirstName))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.USER_FIRST_NAME_IS_NOT_SPECIFIED);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(user.LastName))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.USER_LAST_NAME_IS_NOT_SPECIFIED);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool quota = CheckQuota(itemId);
|
||||
if (!quota)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.USER_QUOTA_HAS_BEEN_REACHED);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
LyncServer lync;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
bool bReloadConfiguration = false;
|
||||
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
if (string.IsNullOrEmpty(org.LyncTenantId))
|
||||
{
|
||||
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
|
||||
|
||||
org.LyncTenantId = lync.CreateOrganization(org.OrganizationId,
|
||||
org.DefaultDomain,
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_ALLOWVIDEO].QuotaAllocatedValue),
|
||||
Convert.ToInt32(cntx.Quotas[Quotas.LYNC_MAXPARTICIPANTS].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue));
|
||||
|
||||
if (string.IsNullOrEmpty(org.LyncTenantId))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ENABLE_ORG);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
PackageController.UpdatePackageItem(org);
|
||||
|
||||
bReloadConfiguration = true;
|
||||
}
|
||||
}
|
||||
|
||||
LyncUserPlan plan = GetLyncUserPlan(itemId, lyncUserPlanId);
|
||||
|
||||
if (!lync.CreateUser(org.OrganizationId, user.PrimaryEmailAddress, plan))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (bReloadConfiguration)
|
||||
{
|
||||
LyncControllerAsync userWorker = new LyncControllerAsync();
|
||||
userWorker.LyncServiceId = lyncServiceId;
|
||||
userWorker.OrganizationServiceId = org.ServiceId;
|
||||
userWorker.Enable_CsComputerAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DataProvider.AddLyncUser(accountId, lyncUserPlanId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER_TO_DATABASE, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
res.IsSuccess = true;
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static int[] ParseMultiSetting(int lyncServiceId, string settingName)
|
||||
{
|
||||
List<int> retIds = new List<int>();
|
||||
StringDictionary settings = ServerController.GetServiceSettings(lyncServiceId);
|
||||
if (!String.IsNullOrEmpty(settings[settingName]))
|
||||
{
|
||||
string[] ids = settings[settingName].Split(',');
|
||||
|
||||
int res;
|
||||
foreach (string id in ids)
|
||||
{
|
||||
if (int.TryParse(id, out res))
|
||||
retIds.Add(res);
|
||||
}
|
||||
}
|
||||
|
||||
if (retIds.Count == 0)
|
||||
retIds.Add(lyncServiceId);
|
||||
|
||||
return retIds.ToArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void GetLyncServices(int lyncServiceId, out int[] lyncServiceIds)
|
||||
{
|
||||
lyncServiceIds = ParseMultiSetting(lyncServiceId, "LyncServersServiceID");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static LyncUser GetLyncUserGeneralSettings(int itemId, int accountId)
|
||||
{
|
||||
TaskManager.StartTask("LYNC", "GET_LYNC_USER_GENERAL_SETTINGS");
|
||||
|
||||
LyncUser user = null;
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
OrganizationUser usr;
|
||||
usr = OrganizationController.GetAccount(itemId, accountId);
|
||||
|
||||
if (usr != null)
|
||||
user = lync.GetLyncUserGeneralSettings(org.OrganizationId, usr.PrimaryEmailAddress);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
LyncUserPlan plan = ObjectUtils.FillObjectFromDataReader<LyncUserPlan>(DataProvider.GetLyncUserPlanByAccountId(accountId));
|
||||
|
||||
if (plan != null)
|
||||
{
|
||||
user.LyncUserPlanId = plan.LyncUserPlanId;
|
||||
user.LyncUserPlanName = plan.LyncUserPlanName;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
|
||||
}
|
||||
TaskManager.CompleteTask();
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
public static int DeleteOrganization(int itemId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("LYNC", "DELETE_ORG");
|
||||
TaskManager.ItemId = itemId;
|
||||
|
||||
try
|
||||
{
|
||||
// delete organization in Exchange
|
||||
//System.Threading.Thread.Sleep(5000);
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
bool successful = lync.DeleteOrganization(org.OrganizationId, org.DefaultDomain);
|
||||
|
||||
return successful ? 0 : BusinessErrorCodes.ERROR_LYNC_DELETE_SOME_PROBLEMS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static LyncUserResult SetUserLyncPlan(int itemId, int accountId, int lyncUserPlanId)
|
||||
{
|
||||
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "SET_LYNC_USER_LYNCPLAN");
|
||||
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.NOT_AUTHORIZED);
|
||||
return res;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
LyncUserPlan plan = GetLyncUserPlan(itemId, lyncUserPlanId);
|
||||
|
||||
OrganizationUser user;
|
||||
user = OrganizationController.GetAccount(itemId, accountId);
|
||||
|
||||
if (!lync.SetLyncUserPlan(org.OrganizationId, user.PrimaryEmailAddress, plan))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER);
|
||||
return res;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DataProvider.SetLyncUserLyncUserplan(accountId, lyncUserPlanId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER_TO_DATABASE, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
res.IsSuccess = true;
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_UPDATE_LYNC_USER, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static LyncUsersPagedResult GetLyncUsers(int itemId, string sortColumn, string sortDirection, int startRow, int count)
|
||||
{
|
||||
LyncUsersPagedResult res = TaskManager.StartResultTask<LyncUsersPagedResult>("LYNC", "GET_LYNC_USERS");
|
||||
|
||||
try
|
||||
{
|
||||
IDataReader reader =
|
||||
DataProvider.GetLyncUsers(itemId, sortColumn, sortDirection, startRow, count);
|
||||
List<LyncUser> accounts = new List<LyncUser>();
|
||||
ObjectUtils.FillCollectionFromDataReader(accounts, reader);
|
||||
res.Value = new LyncUsersPaged { PageUsers = accounts.ToArray() };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.GET_LYNC_USERS, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
IntResult intRes = GetLyncUsersCount(itemId);
|
||||
res.ErrorCodes.AddRange(intRes.ErrorCodes);
|
||||
if (!intRes.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res);
|
||||
return res;
|
||||
}
|
||||
res.Value.RecordsCount = intRes.Value;
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<LyncUser> GetLyncUsersByPlanId(int itemId, int planId)
|
||||
{
|
||||
return ObjectUtils.CreateListFromDataReader<LyncUser>(DataProvider.GetLyncUsersByPlanId(itemId, planId));
|
||||
}
|
||||
|
||||
public static IntResult GetLyncUsersCount(int itemId)
|
||||
{
|
||||
IntResult res = TaskManager.StartResultTask<IntResult>("LYNC", "GET_LYNC_USERS_COUNT");
|
||||
try
|
||||
{
|
||||
res.Value = DataProvider.GetLyncUsersCount(itemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.GET_LYNC_USER_COUNT, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static LyncUserResult DeleteLyncUser(int itemId, int accountId)
|
||||
{
|
||||
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "DELETE_LYNC_USER");
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
||||
if (accountCheck < 0)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.NOT_AUTHORIZED);
|
||||
return res;
|
||||
}
|
||||
|
||||
LyncServer lync;
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
OrganizationUser user;
|
||||
user = OrganizationController.GetAccount(itemId, accountId);
|
||||
|
||||
if (user != null)
|
||||
lync.DeleteUser(user.PrimaryEmailAddress);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_DELETE_LYNC_USER, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DataProvider.DeleteLyncUser(accountId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_DELETE_LYNC_USER_FROM_METADATA, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static Organization GetOrganization(int itemId)
|
||||
{
|
||||
return (Organization)PackageController.GetPackageItem(itemId);
|
||||
}
|
||||
|
||||
|
||||
#region Lync Plans
|
||||
public static List<LyncUserPlan> GetLyncUserPlans(int itemId)
|
||||
{
|
||||
// place log record
|
||||
TaskManager.StartTask("LYNC", "GET_LYNC_LYNCUSERPLANS");
|
||||
TaskManager.ItemId = itemId;
|
||||
|
||||
try
|
||||
{
|
||||
return ObjectUtils.CreateListFromDataReader<LyncUserPlan>(
|
||||
DataProvider.GetLyncUserPlans(itemId));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static LyncUserPlan GetLyncUserPlan(int itemID, int lyncUserPlanId)
|
||||
{
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("LYNC", "GET_LYNC_LYNCUSERPLAN");
|
||||
TaskManager.ItemId = lyncUserPlanId;
|
||||
|
||||
try
|
||||
{
|
||||
return ObjectUtils.FillObjectFromDataReader<LyncUserPlan>(
|
||||
DataProvider.GetLyncUserPlan(lyncUserPlanId));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int AddLyncUserPlan(int itemID, LyncUserPlan lyncUserPlan)
|
||||
{
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("LYNC", "ADD_LYNC_LYNCUSERPLAN");
|
||||
TaskManager.ItemId = itemID;
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = GetOrganization(itemID);
|
||||
if (org == null)
|
||||
return -1;
|
||||
|
||||
// load package context
|
||||
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
|
||||
|
||||
lyncUserPlan.Conferencing = lyncUserPlan.Conferencing & Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue);
|
||||
lyncUserPlan.EnterpriseVoice = lyncUserPlan.EnterpriseVoice & Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_ENTERPRISEVOICE].QuotaAllocatedValue);
|
||||
if (!lyncUserPlan.EnterpriseVoice)
|
||||
lyncUserPlan.VoicePolicy = LyncVoicePolicyType.None;
|
||||
lyncUserPlan.IM = true;
|
||||
|
||||
return DataProvider.AddLyncUserPlan(itemID, lyncUserPlan);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int DeleteLyncUserPlan(int itemID, int lyncUserPlanId)
|
||||
{
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
TaskManager.StartTask("LYNC", "DELETE_LYNC_LYNCPLAN");
|
||||
TaskManager.ItemId = itemID;
|
||||
|
||||
try
|
||||
{
|
||||
DataProvider.DeleteLyncUserPlan(lyncUserPlanId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int SetOrganizationDefaultLyncUserPlan(int itemId, int lyncUserPlanId)
|
||||
{
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
TaskManager.StartTask("LYNC", "SET_LYNC_LYNCUSERPLAN");
|
||||
TaskManager.ItemId = itemId;
|
||||
|
||||
try
|
||||
{
|
||||
DataProvider.SetOrganizationDefaultLyncUserPlan(itemId, lyncUserPlanId);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Federation Domains
|
||||
public static LyncFederationDomain[] GetFederationDomains(int itemId)
|
||||
{
|
||||
// place log record
|
||||
TaskManager.StartTask("LYNC", "GET_LYNC_FEDERATIONDOMAINS");
|
||||
TaskManager.ItemId = itemId;
|
||||
|
||||
LyncFederationDomain[] lyncFederationDomains = null;
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
lyncFederationDomains = lync.GetFederationDomains(org.OrganizationId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return lyncFederationDomains;
|
||||
}
|
||||
|
||||
public static LyncUserResult AddFederationDomain(int itemId, string domainName, string proxyFqdn)
|
||||
{
|
||||
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "ADD_LYNC_FEDERATIONDOMAIN");
|
||||
TaskManager.ItemId = itemId;
|
||||
TaskManager.TaskParameters["domainName"] = domainName;
|
||||
TaskManager.TaskParameters["proxyFqdn"] = proxyFqdn;
|
||||
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
||||
if (accountCheck < 0)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.NOT_AUTHORIZED);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
if (string.IsNullOrEmpty(org.LyncTenantId))
|
||||
{
|
||||
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
|
||||
|
||||
org.LyncTenantId = lync.CreateOrganization(org.OrganizationId,
|
||||
org.DefaultDomain,
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_ALLOWVIDEO].QuotaAllocatedValue),
|
||||
Convert.ToInt32(cntx.Quotas[Quotas.LYNC_MAXPARTICIPANTS].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue),
|
||||
Convert.ToBoolean(cntx.Quotas[Quotas.LYNC_CONFERENCING].QuotaAllocatedValue));
|
||||
|
||||
if (string.IsNullOrEmpty(org.LyncTenantId))
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ENABLE_ORG);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
PackageController.UpdatePackageItem(org);
|
||||
}
|
||||
|
||||
lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
lync.AddFederationDomain(org.OrganizationId, domainName, proxyFqdn);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_FEDERATIONDOMAIN, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static LyncUserResult RemoveFederationDomain(int itemId, string domainName)
|
||||
{
|
||||
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "REMOVE_LYNC_FEDERATIONDOMAIN");
|
||||
TaskManager.ItemId = itemId;
|
||||
TaskManager.TaskParameters["domainName"] = domainName;
|
||||
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
||||
if (accountCheck < 0)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.NOT_AUTHORIZED);
|
||||
return res;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
throw new ApplicationException(
|
||||
string.Format("Organization is null. ItemId={0}", itemId));
|
||||
}
|
||||
|
||||
int lyncServiceId = GetLyncServiceID(org.PackageId);
|
||||
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
|
||||
|
||||
if (org.OrganizationId.ToLower() == domainName.ToLower())
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_REMOVE_LYNC_FEDERATIONDOMAIN);
|
||||
return res;
|
||||
}
|
||||
|
||||
lync.RemoveFederationDomain(org.OrganizationId, domainName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_REMOVE_LYNC_FEDERATIONDOMAIN, ex);
|
||||
return res;
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private methods
|
||||
public static UInt64 ConvertPhoneNumberToLong(string ip)
|
||||
{
|
||||
return Convert.ToUInt64(ip);
|
||||
}
|
||||
|
||||
public static string ConvertLongToPhoneNumber(UInt64 ip)
|
||||
{
|
||||
if (ip == 0)
|
||||
return "";
|
||||
|
||||
return ip.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) 2012, 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.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WebsitePanel.Providers;
|
||||
using WebsitePanel.Providers.Common;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.Lync;
|
||||
using WebsitePanel.EnterpriseServer.Code.HostedSolution;
|
||||
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
|
||||
{
|
||||
public class LyncControllerAsync
|
||||
{
|
||||
private int lyncServiceId;
|
||||
private int organizationServiceId;
|
||||
|
||||
public int LyncServiceId
|
||||
{
|
||||
get { return this.lyncServiceId; }
|
||||
set { this.lyncServiceId = value; }
|
||||
}
|
||||
|
||||
public int OrganizationServiceId
|
||||
{
|
||||
get { return this.organizationServiceId; }
|
||||
set { this.organizationServiceId = value; }
|
||||
}
|
||||
|
||||
|
||||
public void Enable_CsComputerAsync()
|
||||
{
|
||||
// start asynchronously
|
||||
Thread t = new Thread(new ThreadStart(Enable_CsComputer));
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private void Enable_CsComputer()
|
||||
{
|
||||
int[] lyncServiceIds;
|
||||
|
||||
LyncController.GetLyncServices(lyncServiceId, out lyncServiceIds);
|
||||
|
||||
foreach (int id in lyncServiceIds)
|
||||
{
|
||||
LyncServer lync = null;
|
||||
try
|
||||
{
|
||||
lync = LyncController.GetLyncServer(id, organizationServiceId);
|
||||
if (lync != null)
|
||||
{
|
||||
lync.ReloadConfiguration();
|
||||
}
|
||||
}
|
||||
catch (Exception exe)
|
||||
{
|
||||
TaskManager.WriteError(exe);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -40,6 +40,11 @@ using WebsitePanel.Providers.HostedSolution;
|
|||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.SharePoint;
|
||||
using WebsitePanel.Providers.Common;
|
||||
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
public class OrganizationController
|
||||
|
@ -352,6 +357,62 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
PackageController.AddPackageItem(orgDomain);
|
||||
|
||||
|
||||
if (cntx.Quotas[Quotas.EXCHANGE2007_MAILBOXES] != null)
|
||||
{
|
||||
// 5) Create default mailbox plans
|
||||
// load user info
|
||||
UserInfo user = PackageController.GetPackageOwner(org.PackageId);
|
||||
|
||||
// get settings
|
||||
UserSettings userSettings = UserController.GetUserSettings(user.UserId, "ExchangeMailboxPlansPolicy");
|
||||
|
||||
if (!string.IsNullOrEmpty(userSettings[UserSettings.DEFAULT_MAILBOXPLANS]))
|
||||
{
|
||||
|
||||
List<ExchangeMailboxPlan> list = new List<ExchangeMailboxPlan>();
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(list.GetType());
|
||||
|
||||
StringReader reader = new StringReader(userSettings[UserSettings.DEFAULT_MAILBOXPLANS]);
|
||||
|
||||
list = (List<ExchangeMailboxPlan>)serializer.Deserialize(reader);
|
||||
|
||||
foreach (ExchangeMailboxPlan p in list)
|
||||
{
|
||||
ExchangeServerController.AddExchangeMailboxPlan(itemId, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cntx.Quotas[Quotas.LYNC_USERS] != null)
|
||||
{
|
||||
// 5) Create default mailbox plans
|
||||
// load user info
|
||||
UserInfo user = PackageController.GetPackageOwner(org.PackageId);
|
||||
|
||||
// get settings
|
||||
UserSettings userSettings = UserController.GetUserSettings(user.UserId, "LyncUserPlansPolicy");
|
||||
|
||||
if (!string.IsNullOrEmpty(userSettings[UserSettings.DEFAULT_LYNCUSERPLANS]))
|
||||
{
|
||||
|
||||
List<LyncUserPlan> list = new List<LyncUserPlan>();
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(list.GetType());
|
||||
|
||||
StringReader reader = new StringReader(userSettings[UserSettings.DEFAULT_LYNCUSERPLANS]);
|
||||
|
||||
list = (List<LyncUserPlan>)serializer.Deserialize(reader);
|
||||
|
||||
foreach (LyncUserPlan p in list)
|
||||
{
|
||||
LyncController.AddLyncUserPlan(itemId, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -482,6 +543,66 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool DeleteLyncUsers(int itemId)
|
||||
{
|
||||
bool successful = false;
|
||||
|
||||
try
|
||||
{
|
||||
LyncUsersPagedResult res = LyncController.GetLyncUsers(itemId, string.Empty, string.Empty, 0, int.MaxValue);
|
||||
|
||||
if (res.IsSuccess)
|
||||
{
|
||||
successful = true;
|
||||
foreach (LyncUser user in res.Value.PageUsers)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultObject delUserResult = LyncController.DeleteLyncUser(itemId, user.AccountID);
|
||||
if (!delUserResult.IsSuccess)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (string str in delUserResult.ErrorCodes)
|
||||
{
|
||||
sb.Append(str);
|
||||
sb.Append('\n');
|
||||
}
|
||||
|
||||
throw new ApplicationException(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
successful = false;
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (string str in res.ErrorCodes)
|
||||
{
|
||||
sb.Append(str);
|
||||
sb.Append('\n');
|
||||
}
|
||||
|
||||
throw new ApplicationException(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
successful = false;
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
|
||||
public static int DeleteOrganization(int itemId)
|
||||
{
|
||||
// check account
|
||||
|
@ -570,7 +691,22 @@ namespace WebsitePanel.EnterpriseServer
|
|||
successful = false;
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
|
||||
|
||||
//Cleanup Lync
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(org.LyncTenantId))
|
||||
if (DeleteLyncUsers(itemId))
|
||||
LyncController.DeleteOrganization(itemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
successful = false;
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
|
||||
|
||||
//Cleanup Exchange
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(org.GlobalAddressList))
|
||||
|
@ -633,7 +769,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
|
||||
private static Organizations GetOrganizationProxy(int serviceId)
|
||||
public static Organizations GetOrganizationProxy(int serviceId)
|
||||
{
|
||||
Organizations ws = new Organizations();
|
||||
ServiceProviderProxy.Init(ws, serviceId);
|
||||
|
@ -710,9 +846,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
org.Id = 1;
|
||||
org.OrganizationId = "fabrikam";
|
||||
org.Name = "Fabrikam Inc";
|
||||
org.IssueWarningKB = 150000;
|
||||
org.ProhibitSendKB = 170000;
|
||||
org.ProhibitSendReceiveKB = 190000;
|
||||
org.KeepDeletedItemsDays = 14;
|
||||
org.GlobalAddressList = "FabrikamGAL";
|
||||
return org;
|
||||
|
@ -794,6 +927,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.AllocatedOCSUsers = cntx.Quotas[Quotas.OCS_USERS].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
if (cntx.Groups.ContainsKey(ResourceGroups.Lync))
|
||||
{
|
||||
stats.CreatedLyncUsers = LyncController.GetLyncUsersCount(org.Id).Value;
|
||||
stats.AllocatedLyncUsers = cntx.Quotas[Quotas.LYNC_USERS].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
@ -980,8 +1118,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
OrganizationUsersPaged result = new OrganizationUsersPaged();
|
||||
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];
|
||||
|
||||
List<OrganizationUser> Tmpaccounts = new List<OrganizationUser>();
|
||||
ObjectUtils.FillCollectionFromDataView(Tmpaccounts, ds.Tables[1].DefaultView);
|
||||
result.PageUsers = Tmpaccounts.ToArray();
|
||||
|
||||
List<OrganizationUser> accounts = new List<OrganizationUser>();
|
||||
ObjectUtils.FillCollectionFromDataView(accounts, ds.Tables[1].DefaultView);
|
||||
|
||||
foreach (OrganizationUser user in Tmpaccounts.ToArray())
|
||||
{
|
||||
accounts.Add(GetUserGeneralSettings(itemId, user.AccountId));
|
||||
}
|
||||
|
||||
result.PageUsers = accounts.ToArray();
|
||||
return result;
|
||||
}
|
||||
|
@ -993,22 +1140,23 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return DataProvider.ExchangeAccountEmailAddressExists(emailAddress);
|
||||
}
|
||||
|
||||
|
||||
private static int AddOrganizationUser(int itemId, string accountName, string displayName, string email, string accountPassword)
|
||||
{
|
||||
|
||||
private static int AddOrganizationUser(int itemId, string accountName, string displayName, string email, string sAMAccountName, string accountPassword, string subscriberNumber)
|
||||
{
|
||||
return DataProvider.AddExchangeAccount(itemId, (int)ExchangeAccountType.User, accountName, displayName, email, false, string.Empty,
|
||||
string.Empty, CryptoUtils.Encrypt(accountPassword));
|
||||
|
||||
}
|
||||
sAMAccountName, CryptoUtils.Encrypt(accountPassword), 0, subscriberNumber.Trim());
|
||||
|
||||
}
|
||||
|
||||
public static string GetAccountName(string loginName)
|
||||
{
|
||||
string []parts = loginName.Split('@');
|
||||
return parts != null && parts.Length > 1 ? parts[0] : loginName;
|
||||
//string []parts = loginName.Split('@');
|
||||
//return parts != null && parts.Length > 1 ? parts[0] : loginName;
|
||||
return loginName;
|
||||
|
||||
}
|
||||
|
||||
public static int CreateUser(int itemId, string displayName, string name, string domain, string password, bool enabled, bool sendNotification, string to, out string accountName)
|
||||
public static int CreateUser(int itemId, string displayName, string name, string domain, string password, string subscriberNumber, bool enabled, bool sendNotification, string to, out string accountName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(displayName))
|
||||
throw new ArgumentNullException("displayName");
|
||||
|
@ -1023,55 +1171,171 @@ namespace WebsitePanel.EnterpriseServer
|
|||
throw new ArgumentNullException("password");
|
||||
|
||||
accountName = string.Empty;
|
||||
|
||||
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("ORGANIZATION", "CREATE_USER");
|
||||
TaskManager.ItemId = itemId;
|
||||
TaskManager.Write("Organization ID :" + itemId);
|
||||
TaskManager.Write("name :" + name);
|
||||
TaskManager.Write("domain :" + domain);
|
||||
TaskManager.Write("subscriberNumber :" + subscriberNumber);
|
||||
|
||||
// e-mail
|
||||
string email = name + "@" + domain;
|
||||
int userId = -1;
|
||||
|
||||
if (EmailAddressExists(email))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_EMAIL_EXISTS;
|
||||
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
if (org == null)
|
||||
return -1;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(org.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
int errorCode;
|
||||
if (!CheckUserQuota(org.Id, out errorCode))
|
||||
return errorCode;
|
||||
|
||||
|
||||
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
string upn = string.Format("{0}@{1}", name, domain);
|
||||
accountName = BuildAccountName(org.OrganizationId, name);
|
||||
orgProxy.CreateUser(org.OrganizationId, accountName, displayName, upn, password, enabled);
|
||||
|
||||
int userId = AddOrganizationUser(itemId, accountName, displayName, email, password);
|
||||
|
||||
// register email address
|
||||
AddAccountEmailAddress(userId, email);
|
||||
|
||||
if (sendNotification)
|
||||
try
|
||||
{
|
||||
SendSummaryLetter(org.Id, userId, true, to, "");
|
||||
displayName = displayName.Trim();
|
||||
name = name.Trim();
|
||||
domain = domain.Trim();
|
||||
|
||||
// e-mail
|
||||
string email = name + "@" + domain;
|
||||
|
||||
if (EmailAddressExists(email))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_EMAIL_EXISTS;
|
||||
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
if (org == null)
|
||||
return -1;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(org.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
int errorCode;
|
||||
if (!CheckUserQuota(org.Id, out errorCode))
|
||||
return errorCode;
|
||||
|
||||
|
||||
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
string upn = string.Format("{0}@{1}", name, domain);
|
||||
string sAMAccountName = BuildAccountName(org.OrganizationId, name);
|
||||
|
||||
TaskManager.Write("accountName :" + sAMAccountName);
|
||||
TaskManager.Write("upn :" + upn);
|
||||
|
||||
if (orgProxy.CreateUser(org.OrganizationId, sAMAccountName, displayName, upn, password, enabled) == 0)
|
||||
{
|
||||
OrganizationUser retUser = orgProxy.GetUserGeneralSettings(upn, org.OrganizationId);
|
||||
TaskManager.Write("sAMAccountName :" + retUser.DomainUserName);
|
||||
|
||||
userId = AddOrganizationUser(itemId, upn, displayName, email, retUser.DomainUserName, password, subscriberNumber);
|
||||
accountName = upn;
|
||||
|
||||
// register email address
|
||||
AddAccountEmailAddress(userId, email);
|
||||
|
||||
if (sendNotification)
|
||||
{
|
||||
SendSummaryLetter(org.Id, userId, true, to, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskManager.WriteError("Failed to create user");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return userId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int ImportUser(int itemId, string accountName, string displayName, string name, string domain, string password, string subscriberNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accountName))
|
||||
throw new ArgumentNullException("accountName");
|
||||
|
||||
if (string.IsNullOrEmpty(displayName))
|
||||
throw new ArgumentNullException("displayName");
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
throw new ArgumentNullException("name");
|
||||
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
throw new ArgumentNullException("domain");
|
||||
|
||||
if (string.IsNullOrEmpty(password))
|
||||
throw new ArgumentNullException("password");
|
||||
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("ORGANIZATION", "IMPORT_USER");
|
||||
TaskManager.ItemId = itemId;
|
||||
TaskManager.Write("Organization ID :" + itemId);
|
||||
TaskManager.Write("account :" + accountName);
|
||||
TaskManager.Write("name :" + name);
|
||||
TaskManager.Write("domain :" + domain);
|
||||
|
||||
int userId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
accountName = accountName.Trim();
|
||||
displayName = displayName.Trim();
|
||||
name = name.Trim();
|
||||
domain = domain.Trim();
|
||||
|
||||
// e-mail
|
||||
string email = name + "@" + domain;
|
||||
|
||||
if (EmailAddressExists(email))
|
||||
return BusinessErrorCodes.ERROR_EXCHANGE_EMAIL_EXISTS;
|
||||
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
if (org == null)
|
||||
return -1;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(org.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
int errorCode;
|
||||
if (!CheckUserQuota(org.Id, out errorCode))
|
||||
return errorCode;
|
||||
|
||||
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
string upn = string.Format("{0}@{1}", name, domain);
|
||||
TaskManager.Write("upn :" + upn);
|
||||
|
||||
OrganizationUser retUser = orgProxy.GetUserGeneralSettings(accountName, org.OrganizationId);
|
||||
|
||||
TaskManager.Write("sAMAccountName :" + retUser.DomainUserName);
|
||||
|
||||
userId = AddOrganizationUser(itemId, accountName, displayName, email, retUser.DomainUserName, password, subscriberNumber);
|
||||
|
||||
AddAccountEmailAddress(userId, email);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return userId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void AddAccountEmailAddress(int accountId, string emailAddress)
|
||||
{
|
||||
|
@ -1080,28 +1344,40 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
private static string BuildAccountName(string orgId, string name)
|
||||
{
|
||||
int maxLen = 19 - orgId.Length;
|
||||
|
||||
// try to choose name
|
||||
int i = 0;
|
||||
while (true)
|
||||
string accountName = name = name.Replace(" ", "");
|
||||
string CounterStr = "00000";
|
||||
int counter = 0;
|
||||
bool bFound = false;
|
||||
do
|
||||
{
|
||||
string num = i > 0 ? i.ToString() : "";
|
||||
int len = maxLen - num.Length;
|
||||
accountName = genSamLogin(name, CounterStr);
|
||||
|
||||
if (name.Length > len)
|
||||
name = name.Substring(0, len);
|
||||
if (!AccountExists(accountName)) bFound = true;
|
||||
|
||||
string accountName = name + num + "_" + orgId;
|
||||
|
||||
// check if already exists
|
||||
if (!AccountExists(accountName))
|
||||
return accountName;
|
||||
|
||||
i++;
|
||||
CounterStr = counter.ToString("d5");
|
||||
counter++;
|
||||
}
|
||||
while (!bFound);
|
||||
|
||||
return accountName;
|
||||
}
|
||||
|
||||
private static string genSamLogin(string login, string strCounter)
|
||||
{
|
||||
int maxLogin = 20;
|
||||
int fullLen = login.Length + strCounter.Length;
|
||||
if (fullLen <= maxLogin)
|
||||
return login + strCounter;
|
||||
else
|
||||
{
|
||||
if (login.Length - (fullLen - maxLogin) > 0)
|
||||
return login.Substring(0, login.Length - (fullLen - maxLogin)) + strCounter;
|
||||
else return strCounter; // ????
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static bool AccountExists(string accountName)
|
||||
{
|
||||
return DataProvider.ExchangeAccountExists(accountName);
|
||||
|
@ -1180,6 +1456,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return account;
|
||||
}
|
||||
|
||||
public static OrganizationUser GetAccountByAccountName(int itemId, string AccountName)
|
||||
{
|
||||
OrganizationUser account = ObjectUtils.FillObjectFromDataReader<OrganizationUser>(
|
||||
DataProvider.GetExchangeAccountByAccountName(itemId, AccountName));
|
||||
|
||||
if (account == null)
|
||||
return null;
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
|
||||
private static void DeleteUserFromMetabase(int itemId, int accountId)
|
||||
{
|
||||
// try to get organization
|
||||
|
@ -1217,11 +1505,16 @@ namespace WebsitePanel.EnterpriseServer
|
|||
string accountName = GetAccountName(account.AccountName);
|
||||
|
||||
|
||||
OrganizationUser retUser = orgProxy.GeUserGeneralSettings(accountName, org.OrganizationId);
|
||||
OrganizationUser retUser = orgProxy.GetUserGeneralSettings(accountName, org.OrganizationId);
|
||||
retUser.AccountId = accountId;
|
||||
retUser.AccountName = account.AccountName;
|
||||
retUser.PrimaryEmailAddress = account.PrimaryEmailAddress;
|
||||
retUser.AccountType = account.AccountType;
|
||||
retUser.CrmUserId = CRMController.GetCrmUserId(accountId);
|
||||
retUser.IsOCSUser = DataProvider.CheckOCSUserExists(accountId);
|
||||
retUser.IsLyncUser = DataProvider.CheckLyncUserExists(accountId);
|
||||
retUser.IsBlackBerryUser = BlackBerryController.CheckBlackBerryUserExists(accountId);
|
||||
retUser.SubscriberNumber = account.SubscriberNumber;
|
||||
|
||||
return retUser;
|
||||
}
|
||||
|
@ -1240,7 +1533,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
string lastName, string address, string city, string state, string zip, string country,
|
||||
string jobTitle, string company, string department, string office, string managerAccountName,
|
||||
string businessPhone, string fax, string homePhone, string mobilePhone, string pager,
|
||||
string webPage, string notes, string externalEmail)
|
||||
string webPage, string notes, string externalEmail, string subscriberNumber)
|
||||
{
|
||||
|
||||
// check account
|
||||
|
@ -1253,6 +1546,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
try
|
||||
{
|
||||
displayName = displayName.Trim();
|
||||
firstName = firstName.Trim();
|
||||
lastName = lastName.Trim();
|
||||
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
if (org == null)
|
||||
|
@ -1303,6 +1600,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// update account
|
||||
account.DisplayName = displayName;
|
||||
account.SubscriberNumber = subscriberNumber;
|
||||
|
||||
//account.
|
||||
if (!String.IsNullOrEmpty(password))
|
||||
|
@ -1329,7 +1627,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
DataProvider.UpdateExchangeAccount(account.AccountId, account.AccountName, account.AccountType, account.DisplayName,
|
||||
account.PrimaryEmailAddress, account.MailEnabledPublicFolder,
|
||||
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword);
|
||||
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword, account.MailboxPlanId,
|
||||
(string.IsNullOrEmpty(account.SubscriberNumber) ? null : account.SubscriberNumber.Trim()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1377,11 +1676,58 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
#endregion
|
||||
|
||||
return ObjectUtils.CreateListFromDataReader<OrganizationUser>(
|
||||
DataProvider.SearchOrganizationAccounts(SecurityContext.User.UserId, itemId,
|
||||
filterColumn, filterValue, sortColumn, includeMailboxes));
|
||||
List<OrganizationUser> Tmpaccounts = ObjectUtils.CreateListFromDataReader<OrganizationUser>(
|
||||
DataProvider.SearchOrganizationAccounts(SecurityContext.User.UserId, itemId,
|
||||
filterColumn, filterValue, sortColumn, includeMailboxes));
|
||||
|
||||
List<OrganizationUser> Accounts = new List<OrganizationUser>();
|
||||
|
||||
foreach (OrganizationUser user in Tmpaccounts.ToArray())
|
||||
{
|
||||
Accounts.Add(GetUserGeneralSettings(itemId, user.AccountId));
|
||||
}
|
||||
|
||||
return Accounts;
|
||||
}
|
||||
|
||||
public static int GetAccountIdByUserPrincipalName(int itemId, string userPrincipalName)
|
||||
{
|
||||
// place log record
|
||||
TaskManager.StartTask("ORGANIZATION", "GET_ACCOUNT_BYUPN");
|
||||
TaskManager.ItemId = itemId;
|
||||
|
||||
int accounId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
if (org == null)
|
||||
return 0;
|
||||
|
||||
// get samaccountName
|
||||
//Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
|
||||
//string accountName = orgProxy.GetSamAccountNameByUserPrincipalName(org.OrganizationId, userPrincipalName);
|
||||
|
||||
// load account
|
||||
OrganizationUser account = GetAccountByAccountName(itemId, userPrincipalName);
|
||||
|
||||
if (account != null)
|
||||
accounId = account.AccountId;
|
||||
|
||||
return accounId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public static List<OrganizationDomainName> GetOrganizationDomains(int itemId)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -39,6 +39,7 @@ using WebsitePanel.Server;
|
|||
using WebsitePanel.Providers;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using OS = WebsitePanel.Providers.OS;
|
||||
using System.Collections;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
|
@ -406,6 +407,67 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Web Platform Installer
|
||||
|
||||
public static void InitWPIFeeds(int serverId, string feedUrls)
|
||||
{
|
||||
GetServerService(serverId).InitWPIFeeds(feedUrls);
|
||||
}
|
||||
|
||||
public static WPITab[] GetWPITabs(int serverId)
|
||||
{
|
||||
return GetServerService(serverId).GetWPITabs();
|
||||
}
|
||||
|
||||
public static WPIKeyword[] GetWPIKeywords(int serverId)
|
||||
{
|
||||
return GetServerService(serverId).GetWPIKeywords();
|
||||
}
|
||||
|
||||
public static WPIProduct[] GetWPIProducts(int serverId, string tabId, string keywordId)
|
||||
{
|
||||
return GetServerService(serverId).GetWPIProducts(tabId, keywordId);
|
||||
}
|
||||
|
||||
public static WPIProduct[] GetWPIProductsFiltered(int serverId, string keywordId)
|
||||
{
|
||||
return GetServerService(serverId).GetWPIProductsFiltered(keywordId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static WPIProduct[] GetWPIProductsWithDependencies(int serverId, string[] products)
|
||||
{
|
||||
return GetServerService(serverId).GetWPIProductsWithDependencies(products);
|
||||
}
|
||||
public static void InstallWPIProducts(int serverId, string[] products)
|
||||
{
|
||||
GetServerService(serverId).InstallWPIProducts(products);
|
||||
}
|
||||
|
||||
public static void CancelInstallWPIProducts(int serverId)
|
||||
{
|
||||
GetServerService(serverId).CancelInstallWPIProducts();
|
||||
}
|
||||
|
||||
public static string GetWPIStatus(int serverId)
|
||||
{
|
||||
return GetServerService(serverId).GetWPIStatus();
|
||||
}
|
||||
|
||||
public static string WpiGetLogFileDirectory(int serverId)
|
||||
{
|
||||
return GetServerService(serverId).WpiGetLogFileDirectory();
|
||||
}
|
||||
|
||||
public static SettingPair[] WpiGetLogsInDirectory(int serverId, string Path)
|
||||
{
|
||||
return GetServerService(serverId).WpiGetLogsInDirectory(Path);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Viewer
|
||||
public static string[] GetLogNames(int serverId)
|
||||
{
|
||||
|
@ -684,6 +746,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -399,7 +399,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// check account
|
||||
result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive
|
||||
| DemandAccount.IsReseller);
|
||||
| DemandAccount.IsResellerCSR);
|
||||
if (result.Result < 0) return result;
|
||||
|
||||
// check if domain exists
|
||||
|
@ -460,7 +460,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
domain.PackageId = packageId;
|
||||
domain.DomainName = domainName;
|
||||
domain.HostingAllowed = false;
|
||||
domainId = ServerController.AddDomain(domain, createInstantAlias);
|
||||
domainId = ServerController.AddDomain(domain, createInstantAlias, true);
|
||||
if (domainId < 0)
|
||||
{
|
||||
result.Result = domainId;
|
||||
|
@ -652,7 +652,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// check account
|
||||
result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive
|
||||
| DemandAccount.IsReseller);
|
||||
| DemandAccount.IsResellerCSR);
|
||||
if (result.Result < 0) return result;
|
||||
|
||||
int packageId = -1;
|
||||
|
@ -820,7 +820,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive
|
||||
| DemandAccount.IsReseller);
|
||||
| DemandAccount.IsResellerCSR);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
List<PackageInfo> packages = new List<PackageInfo>();
|
||||
|
@ -1521,19 +1521,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
// Exchange Hosted Edition
|
||||
else if (String.Compare(PackageSettings.EXCHANGE_HOSTED_EDITION, settingsName, true) == 0)
|
||||
{
|
||||
// load Exchange service settings
|
||||
int exchServiceId = GetPackageServiceId(packageId, ResourceGroups.ExchangeHostedEdition);
|
||||
if (exchServiceId > 0)
|
||||
{
|
||||
StringDictionary exchSettings = ServerController.GetServiceSettings(exchServiceId);
|
||||
settings["temporaryDomain"] = exchSettings["temporaryDomain"];
|
||||
settings["ecpURL"] = exchSettings["ecpURL"];
|
||||
}
|
||||
}
|
||||
|
||||
// VPS
|
||||
else if (String.Compare(PackageSettings.VIRTUAL_PRIVATE_SERVERS, settingsName, true) == 0)
|
||||
{
|
||||
|
@ -1875,6 +1862,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MsSql2000);
|
||||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MsSql2005);
|
||||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MsSql2008);
|
||||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MsSql2012);
|
||||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MySql4);
|
||||
SetSqlServerExternalAddress(packageId, items, ResourceGroups.MySql5);
|
||||
|
||||
|
@ -1964,6 +1952,21 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
items["Plans"] = plans;
|
||||
|
||||
//Add ons
|
||||
Hashtable addOns = new Hashtable();
|
||||
int i = 0;
|
||||
foreach (PackageInfo package in packages)
|
||||
{
|
||||
List<PackageAddonInfo> lstAddOns = ObjectUtils.CreateListFromDataSet<PackageAddonInfo>(GetPackageAddons(package.PackageId));
|
||||
foreach (PackageAddonInfo addOn in lstAddOns)
|
||||
{
|
||||
addOns.Add(i, addOn);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
items["Addons"] = addOns;
|
||||
|
||||
// package contexts
|
||||
Hashtable cntxs = new Hashtable();
|
||||
foreach (PackageInfo package in packages)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -122,20 +122,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
try
|
||||
{
|
||||
// TO-DO: Check connectivity
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
HttpWebResponse response = (HttpWebResponse)ex.Response;
|
||||
if (response != null && response.StatusCode == HttpStatusCode.NotFound)
|
||||
if (response != null && response.StatusCode == HttpStatusCode.NotFound)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_NOT_FOUND;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.BadRequest)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.BadRequest)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_BAD_REQUEST;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_INTERNAL_SERVER_ERROR;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_SERVICE_UNAVAILABLE;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_UNAUTHORIZED;
|
||||
if (ex.Message.Contains("The remote name could not be resolved") || ex.Message.Contains("Unable to connect"))
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
TaskManager.WriteError("General Server Error");
|
||||
TaskManager.WriteError(ex);
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_APPLICATION_ERROR;
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_APPLICATION_ERROR;
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -220,7 +220,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
throw new ApplicationException("Could not find services. General error was occued.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int AddServer(ServerInfo server, bool autoDiscovery)
|
||||
{
|
||||
// check account
|
||||
|
@ -243,8 +243,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
TaskManager.StartTask("SERVER", "ADD", server.ServerName);
|
||||
|
||||
int serverId = DataProvider.AddServer(server.ServerName, server.ServerUrl,
|
||||
|
||||
int serverId = DataProvider.AddServer(server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.VirtualServer, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -261,7 +261,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TaskManager.ItemId = serverId;
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -294,7 +294,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return availResult;
|
||||
}
|
||||
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -322,7 +322,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
server.Password = password;
|
||||
|
||||
// update server
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -350,7 +350,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
server.ADPassword = adPassword;
|
||||
|
||||
// update server
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -636,12 +636,12 @@ namespace WebsitePanel.EnterpriseServer
|
|||
| DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load original service
|
||||
ServiceInfo origService = GetServiceInfo(service.ServiceId);
|
||||
// load original service
|
||||
ServiceInfo origService = GetServiceInfo(service.ServiceId);
|
||||
|
||||
TaskManager.StartTask("SERVER", "UPDATE_SERVICE");
|
||||
TaskManager.ItemId = origService.ServerId;
|
||||
TaskManager.ItemName = GetServerByIdInternal(origService.ServerId).ServerName;
|
||||
TaskManager.ItemId = origService.ServerId;
|
||||
TaskManager.ItemName = GetServerByIdInternal(origService.ServerId).ServerName;
|
||||
TaskManager.WriteParameter("New service name", service.ServiceName);
|
||||
|
||||
DataProvider.UpdateService(service.ServiceId, service.ServiceName,
|
||||
|
@ -839,7 +839,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public static BoolResult IsInstalled(int serverId, int providerId)
|
||||
{
|
||||
BoolResult res = TaskManager.StartResultTask<BoolResult>("AUTO_DISCOVERY", "IS_INSTALLED");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
ProviderInfo provider = GetProvider(providerId);
|
||||
|
@ -848,22 +848,22 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_GET_PROVIDER_INFO);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
AutoDiscovery.AutoDiscovery ad = new AutoDiscovery.AutoDiscovery();
|
||||
ServiceProviderProxy.ServerInit(ad, serverId);
|
||||
|
||||
res = ad.IsInstalled(provider.ProviderType);
|
||||
|
||||
res = ad.IsInstalled(provider.ProviderType);
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_CHECK_IF_PROVIDER_SOFTWARE_INSTALLED, ex);
|
||||
|
||||
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static string GetServerVersion(int serverId)
|
||||
{
|
||||
AutoDiscovery.AutoDiscovery ad = new AutoDiscovery.AutoDiscovery();
|
||||
|
@ -871,7 +871,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
return ad.GetServerVersion();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IP Addresses
|
||||
|
@ -1400,18 +1400,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
private static string GetIPAddressesQuotaByResourceGroup(string groupName)
|
||||
{
|
||||
if (String.Compare(groupName, ResourceGroups.VPS, true) == 0)
|
||||
{
|
||||
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
|
||||
{
|
||||
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Quotas.WEB_IP_ADDRESSES;
|
||||
}
|
||||
if (String.Compare(groupName, ResourceGroups.VPS, true) == 0)
|
||||
{
|
||||
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
|
||||
{
|
||||
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Quotas.WEB_IP_ADDRESSES;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1521,7 +1521,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteParameter("Data", record.RecordData);
|
||||
|
||||
DataProvider.AddDnsRecord(SecurityContext.User.UserId, record.ServiceId, record.ServerId, record.PackageId,
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.IpAddressId);
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority,
|
||||
record.SrvPriority, record.SrvWeight, record.SrvPort, record.IpAddressId);
|
||||
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -1540,7 +1541,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteParameter("Data", record.RecordData);
|
||||
|
||||
DataProvider.UpdateDnsRecord(SecurityContext.User.UserId, record.RecordId,
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.IpAddressId);
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority,
|
||||
record.SrvPriority, record.SrvWeight, record.SrvPort, record.IpAddressId);
|
||||
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -1571,7 +1573,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
#region Domains
|
||||
public static int CheckDomain(string domainName)
|
||||
{
|
||||
int checkDomainResult = DataProvider.CheckDomain(-10, domainName);
|
||||
int checkDomainResult = DataProvider.CheckDomain(-10, domainName, false);
|
||||
|
||||
if (checkDomainResult == -1)
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_ALREADY_EXISTS;
|
||||
|
@ -1677,8 +1679,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static int AddDomainWithProvisioning(int packageId, string domainName, DomainType domainType,
|
||||
bool createWebSite, int pointWebSiteId, int pointMailDomainId,
|
||||
bool createDnsZone, bool createInstantAlias, bool allowSubDomains)
|
||||
bool createWebSite, int pointWebSiteId, int pointMailDomainId, bool createDnsZone, bool createInstantAlias, bool allowSubDomains)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -1687,7 +1688,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
|
||||
// set flags
|
||||
bool isSubDomain = (domainType == DomainType.SubDomain || domainType == DomainType.ProviderSubDomain);
|
||||
bool isDomainPointer = (domainType == DomainType.DomainPointer);
|
||||
|
@ -1748,10 +1749,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int AddDomain(DomainInfo domain)
|
||||
{
|
||||
return AddDomain(domain, false);
|
||||
return AddDomain(domain, false, false);
|
||||
}
|
||||
|
||||
public static int AddDomain(DomainInfo domain, bool createInstantAlias)
|
||||
public static int AddDomain(DomainInfo domain, bool createInstantAlias, bool createZone)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -1762,7 +1763,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
// add main domain
|
||||
int domainId = AddDomainInternal(domain.PackageId, domain.DomainName, true,
|
||||
int domainId = AddDomainInternal(domain.PackageId, domain.DomainName, createZone,
|
||||
domain.IsSubDomain, false, domain.IsDomainPointer, false);
|
||||
|
||||
if (domainId < 0)
|
||||
|
@ -1805,7 +1806,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// check if the domain already exists
|
||||
int checkResult = DataProvider.CheckDomain(packageId, domainName);
|
||||
int checkResult = DataProvider.CheckDomain(packageId, domainName, isDomainPointer);
|
||||
|
||||
if (checkResult < 0)
|
||||
{
|
||||
|
@ -1816,15 +1817,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
else
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
if (domainName.ToLower().StartsWith("www."))
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_STARTS_WWW;
|
||||
/*
|
||||
if (domainName.ToLower().StartsWith("www."))
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_STARTS_WWW;
|
||||
*/
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "ADD", domainName);
|
||||
TaskManager.PackageId = packageId;
|
||||
TaskManager.TaskParameters["CreateZone"] = createDnsZone;
|
||||
|
||||
|
||||
|
||||
// create DNS zone
|
||||
int zoneItemId = 0;
|
||||
if (createDnsZone)
|
||||
|
@ -1895,60 +1899,60 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
public static int DetachDomain(int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
public static int DetachDomain(int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DETACH", domain.DomainName);
|
||||
TaskManager.ItemId = domain.DomainId;
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DETACH", domain.DomainName);
|
||||
TaskManager.ItemId = domain.DomainId;
|
||||
|
||||
try
|
||||
{
|
||||
// check if domain can be deleted
|
||||
if (domain.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
try
|
||||
{
|
||||
// check if domain can be deleted
|
||||
if (domain.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
|
||||
if (domain.MailDomainId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing mail domain");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_MAIL_DOMAIN;
|
||||
}
|
||||
if (domain.MailDomainId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing mail domain");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_MAIL_DOMAIN;
|
||||
}
|
||||
|
||||
if (DataProvider.ExchangeOrganizationDomainExists(domain.DomainId))
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing organization domain");
|
||||
return BusinessErrorCodes.ERROR_ORGANIZATION_DOMAIN_IS_IN_USE;
|
||||
}
|
||||
|
||||
|
||||
// remove DNS zone meta-item if required
|
||||
if (domain.ZoneItemId > 0)
|
||||
{
|
||||
PackageController.DeletePackageItem(domain.ZoneItemId);
|
||||
}
|
||||
if (domain.ZoneItemId > 0)
|
||||
{
|
||||
PackageController.DeletePackageItem(domain.ZoneItemId);
|
||||
}
|
||||
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int DeleteDomain(int domainId)
|
||||
{
|
||||
|
@ -1991,9 +1995,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
// delete zone if required
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
|
||||
// delete zone if required
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
|
@ -2096,7 +2100,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// add web site DNS records
|
||||
int res = AddWebSiteZoneRecords(domainId);
|
||||
int res = AddWebSiteZoneRecords("", domainId);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
|
@ -2112,7 +2116,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
private static int AddWebSiteZoneRecords(int domainId)
|
||||
private static int AddWebSiteZoneRecords(string hostName, int domainId)
|
||||
{
|
||||
// load domain
|
||||
DomainInfo domain = GetDomainItem(domainId);
|
||||
|
@ -2126,7 +2130,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return res;
|
||||
}
|
||||
|
||||
public static int CreateDomainInstantAlias(int domainId)
|
||||
public static int CreateDomainInstantAlias(string hostName, int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
|
||||
|
@ -2166,14 +2170,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
|
||||
// add mail domain pointer
|
||||
if (domain.MailDomainId > 0 && instantAlias.MailDomainId == 0)
|
||||
{
|
||||
int mailRes = MailServerController.AddMailDomainPointer(domain.MailDomainId, instantAliasId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
/*
|
||||
// add mail domain pointer
|
||||
if (domain.MailDomainId > 0 && instantAlias.MailDomainId == 0)
|
||||
{
|
||||
int mailRes = MailServerController.AddMailDomainPointer(domain.MailDomainId, instantAliasId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2214,14 +2219,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
|
||||
// remove from mail domain pointers
|
||||
if (instantAlias.MailDomainId > 0)
|
||||
{
|
||||
int mailRes = MailServerController.DeleteMailDomainPointer(instantAlias.MailDomainId, instantAlias.DomainId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
/*
|
||||
// remove from mail domain pointers
|
||||
if (instantAlias.MailDomainId > 0)
|
||||
{
|
||||
int mailRes = MailServerController.DeleteMailDomainPointer(instantAlias.MailDomainId, instantAlias.DomainId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
*/
|
||||
|
||||
// delete instant alias
|
||||
int res = DeleteDomain(instantAlias.DomainId);
|
||||
|
@ -2272,12 +2278,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
dt.Columns.Add("RecordName", typeof(string));
|
||||
dt.Columns.Add("RecordData", typeof(string));
|
||||
dt.Columns.Add("MxPriority", typeof(int));
|
||||
dt.Columns.Add("SrvPriority", typeof(int));
|
||||
dt.Columns.Add("SrvWeight", typeof(int));
|
||||
dt.Columns.Add("SrvPort", typeof(int));
|
||||
|
||||
// add rows
|
||||
DnsRecord[] records = GetDnsZoneRecords(domainId);
|
||||
foreach (DnsRecord record in records)
|
||||
{
|
||||
dt.Rows.Add(record.RecordType, record.RecordName, record.RecordData, record.MxPriority);
|
||||
dt.Rows.Add(record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.SrvPriority, record.SrvWeight, record.SrvPort);
|
||||
}
|
||||
|
||||
return ds;
|
||||
|
@ -2299,7 +2308,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static int AddDnsZoneRecord(int domainId, string recordName, DnsRecordType recordType,
|
||||
string recordData, int mxPriority)
|
||||
string recordData, int mxPriority, int srvPriority, int srvWeight, int srvPort)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -2315,7 +2324,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// get DNS service
|
||||
DnsZone zoneItem = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);
|
||||
|
||||
if(zoneItem == null)
|
||||
if (zoneItem == null)
|
||||
return 0;
|
||||
|
||||
// place log record
|
||||
|
@ -2337,6 +2346,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
record.RecordName = recordName;
|
||||
record.RecordData = recordData;
|
||||
record.MxPriority = mxPriority;
|
||||
record.SrvPriority = srvPriority;
|
||||
record.SrvWeight = srvWeight;
|
||||
record.SrvPort = srvPort;
|
||||
dns.AddZoneRecord(zoneItem.Name, record);
|
||||
|
||||
return 0;
|
||||
|
@ -2353,7 +2365,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int UpdateDnsZoneRecord(int domainId,
|
||||
string originalRecordName, string originalRecordData,
|
||||
string recordName, DnsRecordType recordType, string recordData, int mxPriority)
|
||||
string recordName, DnsRecordType recordType, string recordData, int mxPriority, int srvPriority, int srvWeight, int srvPortNumber)
|
||||
{
|
||||
// place log record
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
|
@ -2367,7 +2379,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DeleteDnsZoneRecord(domainId, originalRecordName, recordType, originalRecordData);
|
||||
|
||||
// add new record
|
||||
AddDnsZoneRecord(domainId, recordName, recordType, recordData, mxPriority);
|
||||
AddDnsZoneRecord(domainId, recordName, recordType, recordData, mxPriority, srvPriority, srvWeight, srvPortNumber);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2410,7 +2422,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
|
||||
DnsRecord record = GetDnsZoneRecord(domainId, recordName, recordType, recordData);
|
||||
DnsRecord record = GetDnsZoneRecord(domainId, recordName, recordType, recordData);
|
||||
dns.DeleteZoneRecord(zoneItem.Name, record);
|
||||
|
||||
return 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -49,56 +49,92 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return (user != null);
|
||||
}
|
||||
|
||||
public static int AuthenticateUser(string username, string password, string ip)
|
||||
{
|
||||
// start task
|
||||
TaskManager.StartTask("USER", "AUTHENTICATE", username);
|
||||
TaskManager.WriteParameter("IP", ip);
|
||||
public static int AuthenticateUser(string username, string password, string ip)
|
||||
{
|
||||
// start task
|
||||
TaskManager.StartTask("USER", "AUTHENTICATE", username);
|
||||
TaskManager.WriteParameter("IP", ip);
|
||||
|
||||
try
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = GetUserInternally(username);
|
||||
try
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = GetUserInternally(username);
|
||||
|
||||
// check if the user exists
|
||||
if (user == null)
|
||||
{
|
||||
TaskManager.WriteWarning("Wrong username");
|
||||
return BusinessErrorCodes.ERROR_USER_WRONG_USERNAME;
|
||||
}
|
||||
// check if the user exists
|
||||
if (user == null)
|
||||
{
|
||||
TaskManager.WriteWarning("Wrong username");
|
||||
return BusinessErrorCodes.ERROR_USER_WRONG_USERNAME;
|
||||
}
|
||||
|
||||
// compare user passwords
|
||||
if (user.Password != password)
|
||||
{
|
||||
TaskManager.WriteWarning("Wrong password");
|
||||
return BusinessErrorCodes.ERROR_USER_WRONG_PASSWORD;
|
||||
}
|
||||
// check if the user is disabled
|
||||
if (user.LoginStatus == UserLoginStatus.Disabled)
|
||||
{
|
||||
TaskManager.WriteWarning("User disabled");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_DISABLED;
|
||||
}
|
||||
|
||||
// check status
|
||||
if (user.Status == UserStatus.Cancelled)
|
||||
{
|
||||
TaskManager.WriteWarning("Account cancelled");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_CANCELLED;
|
||||
}
|
||||
// check if the user is locked out
|
||||
if (user.LoginStatus == UserLoginStatus.LockedOut)
|
||||
{
|
||||
TaskManager.WriteWarning("User locked out");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_LOCKEDOUT;
|
||||
}
|
||||
|
||||
if (user.Status == UserStatus.Pending)
|
||||
{
|
||||
TaskManager.WriteWarning("Account pending");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_PENDING;
|
||||
}
|
||||
//Get the password policy
|
||||
UserSettings userSettings = UserController.GetUserSettings(user.UserId, UserSettings.WEBSITEPANEL_POLICY);
|
||||
int lockOut = -1;
|
||||
|
||||
return 0;
|
||||
if (!string.IsNullOrEmpty(userSettings["PasswordPolicy"]))
|
||||
{
|
||||
string passwordPolicy = userSettings["PasswordPolicy"];
|
||||
try
|
||||
{
|
||||
// parse settings
|
||||
string[] parts = passwordPolicy.Split(';');
|
||||
lockOut = Convert.ToInt32(parts[7]);
|
||||
}
|
||||
catch { /* skip */ }
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
// compare user passwords
|
||||
if (user.Password != password)
|
||||
{
|
||||
if (lockOut >= 0)
|
||||
DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false);
|
||||
|
||||
TaskManager.WriteWarning("Wrong password");
|
||||
return BusinessErrorCodes.ERROR_USER_WRONG_PASSWORD;
|
||||
}
|
||||
else
|
||||
DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, true);
|
||||
|
||||
// check status
|
||||
if (user.Status == UserStatus.Cancelled)
|
||||
{
|
||||
TaskManager.WriteWarning("Account cancelled");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_CANCELLED;
|
||||
}
|
||||
|
||||
if (user.Status == UserStatus.Pending)
|
||||
{
|
||||
TaskManager.WriteWarning("Account pending");
|
||||
return BusinessErrorCodes.ERROR_USER_ACCOUNT_PENDING;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static UserInfo GetUserByUsernamePassword(string username, string password, string ip)
|
||||
{
|
||||
|
@ -382,6 +418,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
user.OwnerId,
|
||||
user.RoleId,
|
||||
user.StatusId,
|
||||
user.LoginStatusId,
|
||||
user.IsDemo,
|
||||
user.IsPeer,
|
||||
user.Comments,
|
||||
|
@ -525,6 +562,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
user.UserId,
|
||||
user.RoleId,
|
||||
user.StatusId,
|
||||
user.LoginStatusId,
|
||||
user.IsDemo,
|
||||
user.IsPeer,
|
||||
user.Comments,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -62,6 +62,88 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public const string GET_GALLERY_CATEGORIES_TASK = "GET_GALLERY_CATEGORIES_TASK";
|
||||
#endregion
|
||||
|
||||
private static string[] getFeedsFromSettings(int packageId)
|
||||
{
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
|
||||
|
||||
return getFeedsFromSettingsByServiceId(serviceId);
|
||||
|
||||
}
|
||||
|
||||
private static string[] getFeedsFromSettingsByServiceId(int serviceId)
|
||||
{
|
||||
StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
|
||||
|
||||
List<string> arFeeds = new List<string>();
|
||||
|
||||
if (Utils.ParseBool(serviceSettings["FeedEnableMicrosoft"], true))
|
||||
{
|
||||
arFeeds.Add("https://www.microsoft.com/web/webpi/3.0/WebProductList.xml");
|
||||
}
|
||||
|
||||
if (Utils.ParseBool(serviceSettings["FeedEnableHelicon"], true))
|
||||
{
|
||||
arFeeds.Add("http://www.helicontech.com/zoo/feed/wsp");
|
||||
}
|
||||
|
||||
string additionalFeeds = serviceSettings["FeedUrls"];
|
||||
if (!string.IsNullOrEmpty(additionalFeeds))
|
||||
{
|
||||
arFeeds.AddRange(additionalFeeds.Split(';'));
|
||||
}
|
||||
|
||||
return arFeeds.ToArray();
|
||||
}
|
||||
public static void InitFeedsByServiceId(int UserId, int serviceId)
|
||||
{
|
||||
string[] feeds = getFeedsFromSettingsByServiceId(serviceId);
|
||||
|
||||
WebServer webServer = WebServerController.GetWebServer(serviceId);
|
||||
webServer.InitFeeds(UserId, feeds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void InitFeeds(int UserId, int packageId)
|
||||
{
|
||||
string[] feeds = getFeedsFromSettings(packageId);
|
||||
|
||||
// Set feeds
|
||||
WebServer webServer = GetAssociatedWebServer(packageId);
|
||||
webServer.InitFeeds(UserId, feeds);
|
||||
|
||||
}
|
||||
|
||||
public static void SetResourceLanguage(int packageId, string resourceLanguage)
|
||||
{
|
||||
GetAssociatedWebServer(packageId).SetResourceLanguage(SecurityContext.User.UserId,resourceLanguage);
|
||||
}
|
||||
|
||||
|
||||
public static GalleryLanguagesResult GetGalleryLanguages(int packageId)
|
||||
{
|
||||
GalleryLanguagesResult result;
|
||||
|
||||
try
|
||||
{
|
||||
WebServer webServer = GetAssociatedWebServer(packageId);
|
||||
result = webServer.GetGalleryLanguages(SecurityContext.User.UserId);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryLanguagesResult>(result, GalleryErrors.GetLanguagesError);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error<GalleryLanguagesResult>(GalleryErrors.GetLanguagesError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
//
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static GalleryCategoriesResult GetGalleryCategories(int packageId)
|
||||
{
|
||||
GalleryCategoriesResult result;
|
||||
|
@ -77,7 +159,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<GalleryCategoriesResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get categories
|
||||
result = webServer.GetGalleryCategories();
|
||||
result = webServer.GetGalleryCategories(SecurityContext.User.UserId);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryCategoriesResult>(result, GalleryErrors.GetCategoriesError);
|
||||
|
@ -114,7 +196,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get applications
|
||||
result = webServer.GetGalleryApplications(String.Empty);
|
||||
result = webServer.GetGalleryApplications(SecurityContext.User.UserId,String.Empty);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
|
||||
|
@ -132,7 +214,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
}
|
||||
|
||||
public static GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
|
||||
public static GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
|
||||
{
|
||||
GalleryApplicationsResult result;
|
||||
//
|
||||
|
@ -146,7 +228,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get applications
|
||||
result = webServer.GetGalleryApplications(categoryId);
|
||||
result = webServer.GetGalleryApplications(SecurityContext.User.UserId,categoryId);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
|
||||
|
@ -169,10 +251,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
//{
|
||||
// appsFilter.AddRange(SupportedAppDependencies.PHP_SCRIPTING);
|
||||
//}
|
||||
//// if either MSSQL 2000, 2005 or 2008 enabled in the hosting plan
|
||||
//// if either MSSQL 2000, 2005, 2008 or 2012 enabled in the hosting plan
|
||||
//if (context.Groups.ContainsKey(ResourceGroups.MsSql2000) ||
|
||||
// context.Groups.ContainsKey(ResourceGroups.MsSql2005) ||
|
||||
// context.Groups.ContainsKey(ResourceGroups.MsSql2008))
|
||||
// context.Groups.ContainsKey(ResourceGroups.MsSql2008) ||
|
||||
// context.Groups.ContainsKey(ResourceGroups.MsSql2012))
|
||||
//{
|
||||
// appsFilter.AddRange(SupportedAppDependencies.MSSQL_DATABASE);
|
||||
//}
|
||||
|
@ -188,20 +271,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// || MatchMenaltoGalleryApp(x, appsFilter.ToArray())));
|
||||
|
||||
{
|
||||
int userId = SecurityContext.User.UserId;
|
||||
//
|
||||
SecurityContext.SetThreadSupervisorPrincipal();
|
||||
//
|
||||
string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
|
||||
//
|
||||
if (filteredApps != null)
|
||||
{
|
||||
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
|
||||
x => !Array.Exists(filteredApps,
|
||||
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
|
||||
}
|
||||
//
|
||||
SecurityContext.SetThreadPrincipal(userId);
|
||||
FilterResultApplications(packageId, result);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -217,6 +288,61 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
}
|
||||
|
||||
private static void FilterResultApplications(int packageId, GalleryApplicationsResult result)
|
||||
{
|
||||
int userId = SecurityContext.User.UserId;
|
||||
//
|
||||
SecurityContext.SetThreadSupervisorPrincipal();
|
||||
//
|
||||
string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
|
||||
//
|
||||
if (filteredApps != null)
|
||||
{
|
||||
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
|
||||
x => !Array.Exists(filteredApps,
|
||||
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
|
||||
}
|
||||
//
|
||||
SecurityContext.SetThreadPrincipal(userId);
|
||||
}
|
||||
|
||||
public static GalleryApplicationsResult GetGalleryApplicationsFiltered(int packageId, string pattern)
|
||||
{
|
||||
GalleryApplicationsResult result;
|
||||
//
|
||||
try
|
||||
{
|
||||
TaskManager.StartTask(TASK_MANAGER_SOURCE, GET_GALLERY_APPS_TASK);
|
||||
|
||||
// check if WAG is installed
|
||||
WebServer webServer = GetAssociatedWebServer(packageId);
|
||||
if (!webServer.IsMsDeployInstalled())
|
||||
return Error<GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get applications
|
||||
result = webServer.GetGalleryApplicationsFiltered(SecurityContext.User.UserId,pattern);
|
||||
|
||||
FilterResultApplications(packageId, result);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
return Error<GalleryApplicationsResult>(GalleryErrors.GeneralError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
//
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal static bool MatchParticularAppDependency(Dependency dependency, string[] dependencyIds)
|
||||
{
|
||||
List<Dependency> nested = null;
|
||||
|
@ -310,7 +436,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<GalleryApplicationResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get application details
|
||||
result = webServer.GetGalleryApplication(applicationId);
|
||||
result = webServer.GetGalleryApplication(SecurityContext.User.UserId,applicationId);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<GalleryApplicationResult>(result, GalleryErrors.GetApplicationError);
|
||||
|
@ -342,6 +468,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
!(context.Groups.ContainsKey(ResourceGroups.MsSql2000)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2005)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2008)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2012)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MySql4)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MySql5)))
|
||||
result.ErrorCodes.Add(GalleryErrors.DatabaseRequired);
|
||||
|
@ -350,7 +477,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
else if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.SQL) == GalleryApplicationWellKnownDependency.SQL
|
||||
&& !(context.Groups.ContainsKey(ResourceGroups.MsSql2000)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2005)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2008)))
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2008)
|
||||
|| context.Groups.ContainsKey(ResourceGroups.MsSql2012)))
|
||||
result.ErrorCodes.Add(GalleryErrors.SQLRequired);
|
||||
|
||||
// MySQL
|
||||
|
@ -393,7 +521,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<DeploymentParametersResult>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
|
||||
// get parameters
|
||||
result = webServer.GetGalleryApplicationParameters(webAppId);
|
||||
result = webServer.GetGalleryApplicationParameters(SecurityContext.User.UserId,webAppId);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return Error<DeploymentParametersResult>(result, GalleryErrors.GetApplicationParametersError);
|
||||
|
@ -411,9 +539,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
}
|
||||
|
||||
public static StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters)
|
||||
public static StringResultObject Install(int packageId, string webAppId, string siteName, string virtualDir, List<DeploymentParameter> parameters, string languageId )
|
||||
{
|
||||
StringResultObject result = new StringResultObject();
|
||||
int originalUserId = SecurityContext.User.UserId;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -452,7 +581,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return Error<StringResultObject>(GalleryErrors.WebSiteNotFound, siteName);
|
||||
|
||||
// get application pack details
|
||||
GalleryApplicationResult app = webServer.GetGalleryApplication(webAppId);
|
||||
GalleryApplicationResult app = webServer.GetGalleryApplication(SecurityContext.User.UserId,webAppId);
|
||||
if (!app.IsSuccess)
|
||||
return Error<StringResultObject>(app, GalleryErrors.GeneralError);
|
||||
if (app.Value == null)
|
||||
|
@ -640,7 +769,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// install application
|
||||
result = webServer.InstallGalleryApplication(webAppId, parameters.ToArray());
|
||||
result = webServer.InstallGalleryApplication(originalUserId, webAppId, parameters.ToArray(), languageId);
|
||||
|
||||
#region Rollback in case of failure
|
||||
// Rollback - remove resources have been created previously
|
||||
|
@ -662,12 +791,25 @@ namespace WebsitePanel.EnterpriseServer
|
|||
#region Update Web Application settings
|
||||
|
||||
WebVirtualDirectory iisApp = null;
|
||||
if(String.IsNullOrEmpty(virtualDir))
|
||||
// load web site
|
||||
iisApp = WebServerController.GetWebSite(packageId, siteName);
|
||||
else
|
||||
// load virtual directory
|
||||
iisApp = WebServerController.GetVirtualDirectory(webSite.Id, virtualDir);
|
||||
if (String.IsNullOrEmpty(virtualDir))
|
||||
// load web site
|
||||
iisApp = WebServerController.GetWebSite(packageId, siteName);
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// load virtual directory
|
||||
iisApp = WebServerController.GetVirtualDirectory(webSite.Id, virtualDir);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"{0} on WebServerController.GetVirtualDirectory(\"{1}\", \"{2}\")",
|
||||
ex.GetType(), webSite.Id, virtualDir),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
// put correct extensions
|
||||
if ((app.Value.WellKnownDependencies & GalleryApplicationWellKnownDependency.AspNet20) == GalleryApplicationWellKnownDependency.AspNet20)
|
||||
|
@ -711,7 +853,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteError(ex);
|
||||
|
||||
// exit with error code
|
||||
return Error<StringResultObject>(GalleryErrors.GeneralError);
|
||||
//return Error<StringResultObject>(GalleryErrors.GeneralError);
|
||||
|
||||
result.AddError(GalleryErrors.GeneralError, ex);
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -743,11 +888,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (!webServer.IsMsDeployInstalled())
|
||||
return Error<GalleryWebAppStatus>(GalleryErrors.MsDeployIsNotInstalled);
|
||||
//
|
||||
GalleryWebAppStatus appStatus = webServer.GetGalleryApplicationStatus(webAppId);
|
||||
GalleryWebAppStatus appStatus = webServer.GetGalleryApplicationStatus(SecurityContext.User.UserId,webAppId);
|
||||
//
|
||||
if (appStatus == GalleryWebAppStatus.NotDownloaded)
|
||||
{
|
||||
GalleryApplicationResult appResult = webServer.GetGalleryApplication(webAppId);
|
||||
GalleryApplicationResult appResult = webServer.GetGalleryApplication(SecurityContext.User.UserId,webAppId);
|
||||
// Start app download in new thread
|
||||
WebAppGalleryAsyncWorker async = new WebAppGalleryAsyncWorker();
|
||||
async.GalleryApp = appResult.Value;
|
||||
|
@ -894,7 +1039,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
//
|
||||
TaskManager.Write("Application package download has been started");
|
||||
//
|
||||
GalleryWebAppStatus appStatus = webServer.DownloadGalleryApplication(WebAppId);
|
||||
GalleryWebAppStatus appStatus = webServer.DownloadGalleryApplication(SecurityContext.User.UserId,WebAppId);
|
||||
//
|
||||
if (appStatus == GalleryWebAppStatus.Failed)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -404,6 +404,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (!String.IsNullOrEmpty(pageName)
|
||||
&& pageContent != null)
|
||||
{
|
||||
|
||||
if (Utils.ParseBool(webPolicy["EnableParkingPageTokens"], false))
|
||||
{
|
||||
pageContent = pageContent.Replace("[DOMAIN_NAME]", site.Name);
|
||||
pageContent = pageContent.Replace("[SITE_IP]", site.SiteIPAddress);
|
||||
|
||||
}
|
||||
string path = Path.Combine(
|
||||
FilesController.GetVirtualPackagePath(packageId, site.ContentPath), pageName);
|
||||
|
||||
|
@ -2708,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))
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue