fixed bugs
This commit is contained in:
parent
3fc3a425e0
commit
80d4843693
24 changed files with 2453 additions and 2295 deletions
|
@ -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
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1868,7 +1868,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public static IDataReader GetProcessBackgroundTasks(BackgroundTaskStatus status)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "GetProcessBackgroundTasks",
|
||||
ObjectQualifier + "GetProcessBackgroundTasks",
|
||||
new SqlParameter("@status", (int)status));
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
return OrganizationController.SetUserPassword(itemId, accountId, password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[WebMethod]
|
||||
|
@ -290,15 +290,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
[WebMethod]
|
||||
public ExchangeAccount[] GetSecurityGroupsByMember(int itemId, int accountId)
|
||||
{
|
||||
return OrganizationController.GetSecurityGroupsByMember(itemId, accountId);
|
||||
return OrganizationController.GetSecurityGroupsByMember(itemId, accountId);
|
||||
}
|
||||
|
||||
[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
|
||||
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
void SetUserPassword(string organizationId, string accountName, string password);
|
||||
|
||||
void SetUserPrincipalName(string organizationId, string accountName, string userPrincipalName);
|
||||
|
||||
|
||||
bool OrganizationExists(string organizationId);
|
||||
|
||||
void DeleteOrganizationDomain(string organizationDistinguishedName, string domain);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
set;
|
||||
}
|
||||
|
||||
public OrganizationUser[] MembersAccounts
|
||||
public ExchangeAccount[] MembersAccounts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
|
|
@ -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)
|
||||
|
@ -668,7 +682,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
string path = GetUserPath(organizationId, accountName);
|
||||
DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(password))
|
||||
entry.Invoke(ADAttributes.SetPassword, password);
|
||||
|
||||
|
@ -760,8 +774,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
SearchResult resCollection = searcher.FindOne();
|
||||
if (resCollection != null)
|
||||
{
|
||||
if(resCollection.Properties["samaccountname"] != null)
|
||||
bFound = true;
|
||||
if (resCollection.Properties["samaccountname"] != null)
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -848,13 +862,13 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
string path = GetOrganizationPath(organizationId);
|
||||
groupPath = GetGroupPath(organizationId, groupName);
|
||||
|
||||
|
||||
if (!ActiveDirectoryUtils.AdObjectExists(groupPath))
|
||||
{
|
||||
ActiveDirectoryUtils.CreateGroup(path, groupName);
|
||||
|
||||
groupCreated = true;
|
||||
|
||||
|
||||
HostedSolutionLog.DebugInfo("Security Group created: {0}", groupName);
|
||||
}
|
||||
else
|
||||
|
@ -910,15 +924,32 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
OrganizationSecurityGroup securityGroup = new OrganizationSecurityGroup();
|
||||
|
||||
securityGroup.Notes = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes);
|
||||
|
||||
|
||||
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();
|
||||
|
@ -955,7 +986,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
public void SetSecurityGroupGeneralSettings(string organizationId, string groupName, string[] memberAccounts, string notes)
|
||||
{
|
||||
|
||||
|
||||
SetSecurityGroupGeneralSettingsInternal(organizationId, groupName, memberAccounts, notes);
|
||||
}
|
||||
|
||||
|
@ -977,15 +1008,22 @@ 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
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
using WebsitePanel.Providers.Common;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
MailboxesEnabled="false"
|
||||
EnableMailboxOnly="true"
|
||||
ContactsEnabled="false"
|
||||
DistributionListsEnabled="true" />
|
||||
DistributionListsEnabled="true"
|
||||
SecurityGroupsEnabled="true" />
|
||||
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
MailboxesEnabled="false"
|
||||
EnableMailboxOnly="true"
|
||||
ContactsEnabled="false"
|
||||
DistributionListsEnabled="true" />
|
||||
DistributionListsEnabled="true"
|
||||
SecurityGroupsEnabled="true" />
|
||||
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue