organization password settings added (without GPO)
This commit is contained in:
parent
e320b4c79e
commit
60214cdcf1
40 changed files with 2351 additions and 152 deletions
|
@ -27,11 +27,13 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using WebsitePanel.Providers;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
|
@ -645,6 +647,37 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return type.FullName + ", " + type.Assembly.GetName().Name;
|
||||
}
|
||||
|
||||
public static TResult Deserialize<TResult>(string inputString)
|
||||
{
|
||||
TResult result;
|
||||
|
||||
var serializer = new XmlSerializer(typeof(TResult));
|
||||
|
||||
using (TextReader reader = new StringReader(inputString))
|
||||
{
|
||||
result = (TResult)serializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string Serialize<TEntity>(TEntity entity)
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
var xmlSerializer = new XmlSerializer(typeof(TEntity));
|
||||
|
||||
using (var stringWriter = new StringWriter())
|
||||
{
|
||||
using (XmlWriter writer = XmlWriter.Create(stringWriter))
|
||||
{
|
||||
xmlSerializer.Serialize(writer, entity);
|
||||
result = stringWriter.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#region Helper Functions
|
||||
|
||||
|
|
|
@ -3236,6 +3236,23 @@ namespace WebsitePanel.EnterpriseServer
|
|||
);
|
||||
}
|
||||
|
||||
public static void UpdateOrganizationSettings(int itemId, string settingsName, string xml)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "UpdateExchangeOrganizationSettings",
|
||||
new SqlParameter("@ItemId", itemId),
|
||||
new SqlParameter("@SettingsName", settingsName),
|
||||
new SqlParameter("@Xml", xml));
|
||||
}
|
||||
|
||||
public static IDataReader GetOrganizationSettings(int itemId, string settingsName)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "GetExchangeOrganizationSettings",
|
||||
new SqlParameter("@ItemId", itemId),
|
||||
new SqlParameter("@SettingsName", settingsName));
|
||||
}
|
||||
|
||||
public static int AddOrganizationDeletedUser(int accountId, int originAT, string storagePath, string folderName, string fileName, DateTime expirationDate)
|
||||
{
|
||||
SqlParameter outParam = new SqlParameter("@ID", SqlDbType.Int);
|
||||
|
|
|
@ -1647,6 +1647,56 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return token;
|
||||
}
|
||||
|
||||
public static void UpdateOrganizationPasswordSettings(int itemId, OrganizationPasswordSettings settings)
|
||||
{
|
||||
TaskManager.StartTask("ORGANIZATION", "UPDATE_PASSWORD_SETTINGS");
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
|
||||
if (org == null)
|
||||
{
|
||||
TaskManager.WriteWarning("Organization with itemId '{0}' not found", itemId.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
orgProxy.ApplyPasswordSettings(org.OrganizationId, settings);
|
||||
|
||||
var xml = ObjectUtils.Serialize(settings);
|
||||
|
||||
DataProvider.UpdateOrganizationSettings(itemId, OrganizationSettings.PasswordSettings, xml);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static OrganizationPasswordSettings GetOrganizationPasswordSettings(int itemId)
|
||||
{
|
||||
return GetOrganizationSettings<OrganizationPasswordSettings>(itemId, OrganizationSettings.PasswordSettings);
|
||||
}
|
||||
|
||||
private static T GetOrganizationSettings<T>(int itemId, string settingsName)
|
||||
{
|
||||
var entity = ObjectUtils.FillObjectFromDataReader<OrganizationSettingsEntity>(DataProvider.GetOrganizationSettings(itemId, settingsName));
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return ObjectUtils.Deserialize<T>(entity.Xml);
|
||||
}
|
||||
|
||||
private static bool EmailAddressExists(string emailAddress)
|
||||
{
|
||||
return DataProvider.ExchangeAccountEmailAddressExists(emailAddress);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue