From 6cf946b6b442c30051ad266d97e51402d881c4a3 Mon Sep 17 00:00:00 2001 From: robvde Date: Thu, 22 Nov 2012 13:16:41 +0400 Subject: [PATCH] Fixed: Decoupling of userprincipalName and PrimaryEmailAddress OrganizationUsers updated with image buttons with the ability to go directly to offering settings When changing primaryemailaddress, sip address changes accordingly Mailboxes list view updated with Login (=userprincipalName) with the ability to go directly to user setting Lync list view updated with Login (=userprincipalName) with the ability to go directly to user setting --- WebsitePanel/Database/update_db.sql | 386 ++++++++++++++++-- .../LyncProxy.cs | 13 +- .../Code/Data/DataProvider.cs | 37 +- .../ExchangeServerController.cs | 5 + .../Code/HostedSolution/LyncController.cs | 38 +- .../Code/HostedSolution/ReportController.cs | 2 +- .../esLync.asmx.cs | 2 +- .../HostedSolution/ExchangeAccount.cs | 7 + .../HostedSolution/LyncErrorCodes.cs | 3 + .../HostedSolution/LyncUser.cs | 4 +- .../Exchange2007.cs | 2 +- .../Lync2010.cs | 86 +++- .../ExchangeMailboxes.ascx.resx | 6 + .../OrganizationUsers.ascx.resx | 6 + .../ExchangeServer/ExchangeMailboxes.ascx | 10 + .../ExchangeServer/ExchangeMailboxes.ascx.cs | 12 +- .../ExchangeServer/OrganizationUsers.ascx | 14 +- .../ExchangeServer/OrganizationUsers.ascx.cs | 95 ++++- .../App_LocalResources/LyncEditUser.ascx.resx | 3 + .../App_LocalResources/LyncUsers.ascx.resx | 9 +- .../WebsitePanel/Lync/LyncEditUser.ascx | 10 + .../WebsitePanel/Lync/LyncEditUser.ascx.cs | 9 + .../Lync/LyncEditUser.ascx.designer.cs | 58 +-- .../WebsitePanel/Lync/LyncUsers.ascx | 17 +- .../WebsitePanel/Lync/LyncUsers.ascx.cs | 11 +- .../Lync/LyncUsers.ascx.designer.cs | 9 - .../Lync/UserControls/LyncUserSettings.ascx | 2 + .../UserControls/LyncUserSettings.ascx.cs | 102 +++++ .../LyncUserSettings.ascx.designer.cs | 24 ++ .../WebsitePanel.Portal.Modules.csproj | 8 + 30 files changed, 869 insertions(+), 121 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.designer.cs diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index aba5730d..65f678f4 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -569,6 +569,19 @@ UPDATE [dbo].[Quotas] SET [HideQuota] = 1 WHERE [QuotaName] = N'OS.DomainPointer GO +/****** Object: Table [dbo].[ExchangeAccounts] Extend Exchange Accounts with UserPrincipalName ******/ +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='UserPrincipalName') +BEGIN +ALTER TABLE [dbo].[ExchangeAccounts] ADD + [UserPrincipalName] [nvarchar] (300) COLLATE Latin1_General_CI_AS NULL +END +GO + +IF NOT EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE UserPrincipalName IS NOT NULL) +BEGIN + UPDATE [dbo].[ExchangeAccounts] SET [UserPrincipalName] = PrimaryEmailAddress +END +GO /****** Object: Table [dbo].[ExchangeAccounts] Extend Exchange Accounts with SubscriberNumber ******/ @@ -1468,7 +1481,8 @@ INSERT INTO ExchangeAccounts SamAccountName, AccountPassword, MailboxPlanId, - SubscriberNumber + SubscriberNumber, + UserPrincipalName ) VALUES ( @@ -1482,7 +1496,8 @@ VALUES @SamAccountName, @AccountPassword, @MailboxPlanId, - @SubscriberNumber + @SubscriberNumber, + @PrimaryEmailAddress ) SET @AccountID = SCOPE_IDENTITY() @@ -2157,7 +2172,8 @@ SELECT E.MailEnabledPublicFolder, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2242,7 +2258,8 @@ WITH Accounts AS ( EA.PrimaryEmailAddress, EA.MailEnabledPublicFolder, EA.MailboxPlanId, - EA.SubscriberNumber ' + @joincondition + + EA.SubscriberNumber, + EA.UserPrincipalName ' + @joincondition + ' WHERE ' + @condition + ' ) @@ -2291,7 +2308,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2304,6 +2322,37 @@ GO +ALTER PROCEDURE [dbo].[GetExchangeAccountByAccountName] +( + @ItemID int, + @AccountName nvarchar(300) +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountName = @AccountName +RETURN +GO + + IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetExchangeAccountByMailboxPlanId') @@ -2330,7 +2379,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2357,7 +2407,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2380,7 +2431,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2420,7 +2472,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2447,7 +2500,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2470,7 +2524,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2917,7 +2972,8 @@ SELECT E.AccountPassword, E.MailboxPlanId, P.MailboxPlan, - E.SubscriberNumber + E.SubscriberNumber, + E.UserPrincipalName FROM ExchangeAccounts AS E LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId @@ -2947,7 +3003,8 @@ SELECT DisplayName, PrimaryEmailAddress, MailEnabledPublicFolder, - SubscriberNumber + SubscriberNumber, + UserPrincipalName FROM ExchangeAccounts WHERE @@ -3009,7 +3066,8 @@ SELECT MailboxManagerActions, SamAccountName, AccountPassword, - SubscriberNumber + SubscriberNumber, + UserPrincipalName FROM ExchangeAccounts WHERE AccountID = @AccountID @@ -3078,7 +3136,8 @@ SELECT EA.DisplayName, EA.PrimaryEmailAddress, EA.MailEnabledPublicFolder, - EA.SubscriberNumber + EA.SubscriberNumber, + EA.UserPrincipalName FROM ExchangeAccounts AS EA WHERE ' + @condition @@ -3151,7 +3210,8 @@ SELECT EA.AccountName, EA.DisplayName, EA.PrimaryEmailAddress, - EA.SubscriberNumber + EA.SubscriberNumber, + EA.UserPrincipalName FROM ExchangeAccounts AS EA WHERE ' + @condition @@ -3211,7 +3271,7 @@ AS ea.ItemID, ea.AccountName, ea.DisplayName, - ea.PrimaryEmailAddress, + ea.UserPrincipalName, ea.SamAccountName, ou.LyncUserPlanId, lp.LyncUserPlanName @@ -3249,7 +3309,7 @@ AS ea.ItemID, ea.AccountName, ea.DisplayName, - ea.PrimaryEmailAddress, + ea.UserPrincipalName, ea.SamAccountName, ou.LyncUserPlanId, lp.LyncUserPlanName @@ -3678,6 +3738,13 @@ RETURN GO +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='LyncUsers' AND COLS.name='SipAddress') +BEGIN +ALTER TABLE [dbo].[LyncUsers] ADD + [SipAddress] [nvarchar] (300) COLLATE Latin1_General_CI_AS NULL +END +GO + IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetLyncUsers') @@ -3699,7 +3766,8 @@ CREATE TABLE #TempLyncUsers [ItemID] [int] NOT NULL, [AccountName] [nvarchar](300) NOT NULL, [DisplayName] [nvarchar](300) NOT NULL, - [PrimaryEmailAddress] [nvarchar](300) NULL, + [UserPrincipalName] [nvarchar](300) NULL, + [SipAddress] [nvarchar](300) NULL, [SamAccountName] [nvarchar](100) NULL, [LyncUserPlanId] [int] NOT NULL, [LyncUserPlanName] [nvarchar] (300) NOT NULL, @@ -3714,11 +3782,17 @@ BEGIN SET @condition = ''ORDER BY ea.DisplayName'' END -IF (@SortColumn = ''PrimaryEmailAddress'') +IF (@SortColumn = ''UserPrincipalName'') BEGIN - SET @condition = ''ORDER BY ea.PrimaryEmailAddress'' + SET @condition = ''ORDER BY ea.UserPrincipalName'' END +IF (@SortColumn = ''SipAddress'') +BEGIN + SET @condition = ''ORDER BY ou.SipAddress'' +END + + IF (@SortColumn = ''LyncUserPlanName'') BEGIN SET @condition = ''ORDER BY lp.LyncUserPlanName'' @@ -3734,7 +3808,8 @@ set @sql = '' ea.ItemID, ea.AccountName, ea.DisplayName, - ea.PrimaryEmailAddress, + ea.UserPrincipalName, + ou.SipAddress, ea.SamAccountName, ou.LyncUserPlanId, lp.LyncUserPlanName @@ -3770,11 +3845,17 @@ BEGIN SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC END - IF (@SortColumn = ''PrimaryEmailAddress'') + IF (@SortColumn = ''UserPrincipalName'') BEGIN SELECT * FROM #TempLyncUsers - WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC END + IF (@SortColumn = ''SipAddress'') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY SipAddress DESC + END + IF (@SortColumn = ''LyncUserPlanName'') BEGIN SELECT * FROM #TempLyncUsers @@ -3784,7 +3865,7 @@ BEGIN ELSE BEGIN SELECT * FROM #TempLyncUsers - WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC END @@ -3797,6 +3878,134 @@ GO +ALTER PROCEDURE [dbo].[GetLyncUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @StartRow int, + @Count int +) +AS + +CREATE TABLE #TempLyncUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [UserPrincipalName] [nvarchar](300) NULL, + [SipAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL, + [LyncUserPlanId] [int] NOT NULL, + [LyncUserPlanName] [nvarchar] (300) NOT NULL, +) + + +DECLARE @condition nvarchar(700) +SET @condition = '' + +IF (@SortColumn = 'DisplayName') +BEGIN + SET @condition = 'ORDER BY ea.DisplayName' +END + +IF (@SortColumn = 'UserPrincipalName') +BEGIN + SET @condition = 'ORDER BY ea.UserPrincipalName' +END + +IF (@SortColumn = 'SipAddress') +BEGIN + SET @condition = 'ORDER BY ou.SipAddress' +END + + +IF (@SortColumn = 'LyncUserPlanName') +BEGIN + SET @condition = 'ORDER BY lp.LyncUserPlanName' +END + +DECLARE @sql nvarchar(3500) + +set @sql = '' + INSERT INTO + #TempLyncUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.UserPrincipalName, + ou.SipAddress, + ea.SamAccountName, + ou.LyncUserPlanId, + lp.LyncUserPlanName + FROM + ExchangeAccounts ea + INNER JOIN + LyncUsers ou + INNER JOIN + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID + @condition + +exec sp_executesql @sql, N'@ItemID int',@ItemID + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempLyncUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF @SortColumn <> '' AND @SortColumn IS NOT NULL + BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + IF (@SortColumn = 'UserPrincipalName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END + + IF (@SortColumn = 'SipAddress') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY SipAddress DESC + END + + IF (@SortColumn = 'LyncUserPlanName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY LyncUserPlanName DESC + END + END + ELSE + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END + + +END + +DROP TABLE #TempLyncUsers +GO + + + @@ -6596,4 +6805,129 @@ exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @UserID int, @Filter @StartRow, @MaximumRows, @UserID, @FilterValue, @ItemTypeID, @ActorID RETURN -GO \ No newline at end of file +GO + + + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'LyncUserExists') +BEGIN +EXEC sp_executesql N' +CREATE PROCEDURE [dbo].[LyncUserExists] +( + @AccountID int, + @SipAddress nvarchar(300), + @Exists bit OUTPUT +) +AS + + SET @Exists = 0 + IF EXISTS(SELECT * FROM [dbo].[ExchangeAccountEmailAddresses] WHERE [EmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [PrimaryEmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [UserPrincipalName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [AccountName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[LyncUsers] WHERE [SipAddress] = @SipAddress) + BEGIN + SET @Exists = 1 + END + + + RETURN' +END +GO + + + + +ALTER PROCEDURE [dbo].[LyncUserExists] +( + @AccountID int, + @SipAddress nvarchar(300), + @Exists bit OUTPUT +) +AS + + SET @Exists = 0 + IF EXISTS(SELECT * FROM [dbo].[ExchangeAccountEmailAddresses] WHERE [EmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [PrimaryEmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [UserPrincipalName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [AccountName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[LyncUsers] WHERE [SipAddress] = @SipAddress) + BEGIN + SET @Exists = 1 + END + + + RETURN +GO + + + + + +ALTER PROCEDURE [dbo].[AddLyncUser] + @AccountID int, + @LyncUserPlanID int, + @SipAddress nvarchar(300) +AS +INSERT INTO + dbo.LyncUsers + (AccountID, + LyncUserPlanID, + CreatedDate, + ModifiedDate, + SipAddress) +VALUES +( + @AccountID, + @LyncUserPlanID, + getdate(), + getdate(), + @SipAddress +) +GO + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'UpdateLyncUser') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[UpdateLyncUser] +( + @AccountID int, + @SipAddress nvarchar(300) +) +AS + +UPDATE LyncUsers SET + SipAddress = @SipAddress +WHERE + AccountID = @AccountID AND AccountType IN (1,7) + +RETURN' +END +GO + + diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/LyncProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/LyncProxy.cs index b21b13d1..cce2aeac 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/LyncProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/LyncProxy.cs @@ -52,6 +52,7 @@ namespace WebsitePanel.EnterpriseServer { using WebsitePanel.Providers.ResultObjects; + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] @@ -685,13 +686,13 @@ namespace WebsitePanel.EnterpriseServer { /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SetLyncUserGeneralSettings", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) { + public LyncUserResult SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) { object[] results = this.Invoke("SetLyncUserGeneralSettings", new object[] { itemId, accountId, sipAddress, lineUri}); - return ((bool)(results[0])); + return ((LyncUserResult)(results[0])); } /// @@ -704,9 +705,9 @@ namespace WebsitePanel.EnterpriseServer { } /// - public bool EndSetLyncUserGeneralSettings(System.IAsyncResult asyncResult) { + public LyncUserResult EndSetLyncUserGeneralSettings(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); - return ((bool)(results[0])); + return ((LyncUserResult)(results[0])); } /// @@ -1248,10 +1249,10 @@ namespace WebsitePanel.EnterpriseServer { } /// - public bool Result { + public LyncUserResult Result { get { this.RaiseExceptionIfNecessary(); - return ((bool)(this.results[0])); + return ((LyncUserResult)(this.results[0])); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs index 892546ea..f7ab7cf4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs @@ -3257,7 +3257,7 @@ namespace WebsitePanel.EnterpriseServer #region Lync - public static void AddLyncUser(int accountId, int lyncUserPlanId) + public static void AddLyncUser(int accountId, int lyncUserPlanId, string sipAddress) { SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, @@ -3265,10 +3265,24 @@ namespace WebsitePanel.EnterpriseServer new[] { new SqlParameter("@AccountID", accountId), - new SqlParameter("@LyncUserPlanID", lyncUserPlanId) + new SqlParameter("@LyncUserPlanID", lyncUserPlanId), + new SqlParameter("@SipAddress", sipAddress) }); } + public static void UpdateLyncUser(int accountId, string sipAddress) + { + SqlHelper.ExecuteNonQuery(ConnectionString, + CommandType.StoredProcedure, + "UpdateLyncUser", + new[] + { + new SqlParameter("@AccountID", accountId), + new SqlParameter("@SipAddress", sipAddress) + }); + } + + public static bool CheckLyncUserExists(int accountId) { int res = (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "CheckLyncUserExists", @@ -3276,6 +3290,25 @@ namespace WebsitePanel.EnterpriseServer return res > 0; } + public static bool LyncUserExists(int accountId, string sipAddress) + { + SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); + outParam.Direction = ParameterDirection.Output; + + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "LyncUserExists", + new SqlParameter("@AccountID", accountId), + new SqlParameter("@SipAddress", sipAddress), + outParam + ); + + return Convert.ToBoolean(outParam.Value); + } + + + public static IDataReader GetLyncUsers(int itemId, string sortColumn, string sortDirection, int startRow, int count) { SqlParameter[] sqlParams = new SqlParameter[] diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs index 22be24bb..486e2519 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs @@ -2119,6 +2119,11 @@ namespace WebsitePanel.EnterpriseServer ocs.SetUserPrimaryUri(instanceId, emailAddress); } + if (DataProvider.CheckLyncUserExists(account.AccountId)) + { + LyncController.SetLyncUserGeneralSettings(itemId, accountId, emailAddress, null); + } + // save account UpdateAccount(account); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/LyncController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/LyncController.cs index f7184468..a72d5b59 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/LyncController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/LyncController.cs @@ -250,7 +250,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution try { - DataProvider.AddLyncUser(accountId, lyncUserPlanId); + DataProvider.AddLyncUser(accountId, lyncUserPlanId, user.UserPrincipalName); } catch (Exception ex) { @@ -341,12 +341,11 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } - public static bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) + public static LyncUserResult SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) { - TaskManager.StartTask("LYNC", "SET_LYNC_USER_GENERAL_SETTINGS"); + LyncUserResult res = TaskManager.StartResultTask("LYNC", "SET_LYNC_USER_GENERAL_SETTINGS"); LyncUser user = null; - bool ret = true; try { @@ -376,19 +375,38 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution user.LyncUserPlanName = plan.LyncUserPlanName; } - user.PrimaryUri = sipAddress; - user.LineUri = lineUri; + + if (!string.IsNullOrEmpty(sipAddress)) + { + if (sipAddress != usr.UserPrincipalName) + { + if (DataProvider.LyncUserExists(accountId, sipAddress)) + { + TaskManager.CompleteResultTask(res, LyncErrorCodes.ADDRESS_ALREADY_USED); + return res; + } + } + + user.SipAddress = sipAddress; + + } + + if (!string.IsNullOrEmpty(lineUri)) user.LineUri = lineUri; lync.SetLyncUserGeneralSettings(org.OrganizationId, usr.UserPrincipalName, user); + + DataProvider.UpdateLyncUser(accountId, sipAddress); } } catch (Exception ex) { - ret = false; - throw TaskManager.WriteError(ex); + TaskManager.CompleteResultTask(res, LyncErrorCodes.FAILED_SET_SETTINGS, ex); + return res; } - TaskManager.CompleteTask(); - return ret; + + res.IsSuccess = true; + TaskManager.CompleteResultTask(); + return res; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/ReportController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/ReportController.cs index 8f3d5235..adad212f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/ReportController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/ReportController.cs @@ -511,7 +511,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution try { - stats.SipAddress = lyncUser.PrimaryEmailAddress; + stats.SipAddress = lyncUser.SipAddress; if (string.IsNullOrEmpty(lyncUser.LineUri)) stats.PhoneNumber = string.Empty; else stats.PhoneNumber = lyncUser.LineUri; LyncUserPlan plan = LyncController.GetLyncUserPlan(org.Id, lyncUser.LyncUserPlanId); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esLync.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esLync.asmx.cs index 311b66f9..8006be54 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esLync.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esLync.asmx.cs @@ -120,7 +120,7 @@ namespace WebsitePanel.EnterpriseServer } [WebMethod] - public bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) + public LyncUserResult SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri) { return LyncController.SetLyncUserGeneralSettings(itemId, accountId, sipAddress, lineUri); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAccount.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAccount.cs index 36fbfdde..c3299d67 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAccount.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAccount.cs @@ -49,6 +49,7 @@ namespace WebsitePanel.Providers.HostedSolution int mailboxPlanId; string mailboxPlan; string publicFolderPermission; + string userPrincipalName; public int AccountId { @@ -142,5 +143,11 @@ namespace WebsitePanel.Providers.HostedSolution } + public string UserPrincipalName + { + get { return this.userPrincipalName; } + set { this.userPrincipalName = value; } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncErrorCodes.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncErrorCodes.cs index 15cfbae8..4f792ea3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncErrorCodes.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncErrorCodes.cs @@ -70,5 +70,8 @@ public const string CANNOT_REMOVE_LYNC_FEDERATIONDOMAIN = "CANNOT_REMOVE_LYNC_FEDERATIONDOMAIN"; + public const string FAILED_SET_SETTINGS = "FAILED_SET_SETTINGS"; + + public const string ADDRESS_ALREADY_USED = "ADDRESS_ALREADY_USED"; } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncUser.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncUser.cs index 1a4dd851..e95a9436 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncUser.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/LyncUser.cs @@ -34,8 +34,8 @@ namespace WebsitePanel.Providers.HostedSolution { public class LyncUser { - public string PrimaryUri { get; set; } - public string PrimaryEmailAddress { get; set; } + public string SipAddress { get; set; } + public string UserPrincipalName { get; set; } public string DisplayName { get; set; } public string LineUri { get; set; } public int AccountID { get; set; } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index a338e30c..f972983b 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -2592,7 +2592,7 @@ namespace WebsitePanel.Providers.HostedSolution cmd.Parameters.Add("Identity", accountName); cmd.Parameters.Add("PrimarySmtpAddress", primaryEmail); //cmd.Parameters.Add("UserPrincipalName", primaryEmail); - cmd.Parameters.Add("WindowsEmailAddress", primaryEmail); + //cmd.Parameters.Add("WindowsEmailAddress", primaryEmail); ExecuteShellCommand(runSpace, cmd); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs index f058c759..be5e9397 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs @@ -514,8 +514,10 @@ namespace WebsitePanel.Providers.HostedSolution PSObject user = result[0]; lyncUser.DisplayName = (string)GetPSObjectProperty(user, "DisplayName"); - lyncUser.PrimaryUri = (string)GetPSObjectProperty(user, "SipAddress"); + lyncUser.SipAddress = (string)GetPSObjectProperty(user, "SipAddress"); lyncUser.LineUri = (string)GetPSObjectProperty(user, "LineURI"); + + lyncUser.SipAddress = lyncUser.SipAddress.ToLower().Replace("sip:", ""); } catch (Exception ex) { @@ -538,22 +540,96 @@ namespace WebsitePanel.Providers.HostedSolution bool ret = true; Runspace runSpace = null; + Guid tenantId = Guid.Empty; + LyncTransaction transaction = StartTransaction(); + try { runSpace = OpenRunspace(); + Command cmd = new Command("Get-CsTenant"); + cmd.Parameters.Add("Identity", GetOrganizationPath(organizationId)); + Collection result = ExecuteShellCommand(runSpace, cmd, false); + if ((result != null) && (result.Count > 0)) + { + tenantId = (Guid)GetPSObjectProperty(result[0], "TenantId"); - Command cmd = new Command("Set-CsUser"); + string[] tmp = userUpn.Split('@'); + if (tmp.Length < 2) return false; + + // Get SipDomains and verify existence + bool bSipDomainExists = false; + cmd = new Command("Get-CsSipDomain"); + Collection sipDomains = ExecuteShellCommand(runSpace, cmd, false); + + foreach (PSObject domain in sipDomains) + { + string d = (string)GetPSObjectProperty(domain, "Name"); + if (d.ToLower() == tmp[1].ToLower()) + { + bSipDomainExists = true; + break; + } + } + + string path = string.Empty; + + if (!bSipDomainExists) + { + // Create Sip Domain + cmd = new Command("New-CsSipDomain"); + cmd.Parameters.Add("Identity", tmp[1].ToLower()); + ExecuteShellCommand(runSpace, cmd, false); + + transaction.RegisterNewSipDomain(tmp[1].ToLower()); + + + path = AddADPrefix(GetOrganizationPath(organizationId)); + DirectoryEntry ou = ActiveDirectoryUtils.GetADObject(path); + string[] sipDs = (string[])ActiveDirectoryUtils.GetADObjectPropertyMultiValue(ou, "msRTCSIP-Domains"); + List listSipDs = new List(); + listSipDs.AddRange(sipDs); + listSipDs.Add(tmp[1]); + + ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "msRTCSIP-Domains", listSipDs.ToArray()); + ou.CommitChanges(); + + //Create simpleurls + CreateSimpleUrl(runSpace, tmp[1].ToLower(), tenantId); + transaction.RegisterNewSimpleUrl(tmp[1].ToLower(), tenantId.ToString()); + + path = AddADPrefix(GetResultObjectDN(result)); + DirectoryEntry user = ActiveDirectoryUtils.GetADObject(path); + + if (tmp.Length > 0) + { + string Url = SimpleUrlRoot + tmp[1]; + ActiveDirectoryUtils.SetADObjectPropertyValue(user, "msRTCSIP-BaseSimpleUrl", Url.ToLower()); + } + user.CommitChanges(); + } + } + + cmd = new Command("Set-CsUser"); cmd.Parameters.Add("Identity", userUpn); - if (!string.IsNullOrEmpty(lyncUser.PrimaryUri)) cmd.Parameters.Add("SipAddress", lyncUser.PrimaryUri); - if (!string.IsNullOrEmpty(lyncUser.PrimaryUri)) cmd.Parameters.Add("LineUri", lyncUser.LineUri); + if (!string.IsNullOrEmpty(lyncUser.SipAddress)) cmd.Parameters.Add("SipAddress", "SIP:"+lyncUser.SipAddress); + if (!string.IsNullOrEmpty(lyncUser.SipAddress)) cmd.Parameters.Add("LineUri", lyncUser.LineUri); ExecuteShellCommand(runSpace, cmd, false); + + //initiate addressbook generation + cmd = new Command("Update-CsAddressBook"); + ExecuteShellCommand(runSpace, cmd, false); + + //initiate user database replication + cmd = new Command("Update-CsUserDatabase"); + ExecuteShellCommand(runSpace, cmd, false); + } catch (Exception ex) { ret = false; HostedSolutionLog.LogError("SetLyncUserGeneralSettingsInternal", ex); - throw; + RollbackTransaction(transaction); } finally { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/ExchangeMailboxes.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/ExchangeMailboxes.ascx.resx index 1aaeac3a..a254bede 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/ExchangeMailboxes.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/ExchangeMailboxes.ascx.resx @@ -174,4 +174,10 @@ Mailboxes + + Login + + + Login + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUsers.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUsers.ascx.resx index 581e06b6..3923f30b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUsers.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUsers.ascx.resx @@ -180,4 +180,10 @@ Total Users Created for this Tenant: + + Login + + + Login + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx index 851a9b78..35443356 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx @@ -46,6 +46,7 @@ Email AccountName Account Number + Login @@ -67,6 +68,15 @@ + + + + + <%# Eval("UserPrincipalName") %> + + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs index 6a970dc9..f225eb71 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs @@ -47,7 +47,7 @@ namespace WebsitePanel.Portal.ExchangeServer { if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1) { - gvMailboxes.Columns[2].Visible = false; + gvMailboxes.Columns[3].Visible = false; } } } @@ -139,7 +139,15 @@ namespace WebsitePanel.Portal.ExchangeServer // bind stats BindStats(); - } + } + + public string GetOrganizationUserEditUrl(string accountId) + { + return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "edit_user", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID, + "Context=User"); + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx index c6b5f5bf..8db4b2f5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx @@ -47,6 +47,7 @@ Email AccountName Account Number + Login @@ -74,14 +75,15 @@ - - + + + - - - - + /> + /> + /> + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs index 60d76797..07b88d06 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs @@ -48,7 +48,7 @@ namespace WebsitePanel.Portal.HostedSolution { if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1) { - gvUsers.Columns[3].Visible = false; + gvUsers.Columns[4].Visible = false; } } @@ -115,6 +115,52 @@ namespace WebsitePanel.Portal.HostedSolution messageBox.ShowErrorMessage("ORGANIZATIONS_DELETE_USERS", ex); } } + + if (e.CommandName == "OpenMailProperties") + { + int accountId = Utils.ParseInt(e.CommandArgument.ToString(), 0); + + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "mailbox_settings", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID)); + } + + if (e.CommandName == "OpenBlackBerryProperties") + { + int accountId = Utils.ParseInt(e.CommandArgument.ToString(), 0); + + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "edit_blackberry_user", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID)); + } + + if (e.CommandName == "OpenCRMProperties") + { + int accountId = Utils.ParseInt(e.CommandArgument.ToString(), 0); + + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "mailbox_settings", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID)); + } + + if (e.CommandName == "OpenUCProperties") + { + string[] Tmp = e.CommandArgument.ToString().Split('|'); + + int accountId = Utils.ParseInt(Tmp[0], 0); + if (Tmp[1] == "True") + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "edit_ocs_user", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID)); + else + if (Tmp[2] == "True") + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "edit_lync_user", + "AccountID=" + accountId, + "ItemID=" + PanelRequest.ItemID)); + + + + } } @@ -208,7 +254,52 @@ namespace WebsitePanel.Portal.HostedSolution // bind stats BindStats(); - } + } + + + public bool EnableMailImageButton(int accountTypeId) + { + bool imgName = true; + + ExchangeAccountType accountType = (ExchangeAccountType)accountTypeId; + + if (accountType == ExchangeAccountType.User) + imgName = false; + + return imgName; + } + + public bool EnableOCSImageButton(bool IsOCSUser, bool IsLyncUser) + { + bool imgName = false; + + if (IsLyncUser) + imgName = true; + else + if ((IsOCSUser)) + imgName = true; + + return imgName; + } + + public bool EnableBlackBerryImageButton(bool IsBlackBerryUser) + { + bool imgName = false; + + if (IsBlackBerryUser) + imgName = true; + + return imgName; + } + + + public string GetOCSArgument(int accountID, bool IsOCS, bool IsLync) + { + return accountID.ToString() + "|" + IsOCS.ToString() + "|" + IsLync.ToString(); + } + + + } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncEditUser.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncEditUser.ascx.resx index bad6c174..efcae705 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncEditUser.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncEditUser.ascx.resx @@ -135,4 +135,7 @@ Plan Name : + + SIP Address: + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncUsers.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncUsers.ascx.resx index 9114e730..748a13ee 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncUsers.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/App_LocalResources/LyncUsers.ascx.resx @@ -126,8 +126,8 @@ Display name - - Sign-in name + + Login <p>Microsoft Lync Server delivers unified communications to the users, including software-powered VoIP, Web and audio/video conferencing, and enterprise instant messaging.</p> @@ -138,7 +138,7 @@ Display name - Sign-in name + SIP Address Lync Users @@ -152,4 +152,7 @@ No users have been Lync enabled. To enable a user for Lync click "Create Lync User" button. + + Login + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx index bcb77a8f..64305427 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx @@ -7,6 +7,7 @@ <%@ Register Src="../UserControls/QuotaViewer.ascx" TagName="QuotaViewer" TagPrefix="wsp" %> <%@ Register src="../ExchangeServer/UserControls/MailboxSelector.ascx" tagname="MailboxSelector" tagprefix="uc1" %> <%@ Register Src="UserControls/LyncUserPlanSelector.ascx" TagName="LyncUserPlanSelector" TagPrefix="wsp" %> +<%@ Register Src="UserControls/LyncUserSettings.ascx" TagName="LyncUserSettings" TagPrefix="wsp" %>
@@ -38,6 +39,15 @@ + + + + + + + + +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.cs index aa3b96fa..b3b2782b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.cs @@ -52,6 +52,8 @@ namespace WebsitePanel.Portal.Lync litDisplayName.Text = lyncUser.DisplayName; planSelector.planId = lyncUser.LyncUserPlanId.ToString(); + lyncUserSettings.sipAddress = lyncUser.SipAddress; + } protected void btnSave_Click(object sender, EventArgs e) @@ -61,11 +63,18 @@ namespace WebsitePanel.Portal.Lync try { LyncUserResult res = ES.Services.Lync.SetUserLyncPlan(PanelRequest.ItemID, PanelRequest.AccountID, Convert.ToInt32(planSelector.planId)); + if (res.IsSuccess && res.ErrorCodes.Count == 0) + { + res = ES.Services.Lync.SetLyncUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID, lyncUserSettings.sipAddress, string.Empty); + } + if (res.IsSuccess && res.ErrorCodes.Count == 0) { messageBox.ShowSuccessMessage("UPDATE_LYNC_USER"); return; } + else + messageBox.ShowMessage(res, "UPDATE_LYNC_USER", "LYNC"); } catch(Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.designer.cs index 2b64cf15..fb36ea09 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncEditUser.ascx.designer.cs @@ -1,33 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // @@ -122,6 +93,24 @@ namespace WebsitePanel.Portal.Lync { /// protected global::WebsitePanel.Portal.Lync.UserControls.LyncUserPlanSelector planSelector; + /// + /// locSipAddress control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locSipAddress; + + /// + /// lyncUserSettings control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.Lync.UserControls.LyncUserSettings lyncUserSettings; + /// /// btnSave control. /// @@ -130,14 +119,5 @@ namespace WebsitePanel.Portal.Lync { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Button btnSave; - - /// - /// FormComments control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Localize FormComments; } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncUsers.ascx index d0320faa..f94d5abd 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncUsers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncUsers.ascx @@ -41,7 +41,7 @@ DisplayName - Email + Email - - + + + + + <%# Eval("UserPrincipalName") %> + + + + + protected global::WebsitePanel.Portal.QuotaViewer usersQuota; - - /// - /// FormComments control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Localize FormComments; } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx new file mode 100644 index 00000000..5da9df82 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx @@ -0,0 +1,2 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LyncUserSettings.ascx.cs" Inherits="WebsitePanel.Portal.Lync.UserControls.LyncUserSettings" %> + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.cs new file mode 100644 index 00000000..c7b45afa --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.cs @@ -0,0 +1,102 @@ +// Copyright (c) 2011, Outercurve Foundation. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// - Neither the name of the Outercurve Foundation nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Web.UI.WebControls; +using EntServer = WebsitePanel.EnterpriseServer; + +namespace WebsitePanel.Portal.Lync.UserControls +{ + public partial class LyncUserSettings : WebsitePanelControlBase + { + + private string sipAddressToSelect; + + public string sipAddress + { + + get { return ddlSipAddresses.SelectedItem.Value; } + set + { + sipAddressToSelect = value; + foreach (ListItem li in ddlSipAddresses.Items) + { + if (li.Value == value) + { + ddlSipAddresses.ClearSelection(); + li.Selected = true; + break; + } + } + } + } + + public int plansCount + { + get + { + return this.ddlSipAddresses.Items.Count; + } + } + + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + BindAddresses(); + } + } + + private void BindAddresses() + { + + EntServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (EntServer.ExchangeEmailAddress email in emails) + { + ListItem li = new ListItem(); + li.Text = email.EmailAddress; + li.Value = email.EmailAddress; + li.Selected = email.IsPrimary; + ddlSipAddresses.Items.Add(li); + } + + foreach (ListItem li in ddlSipAddresses.Items) + { + if (li.Value == sipAddressToSelect) + { + ddlSipAddresses.ClearSelection(); + li.Selected = true; + break; + } + } + + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.designer.cs new file mode 100644 index 00000000..2cd7f4d3 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/UserControls/LyncUserSettings.ascx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.Lync.UserControls { + + + public partial class LyncUserSettings { + + /// + /// ddlSipAddresses control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlSipAddresses; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index c513660b..bea7dc26 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -297,6 +297,13 @@ LyncUsers.ascx + + LyncUserSettings.ascx + ASPXCodeBehind + + + LyncUserSettings.ascx + LyncUserPlanSelector.ascx ASPXCodeBehind @@ -3807,6 +3814,7 @@ +