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, @IncludeDistributionLists bit,
@IncludeRooms bit, @IncludeRooms bit,
@IncludeEquipment bit, @IncludeEquipment bit,
@IncludeSecurityGroups bit,
@FilterColumn nvarchar(50) = '', @FilterColumn nvarchar(50) = '',
@FilterValue nvarchar(50) = '', @FilterValue nvarchar(50) = '',
@SortColumn nvarchar(50) @SortColumn nvarchar(50)
@ -1998,7 +1999,7 @@ OR (@IncludeContacts = 1 AND EA.AccountType = 2)
OR (@IncludeDistributionLists = 1 AND EA.AccountType = 3) OR (@IncludeDistributionLists = 1 AND EA.AccountType = 3)
OR (@IncludeRooms = 1 AND EA.AccountType = 5) OR (@IncludeRooms = 1 AND EA.AccountType = 5)
OR (@IncludeEquipment = 1 AND EA.AccountType = 6) 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 AND EA.ItemID = @ItemID
' '
@ -2028,8 +2029,71 @@ WHERE ' + @condition
print @sql print @sql
exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts int, exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts int,
@IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit', @IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit, @IncludeSecurityGroups bit',
@ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment @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 RETURN
GO GO

View file

@ -3053,7 +3053,7 @@ namespace WebsitePanel.EnterpriseServer
/// <remarks/> /// <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)] [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[] { object[] results = this.Invoke("SearchAccounts", new object[] {
itemId, itemId,
@ -3062,6 +3062,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists, includeDistributionLists,
includeRooms, includeRooms,
includeEquipment, includeEquipment,
includeSecurityGroups,
filterColumn, filterColumn,
filterValue, filterValue,
sortColumn}); sortColumn});
@ -3069,7 +3070,7 @@ namespace WebsitePanel.EnterpriseServer
} }
/// <remarks/> /// <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[] { return this.BeginInvoke("SearchAccounts", new object[] {
itemId, itemId,
@ -3078,6 +3079,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists, includeDistributionLists,
includeRooms, includeRooms,
includeEquipment, includeEquipment,
includeSecurityGroups,
filterColumn, filterColumn,
filterValue, filterValue,
sortColumn}, callback, asyncState); sortColumn}, callback, asyncState);
@ -3091,13 +3093,13 @@ namespace WebsitePanel.EnterpriseServer
} }
/// <remarks/> /// <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/> /// <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)) if ((this.SearchAccountsOperationCompleted == null))
{ {
@ -3110,6 +3112,7 @@ namespace WebsitePanel.EnterpriseServer
includeDistributionLists, includeDistributionLists,
includeRooms, includeRooms,
includeEquipment, includeEquipment,
includeSecurityGroups,
filterColumn, filterColumn,
filterValue, filterValue,
sortColumn}, this.SearchAccountsOperationCompleted, userState); sortColumn}, this.SearchAccountsOperationCompleted, userState);

View file

