fixed bugs

This commit is contained in:
vfedosevich 2013-08-28 20:18:56 +03:00
parent 3fc3a425e0
commit 80d4843693
24 changed files with 2453 additions and 2295 deletions

View file

@ -1977,6 +1977,7 @@ ALTER PROCEDURE [dbo].[SearchExchangeAccounts]
@IncludeDistributionLists bit,
@IncludeRooms bit,
@IncludeEquipment bit,
@IncludeSecurityGroups bit,
@FilterColumn nvarchar(50) = '',
@FilterValue nvarchar(50) = '',
@SortColumn nvarchar(50)
@ -1998,7 +1999,7 @@ OR (@IncludeContacts = 1 AND EA.AccountType = 2)
OR (@IncludeDistributionLists = 1 AND EA.AccountType = 3)
OR (@IncludeRooms = 1 AND EA.AccountType = 5)
OR (@IncludeEquipment = 1 AND EA.AccountType = 6)
OR (@IncludeEquipment = 0 AND @IncludeContacts = 0 AND @IncludeDistributionLists = 0 AND @IncludeRooms = 0 AND @IncludeEquipment = 0 AND EA.AccountType = 8))
OR (@IncludeSecurityGroups = 1 AND EA.AccountType = 8))
AND EA.ItemID = @ItemID
'
@ -2028,8 +2029,71 @@ WHERE ' + @condition
print @sql
exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts int,
@IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit',
@ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment
@IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit, @IncludeSecurityGroups bit',
@ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment, @IncludeSecurityGroups
RETURN
GO
CREATE PROCEDURE [dbo].[SearchExchangeAccountsByTypes]
(
@ActorID int,
@ItemID int,
@AccountTypes nvarchar(30),
@FilterColumn nvarchar(50) = '',
@FilterValue nvarchar(50) = '',
@SortColumn nvarchar(50)
)
AS
DECLARE @PackageID int
SELECT @PackageID = PackageID FROM ServiceItems
WHERE ItemID = @ItemID
-- check rights
IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0
RAISERROR('You are not allowed to access this package', 16, 1)
DECLARE @condition nvarchar(700)
SET @condition = 'EA.ItemID = @ItemID AND EA.AccountType IN (' + @AccountTypes + ')'
IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL
AND @FilterValue <> '' AND @FilterValue IS NOT NULL
BEGIN
IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2'
BEGIN
SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')'
END
ELSE
BEGIN
SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + ''''
END
END
IF @SortColumn IS NULL OR @SortColumn = ''
SET @SortColumn = 'EA.DisplayName ASC'
DECLARE @sql nvarchar(3500)
SET @sql = '
SELECT
EA.AccountID,
EA.ItemID,
EA.AccountType,
EA.AccountName,
EA.DisplayName,
EA.PrimaryEmailAddress,
EA.MailEnabledPublicFolder,
EA.MailboxPlanId,
P.MailboxPlan,
EA.SubscriberNumber,
EA.UserPrincipalName
FROM
ExchangeAccounts AS EA
LEFT OUTER JOIN ExchangeMailboxPlans AS P ON EA.MailboxPlanId = P.MailboxPlanId
WHERE ' + @condition
+ ' ORDER BY ' + @SortColumn
EXEC sp_executesql @sql, N'@ItemID int', @ItemID
RETURN
GO

View file

@ -3053,7 +3053,7 @@ namespace WebsitePanel.EnterpriseServer
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SearchAccounts", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public ExchangeAccount[] SearchAccounts(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, string filterColumn, string filterValue, string sortColumn)
public ExchangeAccount[] SearchAccounts(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, bool includeSecurityGroups, string filterColumn, string filterValue, string sortColumn)
{
object[] results = this.Invoke("SearchAccounts", new object[] {
itemId,
@ -3062,6 +3062,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists,
includeRooms,
includeEquipment,
includeSecurityGroups,
filterColumn,
filterValue,
sortColumn});
@ -3069,7 +3070,7 @@ namespace WebsitePanel.EnterpriseServer
}
/// <remarks/>
public System.IAsyncResult BeginSearchAccounts(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, string filterColumn, string filterValue, string sortColumn, System.AsyncCallback callback, object asyncState)
public System.IAsyncResult BeginSearchAccounts(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, bool includeSecurityGroups, string filterColumn, string filterValue, string sortColumn, System.AsyncCallback callback, object asyncState)
{
return this.BeginInvoke("SearchAccounts", new object[] {
itemId,
@ -3078,6 +3079,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists,
includeRooms,
includeEquipment,
includeSecurityGroups,
filterColumn,
filterValue,
sortColumn}, callback, asyncState);
@ -3091,13 +3093,13 @@ namespace WebsitePanel.EnterpriseServer
}
/// <remarks/>
public void SearchAccountsAsync(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, string filterColumn, string filterValue, string sortColumn)
public void SearchAccountsAsync(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, bool includeSecurityGroups, string filterColumn, string filterValue, string sortColumn)
{
this.SearchAccountsAsync(itemId, includeMailboxes, includeContacts, includeDistributionLists, includeRooms, includeEquipment, filterColumn, filterValue, sortColumn, null);
this.SearchAccountsAsync(itemId, includeMailboxes, includeContacts, includeDistributionLists, includeRooms, includeEquipment, includeSecurityGroups, filterColumn, filterValue, sortColumn, null);
}
/// <remarks/>
public void SearchAccountsAsync(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, string filterColumn, string filterValue, string sortColumn, object userState)
public void SearchAccountsAsync(int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, bool includeSecurityGroups, string filterColumn, string filterValue, string sortColumn, object userState)
{
if ((this.SearchAccountsOperationCompleted == null))
{
@ -3110,6 +3112,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists,
includeRooms,
includeEquipment,
includeSecurityGroups,
filterColumn,
filterValue,
sortColumn}, this.SearchAccountsOperationCompleted, userState);

View file

@ -133,7 +133,7 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
private System.Threading.SendOrPostCallback GetSecurityGroupsByMemberOperationCompleted;
private System.Threading.SendOrPostCallback SearchSecurityGroupsOperationCompleted;
private System.Threading.SendOrPostCallback SearchOrganizationAccountsOperationCompleted;
/// <remarks/>
public esOrganizations()
@ -244,7 +244,7 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
public event GetSecurityGroupsByMemberCompletedEventHandler GetSecurityGroupsByMemberCompleted;
/// <remarks/>
public event SearchSecurityGroupsCompletedEventHandler SearchSecurityGroupsCompleted;
public event SearchOrganizationAccountsCompletedEventHandler SearchOrganizationAccountsCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckOrgIdExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
@ -2328,60 +2328,63 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SearchSecurityGroups", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public ExchangeAccount[] SearchSecurityGroups(int itemId, string filterColumn, string filterValue, string sortColumn)
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SearchOrganizationAccounts", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public ExchangeAccount[] SearchOrganizationAccounts(int itemId, string filterColumn, string filterValue, string sortColumn, bool includeOnlySecurityGroups)
{
object[] results = this.Invoke("SearchSecurityGroups", new object[] {
object[] results = this.Invoke("SearchOrganizationAccounts", new object[] {
itemId,
filterColumn,
filterValue,
sortColumn});
sortColumn,
includeOnlySecurityGroups});
return ((ExchangeAccount[])(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginSearchSecurityGroups(int itemId, string filterColumn, string filterValue, string sortColumn, System.AsyncCallback callback, object asyncState)
public System.IAsyncResult BeginSearchOrganizationAccounts(int itemId, string filterColumn, string filterValue, string sortColumn, bool includeOnlySecurityGroups, System.AsyncCallback callback, object asyncState)
{
return this.BeginInvoke("SearchSecurityGroups", new object[] {
return this.BeginInvoke("SearchOrganizationAccounts", new object[] {
itemId,
filterColumn,
filterValue,
sortColumn}, callback, asyncState);
sortColumn,
includeOnlySecurityGroups}, callback, asyncState);
}
/// <remarks/>
public ExchangeAccount[] EndSearchSecurityGroups(System.IAsyncResult asyncResult)
public ExchangeAccount[] EndSearchOrganizationAccounts(System.IAsyncResult asyncResult)
{
object[] results = this.EndInvoke(asyncResult);
return ((ExchangeAccount[])(results[0]));
}
/// <remarks/>
public void SearchSecurityGroupsAsync(int itemId, string filterColumn, string filterValue, string sortColumn)
public void SearchOrganizationAccountsAsync(int itemId, string filterColumn, string filterValue, string sortColumn, bool includeOnlySecurityGroups)
{
this.SearchSecurityGroupsAsync(itemId, filterColumn, filterValue, sortColumn, null);
this.SearchOrganizationAccountsAsync(itemId, filterColumn, filterValue, sortColumn, includeOnlySecurityGroups, null);
}
/// <remarks/>
public void SearchSecurityGroupsAsync(int itemId, string filterColumn, string filterValue, string sortColumn, object userState)
public void SearchOrganizationAccountsAsync(int itemId, string filterColumn, string filterValue, string sortColumn, bool includeOnlySecurityGroups, object userState)
{
if ((this.SearchSecurityGroupsOperationCompleted == null))
if ((this.SearchOrganizationAccountsOperationCompleted == null))
{
this.SearchSecurityGroupsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchSecurityGroupsOperationCompleted);
this.SearchOrganizationAccountsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOrganizationAccountsOperationCompleted);
}
this.InvokeAsync("SearchSecurityGroups", new object[] {
this.InvokeAsync("SearchOrganizationAccounts", new object[] {
itemId,
filterColumn,
filterValue,
sortColumn}, this.SearchSecurityGroupsOperationCompleted, userState);
sortColumn,
includeOnlySecurityGroups}, this.SearchOrganizationAccountsOperationCompleted, userState);
}
private void OnSearchSecurityGroupsOperationCompleted(object arg)
private void OnSearchOrganizationAccountsOperationCompleted(object arg)
{
if ((this.SearchSecurityGroupsCompleted != null))
if ((this.SearchOrganizationAccountsCompleted != null))
{
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.SearchSecurityGroupsCompleted(this, new SearchSecurityGroupsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
this.SearchOrganizationAccountsCompleted(this, new SearchOrganizationAccountsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
@ -3414,18 +3417,18 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
public delegate void SearchSecurityGroupsCompletedEventHandler(object sender, SearchSecurityGroupsCompletedEventArgs e);
public delegate void SearchOrganizationAccountsCompletedEventHandler(object sender, SearchOrganizationAccountsCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SearchSecurityGroupsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
public partial class SearchOrganizationAccountsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{
private object[] results;
internal SearchSecurityGroupsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
internal SearchOrganizationAccountsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState)
{
this.results = results;

View file

@ -1952,7 +1952,7 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@finishDate",
finishDate == DateTime.MinValue
? DBNull.Value
: (object) finishDate),
: (object)finishDate),
new SqlParameter("@indicatorCurrent", indicatorCurrent),
new SqlParameter("@indicatorMaximum", indicatorMaximum),
new SqlParameter("@maximumExecutionTime", maximumExecutionTime),
@ -2636,6 +2636,38 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static IDataReader SearchExchangeAccountsByTypes(int actorId, int itemId, string accountTypes,
string filterColumn, string filterValue, string sortColumn)
{
// check input parameters
string[] types = accountTypes.Split(',');
for (int i = 0; i < types.Length; i++)
{
try
{
int type = Int32.Parse(types[i]);
}
catch
{
throw new ArgumentException("Wrong patameter", "accountTypes");
}
}
string searchTypes = String.Join(",", types);
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"SearchExchangeAccountsByTypes",
new SqlParameter("@ActorID", actorId),
new SqlParameter("@ItemID", itemId),
new SqlParameter("@AccountTypes", searchTypes),
new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)),
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn))
);
}
public static DataSet GetExchangeAccountsPaged(int actorId, int itemId, string accountTypes,
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
@ -2672,7 +2704,7 @@ namespace WebsitePanel.EnterpriseServer
public static IDataReader SearchExchangeAccounts(int actorId, int itemId, bool includeMailboxes,
bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment,
string filterColumn, string filterValue, string sortColumn)
bool includeSecurityGroups, string filterColumn, string filterValue, string sortColumn)
{
return SqlHelper.ExecuteReader(
ConnectionString,
@ -2685,6 +2717,7 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@IncludeDistributionLists", includeDistributionLists),
new SqlParameter("@IncludeRooms", includeRooms),
new SqlParameter("@IncludeEquipment", includeEquipment),
new SqlParameter("@IncludeSecurityGroups", includeSecurityGroups),
new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)),
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn))

View file

@ -60,7 +60,7 @@ namespace WebsitePanel.EnterpriseServer
OrganizationStatistics stats = GetOrganizationStatistics(orgId);
if (stats.AllocatedUsers != -1 && (stats.CreatedUsers >= stats.AllocatedUsers) )
if (stats.AllocatedUsers != -1 && (stats.CreatedUsers >= stats.AllocatedUsers))
{
errorCode = BusinessErrorCodes.ERROR_USERS_RESOURCE_QUOTA_LIMIT;
return false;
@ -165,7 +165,7 @@ namespace WebsitePanel.EnterpriseServer
if (errorCode < 0) return false;
// check organizations quota
QuotaValueInfo quota = PackageController.GetPackageQuota(packageId, Quotas.ORGANIZATIONS );
QuotaValueInfo quota = PackageController.GetPackageQuota(packageId, Quotas.ORGANIZATIONS);
if (quota.QuotaExhausted)
{
errorCode = BusinessErrorCodes.ERROR_ORGS_RESOURCE_QUOTA_LIMIT;
@ -191,7 +191,7 @@ namespace WebsitePanel.EnterpriseServer
StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
string tempDomain = serviceSettings[TemporyDomainName];
return String.IsNullOrEmpty(tempDomain) ? null : organizationId + "."+ tempDomain;
return String.IsNullOrEmpty(tempDomain) ? null : organizationId + "." + tempDomain;
}
private static DomainInfo CreateNewDomain(int packageId, string domainName)
@ -271,20 +271,20 @@ namespace WebsitePanel.EnterpriseServer
return DataProvider.ExchangeOrganizationExists(organizationId);
}
private static void RollbackOrganization(int packageId, string organizationId)
{
try
{
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedOrganizations);
Organizations orgProxy = GetOrganizationProxy(serviceId);
orgProxy.DeleteOrganization(organizationId);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
public static int CreateOrganization(int packageId, string organizationId, string organizationName, string domainName)
private static void RollbackOrganization(int packageId, string organizationId)
{
try
{
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedOrganizations);
Organizations orgProxy = GetOrganizationProxy(serviceId);
orgProxy.DeleteOrganization(organizationId);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
public static int CreateOrganization(int packageId, string organizationId, string organizationName, string domainName)
{
int itemId;
int errorCode;
@ -298,25 +298,25 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.StartTask("ORGANIZATION", "CREATE_ORG", organizationName, parameters);
try
{
// Check if organization exitsts.
if (OrganizationIdentifierExists(organizationId))
return BusinessErrorCodes.ERROR_ORG_ID_EXISTS;
try
{
// Check if organization exitsts.
if (OrganizationIdentifierExists(organizationId))
return BusinessErrorCodes.ERROR_ORG_ID_EXISTS;
// Create Organization Unit
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedOrganizations);
// Create Organization Unit
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedOrganizations);
Organizations orgProxy = GetOrganizationProxy(serviceId);
Organization org = null;
if (!orgProxy.OrganizationExists(organizationId))
{
org = orgProxy.CreateOrganization(organizationId);
}
else
return BusinessErrorCodes.ERROR_ORG_ID_EXISTS;
Organizations orgProxy = GetOrganizationProxy(serviceId);
Organization org = null;
if (!orgProxy.OrganizationExists(organizationId))
{
org = orgProxy.CreateOrganization(organizationId);
}
else
return BusinessErrorCodes.ERROR_ORG_ID_EXISTS;
//create temporary domain name;
//create temporary domain name;
if (string.IsNullOrEmpty(domainName))
{
string tmpDomainName = CreateTemporyDomainName(serviceId, organizationId);
@ -324,22 +324,22 @@ namespace WebsitePanel.EnterpriseServer
if (!string.IsNullOrEmpty(tmpDomainName)) domainName = tmpDomainName;
}
if (string.IsNullOrEmpty(domainName))
{
if (string.IsNullOrEmpty(domainName))
{
domainName = organizationName;
//RollbackOrganization(packageId, organizationId);
//return BusinessErrorCodes.ERROR_ORGANIZATION_TEMP_DOMAIN_IS_NOT_SPECIFIED;
}
//RollbackOrganization(packageId, organizationId);
//return BusinessErrorCodes.ERROR_ORGANIZATION_TEMP_DOMAIN_IS_NOT_SPECIFIED;
}
bool domainCreated;
int domainId = CreateDomain(domainName, packageId, out domainCreated);
//create domain
if (domainId < 0)
{
RollbackOrganization(packageId, organizationId);
return domainId;
}
bool domainCreated;
int domainId = CreateDomain(domainName, packageId, out domainCreated);
//create domain
if (domainId < 0)
{
RollbackOrganization(packageId, organizationId);
return domainId;
}
DomainInfo domain = ServerController.GetDomain(domainId);
if (domain != null)
@ -352,58 +352,58 @@ namespace WebsitePanel.EnterpriseServer
}
PackageContext cntx = PackageController.GetPackageContext(packageId);
PackageContext cntx = PackageController.GetPackageContext(packageId);
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE] != null)
org.MaxSharePointStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE] != null)
org.MaxSharePointStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE] != null)
org.WarningSharePointStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE] != null)
org.WarningSharePointStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE].QuotaAllocatedValue;
//add organization to package items
itemId = AddOrganizationToPackageItems(org, serviceId, packageId, organizationName, organizationId, domainName);
//add organization to package items
itemId = AddOrganizationToPackageItems(org, serviceId, packageId, organizationName, organizationId, domainName);
// register org ID
// register org ID
DataProvider.AddExchangeOrganization(itemId, organizationId);
DataProvider.AddExchangeOrganization(itemId, organizationId);
// register domain
DataProvider.AddExchangeOrganizationDomain(itemId, domainId, true);
// register domain
DataProvider.AddExchangeOrganizationDomain(itemId, domainId, true);
//add to exchangeAcounts
AddAccount(itemId, ExchangeAccountType.DefaultSecurityGroup, org.GroupName,
org.GroupName, null, false,
0, org.GroupName, null, 0, null);
// register organization domain service item
OrganizationDomain orgDomain = new OrganizationDomain
{
Name = domainName,
PackageId = packageId,
ServiceId = serviceId
};
// register organization domain service item
OrganizationDomain orgDomain = new OrganizationDomain
{
Name = domainName,
PackageId = packageId,
ServiceId = serviceId
};
PackageController.AddPackageItem(orgDomain);
PackageController.AddPackageItem(orgDomain);
}
catch (Exception ex)
{
//rollback organization
try
{
RollbackOrganization(packageId, organizationId);
}
catch (Exception rollbackException)
{
TaskManager.WriteError(rollbackException);
}
}
catch (Exception ex)
{
//rollback organization
try
{
RollbackOrganization(packageId, organizationId);
}
catch (Exception rollbackException)
{
TaskManager.WriteError(rollbackException);
}
throw TaskManager.WriteError(ex);
}
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
@ -478,51 +478,51 @@ namespace WebsitePanel.EnterpriseServer
{
try
{
OCSUsersPagedResult res = OCSController.GetOCSUsers(itemId, string.Empty, string.Empty, string.Empty,
string.Empty, 0, int.MaxValue);
if (res.IsSuccess)
{
foreach (OCSUser user in res.Value.PageUsers)
{
try
{
ResultObject delUserResult = OCSController.DeleteOCSUser(itemId, user.InstanceId);
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);
}
}
}
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)
OCSUsersPagedResult res = OCSController.GetOCSUsers(itemId, string.Empty, string.Empty, string.Empty,
string.Empty, 0, int.MaxValue);
if (res.IsSuccess)
{
successful = false;
TaskManager.WriteError(ex);
foreach (OCSUser user in res.Value.PageUsers)
{
try
{
ResultObject delUserResult = OCSController.DeleteOCSUser(itemId, user.InstanceId);
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);
}
}
}
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);
}
}
@ -639,7 +639,7 @@ namespace WebsitePanel.EnterpriseServer
if (!delUserResult.IsSuccess)
{
StringBuilder sb = new StringBuilder();
foreach(string str in delUserResult.ErrorCodes)
foreach (string str in delUserResult.ErrorCodes)
{
sb.Append(str);
sb.Append('\n');
@ -648,7 +648,7 @@ namespace WebsitePanel.EnterpriseServer
throw new ApplicationException(sb.ToString());
}
}
catch(Exception ex)
catch (Exception ex)
{
successful = false;
TaskManager.WriteError(ex);
@ -658,7 +658,7 @@ namespace WebsitePanel.EnterpriseServer
else
{
StringBuilder sb = new StringBuilder();
foreach(string str in res.ErrorCodes)
foreach (string str in res.ErrorCodes)
{
sb.Append(str);
sb.Append('\n');
@ -667,7 +667,7 @@ namespace WebsitePanel.EnterpriseServer
throw new ApplicationException(sb.ToString());
}
}
catch(Exception ex)
catch (Exception ex)
{
successful = false;
TaskManager.WriteError(ex);
@ -701,7 +701,7 @@ namespace WebsitePanel.EnterpriseServer
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
try
{
@ -1035,7 +1035,7 @@ namespace WebsitePanel.EnterpriseServer
// change accepted domain type in DB
int domainTypeId= (int) newDomainType;
int domainTypeId = (int)newDomainType;
DataProvider.ChangeExchangeAcceptedDomainType(itemId, domainId, domainTypeId);
return checkResult;
@ -1190,7 +1190,7 @@ namespace WebsitePanel.EnterpriseServer
public static OrganizationUsersPaged GetOrganizationUsersPaged(int itemId, string filterColumn, string filterValue, string sortColumn,
int startRow, int maximumRows)
int startRow, int maximumRows)
{
#region Demo Mode
@ -1509,7 +1509,7 @@ namespace WebsitePanel.EnterpriseServer
/// <returns> The account name with organization Id. </returns>
private static string BuildAccountNameWithOrgId(string orgId, string name, int serviceId)
{
name = name.Length > 5 ? name.Substring(0, 5) : name;
name = ((orgId.Length + name.Length) > 19 && name.Length > 9) ? name.Substring(0, (19 - orgId.Length) < 10 ? 10 : 19 - orgId.Length) : name;
orgId = (orgId.Length + name.Length) > 19 ? orgId.Substring(0, 19 - name.Length) : orgId;
@ -1583,7 +1583,7 @@ namespace WebsitePanel.EnterpriseServer
try
{
Guid crmUserId = CRMController.GetCrmUserId( accountId);
Guid crmUserId = CRMController.GetCrmUserId(accountId);
if (crmUserId != Guid.Empty)
{
return BusinessErrorCodes.CURRENT_USER_IS_CRM_USER;
@ -1697,7 +1697,7 @@ namespace WebsitePanel.EnterpriseServer
// load account
account = GetAccount(itemId, accountId);
}
catch (Exception){}
catch (Exception) { }
try
{
@ -1765,8 +1765,8 @@ namespace WebsitePanel.EnterpriseServer
string accountName = GetAccountName(account.AccountName);
// get mailbox settings
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
// external email
string externalEmailAddress = (account.AccountType == ExchangeAccountType.User ) ? externalEmail : account.PrimaryEmailAddress;
// external email
string externalEmailAddress = (account.AccountType == ExchangeAccountType.User) ? externalEmail : account.PrimaryEmailAddress;
orgProxy.SetUserGeneralSettings(
org.OrganizationId,
@ -1796,7 +1796,7 @@ namespace WebsitePanel.EnterpriseServer
pager,
webPage,
notes,
externalEmailAddress);
externalEmailAddress);
// update account
account.DisplayName = displayName;
@ -1951,7 +1951,7 @@ namespace WebsitePanel.EnterpriseServer
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
orgProxy.SetUserPassword( org.OrganizationId,
orgProxy.SetUserPassword(org.OrganizationId,
accountName,
password);
@ -1989,7 +1989,7 @@ namespace WebsitePanel.EnterpriseServer
public static List<OrganizationUser> SearchAccounts(int itemId,
string filterColumn, string filterValue, string sortColumn, bool includeMailboxes )
string filterColumn, string filterValue, string sortColumn, bool includeMailboxes)
{
#region Demo Mode
if (IsDemoMode)
@ -1998,32 +1998,32 @@ namespace WebsitePanel.EnterpriseServer
OrganizationUser m1 = new OrganizationUser();
m1.AccountId = 1;
m1.AccountName = "john_fabrikam";
m1.AccountType = ExchangeAccountType.Mailbox;
m1.DisplayName = "John Smith";
m1.PrimaryEmailAddress = "john@fabrikam.net";
m1.AccountId = 1;
m1.AccountName = "john_fabrikam";
m1.AccountType = ExchangeAccountType.Mailbox;
m1.DisplayName = "John Smith";
m1.PrimaryEmailAddress = "john@fabrikam.net";
if (includeMailboxes)
demoAccounts.Add(m1);
if (includeMailboxes)
demoAccounts.Add(m1);
OrganizationUser m2 = new OrganizationUser();
m2.AccountId = 2;
m2.AccountName = "jack_fabrikam";
m2.AccountType = ExchangeAccountType.User;
m2.DisplayName = "Jack Brown";
m2.PrimaryEmailAddress = "jack@fabrikam.net";
demoAccounts.Add(m2);
OrganizationUser m2 = new OrganizationUser();
m2.AccountId = 2;
m2.AccountName = "jack_fabrikam";
m2.AccountType = ExchangeAccountType.User;
m2.DisplayName = "Jack Brown";
m2.PrimaryEmailAddress = "jack@fabrikam.net";
demoAccounts.Add(m2);
OrganizationUser m3 = new OrganizationUser();
m3.AccountId = 3;
m3.AccountName = "marry_fabrikam";
m3.AccountType = ExchangeAccountType.Mailbox;
m3.DisplayName = "Marry Smith";
m3.PrimaryEmailAddress = "marry@fabrikam.net";
OrganizationUser m3 = new OrganizationUser();
m3.AccountId = 3;
m3.AccountName = "marry_fabrikam";
m3.AccountType = ExchangeAccountType.Mailbox;
m3.DisplayName = "Marry Smith";
m3.PrimaryEmailAddress = "marry@fabrikam.net";
if (includeMailboxes)
demoAccounts.Add(m3);
if (includeMailboxes)
demoAccounts.Add(m3);
return demoAccounts;
@ -2153,7 +2153,7 @@ namespace WebsitePanel.EnterpriseServer
public static PasswordPolicyResult GetPasswordPolicy(int itemId)
{
PasswordPolicyResult res = new PasswordPolicyResult {IsSuccess = true};
PasswordPolicyResult res = new PasswordPolicyResult { IsSuccess = true };
try
{
Organization org = GetOrganization(itemId);
@ -2169,7 +2169,7 @@ namespace WebsitePanel.EnterpriseServer
{
orgProxy = GetOrganizationProxy(org.ServiceId);
}
catch(Exception ex)
catch (Exception ex)
{
res.IsSuccess = false;
res.ErrorCodes.Add(ErrorCodes.CANNOT_GET_ORGANIZATION_PROXY);
@ -2177,17 +2177,17 @@ namespace WebsitePanel.EnterpriseServer
return res;
}
PasswordPolicyResult policyRes = orgProxy.GetPasswordPolicy();
res.ErrorCodes.AddRange(policyRes.ErrorCodes);
if (!policyRes.IsSuccess)
{
res.IsSuccess = false;
return res;
}
PasswordPolicyResult policyRes = orgProxy.GetPasswordPolicy();
res.ErrorCodes.AddRange(policyRes.ErrorCodes);
if (!policyRes.IsSuccess)
{
res.IsSuccess = false;
return res;
}
res.Value = policyRes.Value;
}
catch(Exception ex)
catch (Exception ex)
{
TaskManager.WriteError(ex);
res.IsSuccess = false;
@ -2263,7 +2263,7 @@ namespace WebsitePanel.EnterpriseServer
Organizations orgProxy = GetOrganizationProxy(org.ServiceId);
string groupName = BuildAccountNameWithOrgId(org.OrganizationId, displayName, org.ServiceId);
string groupName = BuildAccountNameWithOrgId(org.OrganizationId, displayName.Replace(" ", ""), org.ServiceId);
TaskManager.Write("accountName :" + groupName);
@ -2332,9 +2332,9 @@ namespace WebsitePanel.EnterpriseServer
securityGroup.IsDefault = account.AccountType == ExchangeAccountType.DefaultSecurityGroup;
List<OrganizationUser> members = new List<OrganizationUser>();
List<ExchangeAccount> members = new List<ExchangeAccount>();
foreach (OrganizationUser user in securityGroup.MembersAccounts)
foreach (ExchangeAccount user in securityGroup.MembersAccounts)
{
OrganizationUser userAccount = GetAccountByAccountName(itemId, user.SamAccountName);
@ -2342,6 +2342,7 @@ namespace WebsitePanel.EnterpriseServer
{
user.AccountId = userAccount.AccountId;
user.AccountName = userAccount.AccountName;
user.DisplayName = userAccount.DisplayName;
user.PrimaryEmailAddress = userAccount.PrimaryEmailAddress;
user.AccountType = userAccount.AccountType;
@ -2610,16 +2611,20 @@ namespace WebsitePanel.EnterpriseServer
// load account
ExchangeAccount account = ExchangeServerController.GetAccount(itemId, accountId);
List<ExchangeAccount> SecurytyGroups = ExchangeServerController.GetAccounts(itemId, ExchangeAccountType.SecurityGroup);
foreach (ExchangeAccount SecurytyGroupAccount in SecurytyGroups)
{
OrganizationSecurityGroup SecurytyGroup = GetSecurityGroupGeneralSettings(itemId, SecurytyGroupAccount.AccountId);
List<ExchangeAccount> securytyGroups = ExchangeServerController.GetAccounts(itemId, ExchangeAccountType.SecurityGroup);
foreach (OrganizationUser member in SecurytyGroup.MembersAccounts)
//load default group
securytyGroups.AddRange(ExchangeServerController.GetAccounts(itemId, ExchangeAccountType.DefaultSecurityGroup));
foreach (ExchangeAccount securityGroupAccount in securytyGroups)
{
OrganizationSecurityGroup securityGroup = GetSecurityGroupGeneralSettings(itemId, securityGroupAccount.AccountId);
foreach (ExchangeAccount member in securityGroup.MembersAccounts)
{
if (member.AccountName == account.AccountName)
{
ret.Add(SecurytyGroupAccount);
ret.Add(securityGroupAccount);
break;
}
@ -2638,39 +2643,83 @@ namespace WebsitePanel.EnterpriseServer
}
}
public static List<ExchangeAccount> SearchSecurityGroups(int itemId, string filterColumn, string filterValue, string sortColumn)
public static List<ExchangeAccount> SearchOrganizationAccounts(int itemId, string filterColumn, string filterValue,
string sortColumn, bool includeOnlySecurityGroups)
{
#region Demo Mode
if (IsDemoMode)
{
List<ExchangeAccount> demoSecurityGroups = new List<ExchangeAccount>();
List<ExchangeAccount> demoAccounts = new List<ExchangeAccount>();
ExchangeAccount m1 = new ExchangeAccount();
m1.AccountId = 1;
m1.AccountName = "john_fabrikam";
m1.AccountType = ExchangeAccountType.Mailbox;
m1.DisplayName = "John Smith";
m1.PrimaryEmailAddress = "john@fabrikam.net";
demoAccounts.Add(m1);
ExchangeAccount m2 = new ExchangeAccount();
m2.AccountId = 2;
m2.AccountName = "jack_fabrikam";
m2.AccountType = ExchangeAccountType.User;
m2.DisplayName = "Jack Brown";
m2.PrimaryEmailAddress = "jack@fabrikam.net";
demoAccounts.Add(m2);
ExchangeAccount m3 = new ExchangeAccount();
m3.AccountId = 3;
m3.AccountName = "marry_fabrikam";
m3.AccountType = ExchangeAccountType.Mailbox;
m3.DisplayName = "Marry Smith";
m3.PrimaryEmailAddress = "marry@fabrikam.net";
demoAccounts.Add(m3);
ExchangeAccount r1 = new ExchangeAccount();
r1.AccountId = 20;
r1.AccountName = "group1_fabrikam";
r1.AccountType = ExchangeAccountType.SecurityGroup;
r1.DisplayName = "Group 1";
demoSecurityGroups.Add(r1);
demoAccounts.Add(r1);
ExchangeAccount r2 = new ExchangeAccount();
r1.AccountId = 21;
r1.AccountName = "group2_fabrikam";
r1.AccountType = ExchangeAccountType.SecurityGroup;
r1.DisplayName = "Group 2";
demoSecurityGroups.Add(r2);
demoAccounts.Add(r2);
return demoSecurityGroups;
return demoAccounts;
}
#endregion
List<ExchangeAccount> accounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>(
DataProvider.SearchExchangeAccounts(
SecurityContext.User.UserId, itemId, false, false, false, false, false, filterColumn, filterValue, sortColumn));
string accountTypes = string.Format("{0}", ((int)ExchangeAccountType.SecurityGroup));
return accounts.Where(x => x.AccountType == ExchangeAccountType.SecurityGroup).ToList();
if (!includeOnlySecurityGroups)
{
accountTypes = string.Format("{0}, {1}, {2}, {3}, {4}", accountTypes, ((int)ExchangeAccountType.User), ((int)ExchangeAccountType.Mailbox),
((int)ExchangeAccountType.Room), ((int)ExchangeAccountType.Equipment));
}
List<ExchangeAccount> tmpAccounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>(
DataProvider.SearchExchangeAccountsByTypes(SecurityContext.User.UserId, itemId,
accountTypes, filterColumn, filterValue, sortColumn));
List<ExchangeAccount> accounts = new List<ExchangeAccount>();
foreach (ExchangeAccount tmpAccount in tmpAccounts.ToArray())
{
if (tmpAccount.AccountType == ExchangeAccountType.SecurityGroup
? GetSecurityGroupGeneralSettings(itemId, tmpAccount.AccountId) != null
: GetUserGeneralSettings(itemId, tmpAccount.AccountId) != null)
{
accounts.Add(tmpAccount);
}
}
return accounts;
}
}
}

View file

@ -190,12 +190,12 @@ namespace WebsitePanel.EnterpriseServer
[WebMethod]
public List<ExchangeAccount> SearchAccounts(int itemId,
bool includeMailboxes, bool includeContacts, bool includeDistributionLists,
bool includeRooms, bool includeEquipment,
bool includeRooms, bool includeEquipment, bool includeSecurityGroups,
string filterColumn, string filterValue, string sortColumn)
{
return ExchangeServerController.SearchAccounts(itemId,
includeMailboxes, includeContacts, includeDistributionLists,
includeRooms, includeEquipment,
includeRooms, includeEquipment, includeSecurityGroups,
filterColumn, filterValue, sortColumn);
}

View file

@ -294,9 +294,11 @@ namespace WebsitePanel.EnterpriseServer
}
[WebMethod]
public List<ExchangeAccount> SearchSecurityGroups(int itemId, string filterColumn, string filterValue, string sortColumn)
public List<ExchangeAccount> SearchOrganizationAccounts(int itemId, string filterColumn, string filterValue,
string sortColumn, bool includeOnlySecurityGroups)
{
return OrganizationController.SearchSecurityGroups(itemId, filterColumn, filterValue, sortColumn);
return OrganizationController.SearchOrganizationAccounts(itemId, filterColumn, filterValue, sortColumn,
includeOnlySecurityGroups);
}
#endregion

View file

@ -58,7 +58,7 @@ namespace WebsitePanel.Providers.HostedSolution
public const string UserPrincipalName = "UserPrincipalName";
public const string GroupType = "GroupType";
public const string Name = "Name";
public const string ExternalEmail = "mail";
public const string ExternalEmail = "mail";
public const string CustomAttribute2 = "extensionAttribute2";
public const string DistinguishedName = "distinguishedName";

View file

@ -44,21 +44,21 @@ namespace WebsitePanel.Providers.HostedSolution
return de;
}
public static string[] GetUsersGroup(string group)
public static string[] GetGroupObjects(string group, string objectType)
{
List<string> rets = new List<string>();
DirectorySearcher deSearch = new DirectorySearcher
{
Filter =
"(&(objectClass=user))"
"(&(objectClass=" + objectType + "))"
};
SearchResultCollection srcUsers = deSearch.FindAll();
SearchResultCollection srcObjects = deSearch.FindAll();
foreach (SearchResult srcUser in srcUsers)
foreach (SearchResult srcObject in srcObjects)
{
DirectoryEntry de = srcUser.GetDirectoryEntry();
DirectoryEntry de = srcObject.GetDirectoryEntry();
PropertyValueCollection props = de.Properties["memberOf"];
foreach (string str in props)
@ -371,20 +371,20 @@ namespace WebsitePanel.Providers.HostedSolution
newGroupObject.CommitChanges();
}
public static void AddUserToGroup(string userPath, string groupPath)
public static void AddObjectToGroup(string objectPath, string groupPath)
{
DirectoryEntry user = new DirectoryEntry(userPath);
DirectoryEntry obj = new DirectoryEntry(objectPath);
DirectoryEntry group = new DirectoryEntry(groupPath);
group.Invoke("Add", user.Path);
group.Invoke("Add", obj.Path);
}
public static void RemoveUserFromGroup(string userPath, string groupPath)
public static void RemoveObjectFromGroup(string obejctPath, string groupPath)
{
DirectoryEntry user = new DirectoryEntry(userPath);
DirectoryEntry obj = new DirectoryEntry(obejctPath);
DirectoryEntry group = new DirectoryEntry(groupPath);
group.Invoke("Remove", user.Path);
group.Invoke("Remove", obj.Path);
}
public static bool AdObjectExists(string path)

View file

@ -19,7 +19,7 @@ namespace WebsitePanel.Providers.HostedSolution
set;
}
public OrganizationUser[] MembersAccounts
public ExchangeAccount[] MembersAccounts
{
get;
set;

View file

@ -102,6 +102,20 @@ namespace WebsitePanel.Providers.HostedSolution
return sb.ToString();
}
private string GetObjectPath(string organizationId, string objName)
{
StringBuilder sb = new StringBuilder();
// append provider
AppendProtocol(sb);
AppendDomainController(sb);
AppendCNPath(sb, objName);
AppendOUPath(sb, organizationId);
AppendOUPath(sb, RootOU);
AppendDomainPath(sb, RootDomain);
return sb.ToString();
}
private string GetGroupPath(string organizationId, string groupName)
{
StringBuilder sb = new StringBuilder();
@ -404,7 +418,7 @@ namespace WebsitePanel.Providers.HostedSolution
HostedSolutionLog.DebugInfo("Group retrieved: {0}", groupPath);
ActiveDirectoryUtils.AddUserToGroup(userPath, groupPath);
ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
HostedSolutionLog.DebugInfo("Added to group: {0}", groupPath);
}
catch (Exception e)
@ -760,7 +774,7 @@ namespace WebsitePanel.Providers.HostedSolution
SearchResult resCollection = searcher.FindOne();
if (resCollection != null)
{
if(resCollection.Properties["samaccountname"] != null)
if (resCollection.Properties["samaccountname"] != null)
bFound = true;
}
}
@ -914,11 +928,28 @@ namespace WebsitePanel.Providers.HostedSolution
securityGroup.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
securityGroup.SAMAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
List<OrganizationUser> members = new List<OrganizationUser>();
List<ExchangeAccount> members = new List<ExchangeAccount>();
foreach (string userPath in ActiveDirectoryUtils.GetUsersGroup(groupName))
foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user"))
{
members.Add(GetUser(userPath));
OrganizationUser tmpUser = GetUser(userPath);
members.Add(new ExchangeAccount
{
AccountName = tmpUser.AccountName,
SamAccountName = tmpUser.SamAccountName
});
}
foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group"))
{
DirectoryEntry groupEntry = ActiveDirectoryUtils.GetADObject(groupPath);
members.Add(new ExchangeAccount
{
AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName),
SamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName)
});
}
securityGroup.MembersAccounts = members.ToArray();
@ -977,13 +1008,20 @@ namespace WebsitePanel.Providers.HostedSolution
ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes);
foreach(string userPath in ActiveDirectoryUtils.GetUsersGroup(groupName)) {
ActiveDirectoryUtils.RemoveUserFromGroup(userPath, path);
foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user"))
{
ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, path);
}
foreach(string user in memberAccounts) {
string userPath = GetUserPath(organizationId, user);
ActiveDirectoryUtils.AddUserToGroup(userPath, path);
foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group"))
{
ActiveDirectoryUtils.RemoveObjectFromGroup(groupPath, path);
}
foreach (string obj in memberAccounts)
{
string objPath = GetObjectPath(organizationId, obj);
ActiveDirectoryUtils.AddObjectToGroup(objPath, path);
}
entry.CommitChanges();
@ -1014,7 +1052,7 @@ namespace WebsitePanel.Providers.HostedSolution
string groupPath = GetGroupPath(organizationId, groupName);
ActiveDirectoryUtils.AddUserToGroup(userPath, groupPath);
ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
}
public void DeleteUserFromSecurityGroup(string organizationId, string loginName, string groupName)
@ -1042,7 +1080,7 @@ namespace WebsitePanel.Providers.HostedSolution
string groupPath = GetGroupPath(organizationId, groupName);
ActiveDirectoryUtils.RemoveUserFromGroup(userPath, groupPath);
ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, groupPath);
}
#endregion

View file

@ -39,7 +39,8 @@
MailboxesEnabled="false"
EnableMailboxOnly="true"
ContactsEnabled="false"
DistributionListsEnabled="true" />
DistributionListsEnabled="true"
SecurityGroupsEnabled="true" />
</ContentTemplate>
</asp:UpdatePanel>

View file

@ -41,7 +41,8 @@
MailboxesEnabled="false"
EnableMailboxOnly="true"
ContactsEnabled="false"
DistributionListsEnabled="true" />
DistributionListsEnabled="true"
SecurityGroupsEnabled="true" />
</ContentTemplate>
</asp:UpdatePanel>

View file

@ -69,6 +69,8 @@
meta:resourcekey="chkIncludeContacts" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkIncludeLists" runat="server" Text="Distribution Lists" Checked="true"
meta:resourcekey="chkIncludeLists" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkIncludeGroups" runat="server" Text="Groups" Checked="true"
meta:resourcekey="chkIncludeGroups" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
</div>
<div class="FormButtonsBarClean">
<div class="FormButtonsBarCleanRight">

View file

@ -67,6 +67,12 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
set { ViewState["DistributionListsEnabled"] = value; }
}
public bool SecurityGroupsEnabled
{
get { return ViewState["SecurityGroupsEnabled"] != null ? (bool)ViewState["SecurityGroupsEnabled"] : false; }
set { ViewState["SecurityGroupsEnabled"] = value; }
}
public int ExcludeAccountId
{
get { return PanelRequest.AccountID; }
@ -109,6 +115,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
chkIncludeContacts.Checked = ContactsEnabled;
chkIncludeLists.Visible = DistributionListsEnabled;
chkIncludeLists.Checked = DistributionListsEnabled;
chkIncludeGroups.Visible = SecurityGroupsEnabled;
chkIncludeGroups.Checked = SecurityGroupsEnabled;
}
// register javascript
@ -131,14 +140,16 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccountType accountType = (ExchangeAccountType)accountTypeId;
string imgName = "mailbox_16.gif";
if (accountType == ExchangeAccountType.Contact)
imgName = "contact_16.gif";
else if (accountType == ExchangeAccountType.DistributionList)
imgName = "dlist_16.gif";
if (accountType == ExchangeAccountType.Contact)
imgName = "contact_16.gif";
else if (accountType == ExchangeAccountType.DistributionList)
imgName = "dlist_16.gif";
else if (accountType == ExchangeAccountType.Room)
imgName = "room_16.gif";
else if (accountType == ExchangeAccountType.Equipment)
imgName = "equipment_16.gif";
else if (accountType == ExchangeAccountType.Equipment)
imgName = "dlist_16.gif";
return GetThemedImage("Exchange/" + imgName);
}
@ -174,7 +185,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, chkIncludeGroups.Checked,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -11,12 +10,6 @@
namespace WebsitePanel.Portal.ExchangeServer.UserControls {
/// <summary>
/// AccountsList class.
/// </summary>
/// <remarks>
/// Auto-generated class.
/// </remarks>
public partial class AccountsList {
/// <summary>
@ -136,6 +129,15 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls {
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkIncludeLists;
/// <summary>
/// chkIncludeGroups control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkIncludeGroups;
/// <summary>
/// SearchPanel control.
/// </summary>

View file

@ -184,7 +184,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, false,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="btnAdd.Text" xml:space="preserve">
<value>Add...</value>
@ -135,6 +135,9 @@
<data name="chkIncludeEquipment.Text" xml:space="preserve">
<value>Equipment</value>
</data>
<data name="chkIncludeGroups" xml:space="preserve">
<value>Groups</value>
</data>
<data name="chkIncludeLists.Text" xml:space="preserve">
<value>Distribution Lists</value>
</data>

View file

@ -116,8 +116,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindPopupAccounts()
{
ExchangeAccount[] accounts = ES.Services.Organizations.SearchSecurityGroups(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
ExchangeAccount[] accounts = ES.Services.Organizations.SearchOrganizationAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", true);
accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray();
@ -158,6 +158,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
gvGroups.DataSource = accounts;
gvGroups.DataBind();
UpdateGridViewAccounts(gvGroups);
btnDelete.Visible = gvGroups.Rows.Count > 0;
}
@ -184,6 +186,39 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
return accounts;
}
private void UpdateGridViewAccounts(GridView gv)
{
CheckBox chkSelectAll = (CheckBox)gv.HeaderRow.FindControl("chkSelectAll");
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
if (chkSelect == null)
{
continue;
}
ExchangeAccountType exAccountType = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
if (exAccountType != ExchangeAccountType.DefaultSecurityGroup)
{
chkSelectAll = null;
chkSelect.Enabled = true;
}
else
{
chkSelect.Enabled = false;
}
}
if (chkSelectAll != null)
{
chkSelectAll.Enabled = false;
}
}
protected void chkIncludeMailboxes_CheckedChanged(object sender, EventArgs e)
{
BindPopupAccounts();

View file

@ -157,7 +157,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, false,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -54,79 +54,12 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
Unselected
}
public bool IncludeMailboxes
{
get
{
object ret = ViewState["IncludeMailboxes"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["IncludeMailboxes"] = value;
}
}
public bool IncludeMailboxesOnly
{
get
{
object ret = ViewState["IncludeMailboxesOnly"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["IncludeMailboxesOnly"] = value;
}
}
public bool ExcludeOCSUsers
{
get
{
object ret = ViewState["ExcludeOCSUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeOCSUsers"] = value;
}
}
public bool ExcludeLyncUsers
{
get
{
object ret = ViewState["ExcludeLyncUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeLyncUsers"] = value;
}
}
public bool ExcludeBESUsers
{
get
{
object ret = ViewState["ExcludeBESUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeBESUsers"] = value;
}
}
public int ExcludeAccountId
{
get { return PanelRequest.AccountID; }
}
public void SetAccounts(OrganizationUser[] accounts)
public void SetAccounts(ExchangeAccount[] accounts)
{
BindAccounts(accounts, false);
}
@ -134,10 +67,10 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
public string[] GetAccounts()
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.All);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.All);
List<string> accountNames = new List<string>();
foreach (OrganizationUser account in selectedAccounts)
foreach (ExchangeAccount account in selectedAccounts)
accountNames.Add(account.AccountName);
return accountNames.ToArray();
@ -178,7 +111,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
protected void btnDelete_Click(object sender, EventArgs e)
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.Unselected);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.Unselected);
// add to the main list
BindAccounts(selectedAccounts.ToArray(), false);
@ -187,7 +120,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
protected void btnAddSelected_Click(object sender, EventArgs e)
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvPopupAccounts, SelectedState.Selected);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvPopupAccounts, SelectedState.Selected);
// add to the main list
BindAccounts(selectedAccounts.ToArray(), true);
@ -206,6 +139,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
case ExchangeAccountType.Equipment:
imgName = "equipment_16.gif";
break;
case ExchangeAccountType.SecurityGroup:
imgName = "dlist_16.gif";
break;
default:
imgName = "admin_16.png";
break;
@ -216,58 +152,23 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindPopupAccounts()
{
OrganizationUser[] accounts = ES.Services.Organizations.SearchAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", IncludeMailboxes);
ExchangeAccount[] accounts = ES.Services.Organizations.SearchOrganizationAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", false);
List<OrganizationUser> newAccounts = new List<OrganizationUser>();
List<ExchangeAccount> newAccounts = new List<ExchangeAccount>();
accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray();
if (ExcludeAccountId > 0)
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
List<ExchangeAccount> updatedAccounts = new List<ExchangeAccount>();
foreach (ExchangeAccount account in accounts)
if (account.AccountId != ExcludeAccountId)
updatedAccounts.Add(account);
accounts = updatedAccounts.ToArray();
}
if (IncludeMailboxesOnly)
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
{
bool addUser = false;
if (account.ExternalEmail != string.Empty) addUser = true;
if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false;
if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false;
if (addUser) updatedAccounts.Add(account);
}
accounts = updatedAccounts.ToArray();
}
else
if ((ExcludeOCSUsers) | (ExcludeBESUsers) | (ExcludeLyncUsers))
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
{
bool addUser = true;
if ((account.IsOCSUser) & (ExcludeOCSUsers)) addUser = false;
if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false;
if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false;
if (addUser) updatedAccounts.Add(account);
}
accounts = updatedAccounts.ToArray();
}
Array.Sort(accounts, CompareAccount);
if (Direction == SortDirection.Ascending)
{
@ -281,21 +182,21 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
gvPopupAccounts.DataBind();
}
private void BindAccounts(OrganizationUser[] newAccounts, bool preserveExisting)
private void BindAccounts(ExchangeAccount[] newAccounts, bool preserveExisting)
{
// get binded addresses
List<OrganizationUser> accounts = new List<OrganizationUser>();
List<ExchangeAccount> accounts = new List<ExchangeAccount>();
if(preserveExisting)
accounts.AddRange(GetGridViewAccounts(gvAccounts, SelectedState.All));
// add new accounts
if (newAccounts != null)
{
foreach (OrganizationUser newAccount in newAccounts)
foreach (ExchangeAccount newAccount in newAccounts)
{
// check if exists
bool exists = false;
foreach (OrganizationUser account in accounts)
foreach (ExchangeAccount account in accounts)
{
if (String.Compare(newAccount.AccountName, account.AccountName, true) == 0)
{
@ -317,9 +218,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
btnDelete.Visible = gvAccounts.Rows.Count > 0;
}
private List<OrganizationUser> GetGridViewAccounts(GridView gv, SelectedState state)
private List<ExchangeAccount> GetGridViewAccounts(GridView gv, SelectedState state)
{
List<OrganizationUser> accounts = new List<OrganizationUser>();
List<ExchangeAccount> accounts = new List<ExchangeAccount>();
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
@ -327,7 +228,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
if (chkSelect == null)
continue;
OrganizationUser account = new OrganizationUser();
ExchangeAccount account = new ExchangeAccount();
account.AccountType = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
account.AccountName = (string)gv.DataKeys[i][0];
account.DisplayName = ((Literal)row.FindControl("litDisplayName")).Text;
@ -352,7 +253,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
set { ViewState[DirectionString] = value; }
}
private static int CompareAccount(OrganizationUser user1, OrganizationUser user2)
private static int CompareAccount(ExchangeAccount user1, ExchangeAccount user2)
{
return string.Compare(user1.DisplayName, user2.DisplayName);
}