@ -133,7 +133,7 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
private System.Threading.SendOrPostCallback GetSecurityGroupsByMemberOperationCompleted; private System.Threading.SendOrPostCallback GetSecurityGroupsByMemberOperationCompleted;
private System.Threading.SendOrPostCallback SearchSecurityGroupsOperationCompleted; private System.Threading.SendOrPostCallback SearchOrganizationAccountsOperationCompleted;
/// <remarks/> /// <remarks/>
public esOrganizations() public esOrganizations()
@ -244,7 +244,7 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution
public event GetSecurityGroupsByMemberCompletedEventHandler GetSecurityGroupsByMemberCompleted; public event GetSecurityGroupsByMemberCompletedEventHandler GetSecurityGroupsByMemberCompleted;
/// <remarks/> /// <remarks/>
public event SearchSecurityGroupsCompletedEventHandler SearchSecurityGroupsCompleted; public event SearchOrganizationAccountsCompletedEventHandler SearchOrganizationAccountsCompleted;
/// <remarks/> /// <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)] [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/> /// <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)] [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[] SearchSecurityGroups(int itemId, string filterColumn, string filterValue, string sortColumn) 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, itemId,
filterColumn, filterColumn,
filterValue, filterValue,
sortColumn}); sortColumn,
includeOnlySecurityGroups});
return ((ExchangeAccount[])(results[0])); return ((ExchangeAccount[])(results[0]));
} }
/// <remarks/> /// <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, itemId,
filterColumn, filterColumn,
filterValue, filterValue,
sortColumn}, callback, asyncState); sortColumn,
includeOnlySecurityGroups}, callback, asyncState);
} }
/// <remarks/> /// <remarks/>
public ExchangeAccount[] EndSearchSecurityGroups(System.IAsyncResult asyncResult) public ExchangeAccount[] EndSearchOrganizationAccounts(System.IAsyncResult asyncResult)
{ {
object[] results = this.EndInvoke(asyncResult); object[] results = this.EndInvoke(asyncResult);
return ((ExchangeAccount[])(results[0])); return ((ExchangeAccount[])(results[0]));
} }
/// <remarks/> /// <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/> /// <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, itemId,
filterColumn, filterColumn,
filterValue, 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)); 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/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [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/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")] [System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SearchSecurityGroupsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs public partial class SearchOrganizationAccountsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{ {
private object[] results; 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) base(exception, cancelled, userState)
{ {
this.results = results; this.results = results;

View file

@ -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, public static DataSet GetExchangeAccountsPaged(int actorId, int itemId, string accountTypes,
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) 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, public static IDataReader SearchExchangeAccounts(int actorId, int itemId, bool includeMailboxes,
bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, 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( return SqlHelper.ExecuteReader(
ConnectionString, ConnectionString,
@ -2685,6 +2717,7 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@IncludeDistributionLists", includeDistributionLists), new SqlParameter("@IncludeDistributionLists", includeDistributionLists),
new SqlParameter("@IncludeRooms", includeRooms), new SqlParameter("@IncludeRooms", includeRooms),
new SqlParameter("@IncludeEquipment", includeEquipment), new SqlParameter("@IncludeEquipment", includeEquipment),
new SqlParameter("@IncludeSecurityGroups", includeSecurityGroups),
new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)), new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)),
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)), new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)) new SqlParameter("@SortColumn", VerifyColumnName(sortColumn))

View file

@ -982,11 +982,11 @@ namespace WebsitePanel.EnterpriseServer
if (IsDemoMode) if (IsDemoMode)
{ {
if (accountType == ExchangeAccountType.Mailbox) if (accountType == ExchangeAccountType.Mailbox)
return SearchAccounts(0, true, false, false, true, true, "", "", ""); return SearchAccounts(0, true, false, false, true, true, false, "", "", "");
else if (accountType == ExchangeAccountType.Contact) else if (accountType == ExchangeAccountType.Contact)
return SearchAccounts(0, false, true, false, false, false, "", "", ""); return SearchAccounts(0, false, true, false, false, false, false, "", "", "");
else if (accountType == ExchangeAccountType.DistributionList) else if (accountType == ExchangeAccountType.DistributionList)
return SearchAccounts(0, false, false, true, false, false, "", "", ""); return SearchAccounts(0, false, false, true, false, false, false, "", "", "");
else else
{ {
List<ExchangeAccount> demoAccounts = new List<ExchangeAccount>(); List<ExchangeAccount> demoAccounts = new List<ExchangeAccount>();
@ -1037,7 +1037,7 @@ namespace WebsitePanel.EnterpriseServer
public static List<ExchangeAccount> SearchAccounts(int itemId, public static List<ExchangeAccount> SearchAccounts(int itemId,
bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeMailboxes, bool includeContacts, bool includeDistributionLists,
bool includeRooms, bool includeEquipment, bool includeRooms, bool includeEquipment, bool includeSecurityGroups,
string filterColumn, string filterValue, string sortColumn) string filterColumn, string filterValue, string sortColumn)
{ {
#region Demo Mode #region Demo Mode
@ -1118,13 +1118,23 @@ namespace WebsitePanel.EnterpriseServer
demoAccounts.Add(d1); demoAccounts.Add(d1);
} }
if (includeSecurityGroups)
{
ExchangeAccount g1 = new ExchangeAccount();
g1.AccountId = 7;
g1.AccountName = "group_fabrikam";
g1.AccountType = ExchangeAccountType.SecurityGroup;
g1.DisplayName = "Fabrikam Sales Dept";
demoAccounts.Add(g1);
}
return demoAccounts; return demoAccounts;
} }
#endregion #endregion
return ObjectUtils.CreateListFromDataReader<ExchangeAccount>( return ObjectUtils.CreateListFromDataReader<ExchangeAccount>(
DataProvider.SearchExchangeAccounts(SecurityContext.User.UserId, itemId, includeMailboxes, includeContacts, DataProvider.SearchExchangeAccounts(SecurityContext.User.UserId, itemId, includeMailboxes, includeContacts,
includeDistributionLists, includeRooms, includeEquipment, includeDistributionLists, includeRooms, includeEquipment, includeSecurityGroups,
filterColumn, filterValue, sortColumn)); filterColumn, filterValue, sortColumn));
} }

View file

@ -1509,7 +1509,7 @@ namespace WebsitePanel.EnterpriseServer
/// <returns> The account name with organization Id. </returns> /// <returns> The account name with organization Id. </returns>
private static string BuildAccountNameWithOrgId(string orgId, string name, int serviceId) 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; orgId = (orgId.Length + name.Length) > 19 ? orgId.Substring(0, 19 - name.Length) : orgId;
@ -2263,7 +2263,7 @@ namespace WebsitePanel.EnterpriseServer
Organizations orgProxy = GetOrganizationProxy(org.ServiceId); 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); TaskManager.Write("accountName :" + groupName);
@ -2332,9 +2332,9 @@ namespace WebsitePanel.EnterpriseServer
securityGroup.IsDefault = account.AccountType == ExchangeAccountType.DefaultSecurityGroup; 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); OrganizationUser userAccount = GetAccountByAccountName(itemId, user.SamAccountName);
@ -2342,6 +2342,7 @@ namespace WebsitePanel.EnterpriseServer
{ {
user.AccountId = userAccount.AccountId; user.AccountId = userAccount.AccountId;
user.AccountName = userAccount.AccountName; user.AccountName = userAccount.AccountName;
user.DisplayName = userAccount.DisplayName;
user.PrimaryEmailAddress = userAccount.PrimaryEmailAddress; user.PrimaryEmailAddress = userAccount.PrimaryEmailAddress;
user.AccountType = userAccount.AccountType; user.AccountType = userAccount.AccountType;
@ -2610,16 +2611,20 @@ namespace WebsitePanel.EnterpriseServer
// load account // load account
ExchangeAccount account = ExchangeServerController.GetAccount(itemId, accountId); ExchangeAccount account = ExchangeServerController.GetAccount(itemId, accountId);
List<ExchangeAccount> SecurytyGroups = ExchangeServerController.GetAccounts(itemId, ExchangeAccountType.SecurityGroup); List<ExchangeAccount> securytyGroups = ExchangeServerController.GetAccounts(itemId, ExchangeAccountType.SecurityGroup);
foreach (ExchangeAccount SecurytyGroupAccount in SecurytyGroups)
{
OrganizationSecurityGroup SecurytyGroup = GetSecurityGroupGeneralSettings(itemId, SecurytyGroupAccount.AccountId);
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) if (member.AccountName == account.AccountName)
{ {
ret.Add(SecurytyGroupAccount); ret.Add(securityGroupAccount);
break; 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 #region Demo Mode
if (IsDemoMode) 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(); ExchangeAccount r1 = new ExchangeAccount();
r1.AccountId = 20; r1.AccountId = 20;
r1.AccountName = "group1_fabrikam"; r1.AccountName = "group1_fabrikam";
r1.AccountType = ExchangeAccountType.SecurityGroup; r1.AccountType = ExchangeAccountType.SecurityGroup;
r1.DisplayName = "Group 1"; r1.DisplayName = "Group 1";
demoSecurityGroups.Add(r1); demoAccounts.Add(r1);
ExchangeAccount r2 = new ExchangeAccount(); ExchangeAccount r2 = new ExchangeAccount();
r1.AccountId = 21; r1.AccountId = 21;
r1.AccountName = "group2_fabrikam"; r1.AccountName = "group2_fabrikam";
r1.AccountType = ExchangeAccountType.SecurityGroup; r1.AccountType = ExchangeAccountType.SecurityGroup;
r1.DisplayName = "Group 2"; r1.DisplayName = "Group 2";
demoSecurityGroups.Add(r2); demoAccounts.Add(r2);
return demoSecurityGroups; return demoAccounts;
} }
#endregion #endregion
List<ExchangeAccount> accounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>( string accountTypes = string.Format("{0}", ((int)ExchangeAccountType.SecurityGroup));
DataProvider.SearchExchangeAccounts(
SecurityContext.User.UserId, itemId, false, false, false, false, false, filterColumn, filterValue, sortColumn));
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] [WebMethod]
public List<ExchangeAccount> SearchAccounts(int itemId, public List<ExchangeAccount> SearchAccounts(int itemId,
bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeMailboxes, bool includeContacts, bool includeDistributionLists,
bool includeRooms, bool includeEquipment, bool includeRooms, bool includeEquipment, bool includeSecurityGroups,
string filterColumn, string filterValue, string sortColumn) string filterColumn, string filterValue, string sortColumn)
{ {
return ExchangeServerController.SearchAccounts(itemId, return ExchangeServerController.SearchAccounts(itemId,
includeMailboxes, includeContacts, includeDistributionLists, includeMailboxes, includeContacts, includeDistributionLists,
includeRooms, includeEquipment, includeRooms, includeEquipment, includeSecurityGroups,
filterColumn, filterValue, sortColumn); filterColumn, filterValue, sortColumn);
} }

View file

@ -294,9 +294,11 @@ namespace WebsitePanel.EnterpriseServer
} }
[WebMethod] [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 #endregion

View file

@ -44,21 +44,21 @@ namespace WebsitePanel.Providers.HostedSolution
return de; return de;
} }
public static string[] GetUsersGroup(string group) public static string[] GetGroupObjects(string group, string objectType)
{ {
List<string> rets = new List<string>(); List<string> rets = new List<string>();
DirectorySearcher deSearch = new DirectorySearcher DirectorySearcher deSearch = new DirectorySearcher
{ {
Filter = 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"]; PropertyValueCollection props = de.Properties["memberOf"];
foreach (string str in props) foreach (string str in props)
@ -371,20 +371,20 @@ namespace WebsitePanel.Providers.HostedSolution
newGroupObject.CommitChanges(); 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); 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); DirectoryEntry group = new DirectoryEntry(groupPath);
group.Invoke("Remove", user.Path); group.Invoke("Remove", obj.Path);
} }
public static bool AdObjectExists(string path) public static bool AdObjectExists(string path)

View file

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

View file

@ -102,6 +102,20 @@ namespace WebsitePanel.Providers.HostedSolution
return sb.ToString(); 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) private string GetGroupPath(string organizationId, string groupName)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -404,7 +418,7 @@ namespace WebsitePanel.Providers.HostedSolution
HostedSolutionLog.DebugInfo("Group retrieved: {0}", groupPath); HostedSolutionLog.DebugInfo("Group retrieved: {0}", groupPath);
ActiveDirectoryUtils.AddUserToGroup(userPath, groupPath); ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
HostedSolutionLog.DebugInfo("Added to group: {0}", groupPath); HostedSolutionLog.DebugInfo("Added to group: {0}", groupPath);
} }
catch (Exception e) catch (Exception e)
@ -914,11 +928,28 @@ namespace WebsitePanel.Providers.HostedSolution
securityGroup.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName); securityGroup.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
securityGroup.SAMAccountName = 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(); securityGroup.MembersAccounts = members.ToArray();
@ -977,13 +1008,20 @@ namespace WebsitePanel.Providers.HostedSolution
ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes); ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes);
foreach(string userPath in ActiveDirectoryUtils.GetUsersGroup(groupName)) { foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user"))
ActiveDirectoryUtils.RemoveUserFromGroup(userPath, path); {
ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, path);
} }
foreach(string user in memberAccounts) { foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group"))
string userPath = GetUserPath(organizationId, user); {
ActiveDirectoryUtils.AddUserToGroup(userPath, path); ActiveDirectoryUtils.RemoveObjectFromGroup(groupPath, path);
}
foreach (string obj in memberAccounts)
{
string objPath = GetObjectPath(organizationId, obj);
ActiveDirectoryUtils.AddObjectToGroup(objPath, path);
} }
entry.CommitChanges(); entry.CommitChanges();
@ -1014,7 +1052,7 @@ namespace WebsitePanel.Providers.HostedSolution
string groupPath = GetGroupPath(organizationId, groupName); string groupPath = GetGroupPath(organizationId, groupName);
ActiveDirectoryUtils.AddUserToGroup(userPath, groupPath); ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
} }
public void DeleteUserFromSecurityGroup(string organizationId, string loginName, string groupName) public void DeleteUserFromSecurityGroup(string organizationId, string loginName, string groupName)
@ -1042,7 +1080,7 @@ namespace WebsitePanel.Providers.HostedSolution
string groupPath = GetGroupPath(organizationId, groupName); string groupPath = GetGroupPath(organizationId, groupName);
ActiveDirectoryUtils.RemoveUserFromGroup(userPath, groupPath); ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, groupPath);
} }
#endregion #endregion

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -112,10 +112,10 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <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>
<resheader name="writer"> <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> </resheader>
<data name="btnAdd.Text" xml:space="preserve"> <data name="btnAdd.Text" xml:space="preserve">
<value>Add...</value> <value>Add...</value>
@ -135,6 +135,9 @@
<data name="chkIncludeEquipment.Text" xml:space="preserve"> <data name="chkIncludeEquipment.Text" xml:space="preserve">
<value>Equipment</value> <value>Equipment</value>
</data> </data>
<data name="chkIncludeGroups" xml:space="preserve">
<value>Groups</value>
</data>
<data name="chkIncludeLists.Text" xml:space="preserve"> <data name="chkIncludeLists.Text" xml:space="preserve">
<value>Distribution Lists</value> <value>Distribution Lists</value>
</data> </data>

View file

@ -116,8 +116,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindPopupAccounts() private void BindPopupAccounts()
{ {
ExchangeAccount[] accounts = ES.Services.Organizations.SearchSecurityGroups(PanelRequest.ItemID, ExchangeAccount[] accounts = ES.Services.Organizations.SearchOrganizationAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", ""); ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", true);
accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray(); accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray();
@ -158,6 +158,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
gvGroups.DataSource = accounts; gvGroups.DataSource = accounts;
gvGroups.DataBind(); gvGroups.DataBind();
UpdateGridViewAccounts(gvGroups);
btnDelete.Visible = gvGroups.Rows.Count > 0; btnDelete.Visible = gvGroups.Rows.Count > 0;
} }
@ -184,6 +186,39 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
return accounts; 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) protected void chkIncludeMailboxes_CheckedChanged(object sender, EventArgs e)
{ {
BindPopupAccounts(); BindPopupAccounts();

View file

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

View file

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