Lync 2013 support
This commit is contained in:
parent
6b7916bed6
commit
a7ee79fb88
10 changed files with 1501 additions and 41 deletions
|
@ -433,6 +433,7 @@ GO
|
||||||
|
|
||||||
UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution.CRM2011' WHERE ProviderID = 1201
|
UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution.CRM2011' WHERE ProviderID = 1201
|
||||||
GO
|
GO
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted SharePoint Foundation 2013')
|
IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted SharePoint Foundation 2013')
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery])
|
INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery])
|
||||||
|
@ -441,4 +442,11 @@ END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013, WebsitePanel.Providers.HostedSolution.SharePoint2013' WHERE ProviderID = 1301
|
UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013, WebsitePanel.Providers.HostedSolution.SharePoint2013' WHERE ProviderID = 1301
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'Lync2013')
|
||||||
|
BEGIN
|
||||||
|
INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery])
|
||||||
|
VALUES (1401, 41, N'Lync2013', N'Microsoft Lync Server 2013 Multitenant Hosting Pack', N'WebsitePanel.Providers.HostedSolution.Lync2013, WebsitePanel.Providers.HostedSolution.Lync2013', N'Lync', NULL)
|
||||||
|
END
|
||||||
GO
|
GO
|
|
@ -30,68 +30,64 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace WebsitePanel.Providers.HostedSolution
|
namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
internal class LyncTransaction
|
public class LyncTransaction
|
||||||
{
|
{
|
||||||
List<TransactionAction> actions = null;
|
#region Fields
|
||||||
|
|
||||||
|
private readonly List<TransactionAction> actions;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public List<TransactionAction> Actions
|
||||||
|
{
|
||||||
|
get { return actions; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
public LyncTransaction()
|
public LyncTransaction()
|
||||||
{
|
{
|
||||||
actions = new List<TransactionAction>();
|
actions = new List<TransactionAction>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<TransactionAction> Actions
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public void RegisterNewSipDomain(string id)
|
||||||
{
|
{
|
||||||
get { return actions; }
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewSipDomain, Id = id });
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterNewSipDomain(string id)
|
public void RegisterNewSimpleUrl(string sipDomain, string tenantID)
|
||||||
{
|
{
|
||||||
TransactionAction action = new TransactionAction();
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewSimpleUrl, Id = sipDomain, Account = tenantID });
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewSipDomain;
|
|
||||||
action.Id = id;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterNewSimpleUrl(string sipDomain, string tenantID)
|
public void RegisterNewConferencingPolicy(string id)
|
||||||
{
|
{
|
||||||
TransactionAction action = new TransactionAction();
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewConferencingPolicy, Id = id });
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewSimpleUrl;
|
|
||||||
action.Id = sipDomain;
|
|
||||||
action.Account = tenantID;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterNewCsExternalAccessPolicy(string id)
|
||||||
internal void RegisterNewConferencingPolicy(string id)
|
|
||||||
{
|
{
|
||||||
TransactionAction action = new TransactionAction();
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewExternalAccessPolicy, Id = id });
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewConferencingPolicy;
|
|
||||||
action.Id = id;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterNewCsExternalAccessPolicy(string id)
|
public void RegisterNewCsMobilityPolicy(string id)
|
||||||
{
|
{
|
||||||
TransactionAction action = new TransactionAction();
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewMobilityPolicy, Id = id });
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewExternalAccessPolicy;
|
|
||||||
action.Id = id;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterNewCsMobilityPolicy(string id)
|
public void RegisterNewCsUser(string id)
|
||||||
{
|
{
|
||||||
TransactionAction action = new TransactionAction();
|
Actions.Add(new TransactionAction { ActionType = TransactionAction.TransactionActionTypes.LyncNewUser, Id = id });
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewMobilityPolicy;
|
|
||||||
action.Id = id;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterNewCsUser(string id)
|
#endregion
|
||||||
{
|
|
||||||
TransactionAction action = new TransactionAction();
|
|
||||||
action.ActionType = TransactionAction.TransactionActionTypes.LyncNewUser;
|
|
||||||
action.Id = id;
|
|
||||||
Actions.Add(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -63,6 +63,7 @@
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Web.Services" />
|
<Reference Include="System.Web.Services" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
@ -90,6 +91,7 @@
|
||||||
<Compile Include="HostedSolution\LyncErrorCodes.cs" />
|
<Compile Include="HostedSolution\LyncErrorCodes.cs" />
|
||||||
<Compile Include="HostedSolution\LyncFederationDomain.cs" />
|
<Compile Include="HostedSolution\LyncFederationDomain.cs" />
|
||||||
<Compile Include="HostedSolution\LyncOrganizationStatistics.cs" />
|
<Compile Include="HostedSolution\LyncOrganizationStatistics.cs" />
|
||||||
|
<Compile Include="HostedSolution\LyncTransaction.cs" />
|
||||||
<Compile Include="HostedSolution\LyncUserStatistics.cs" />
|
<Compile Include="HostedSolution\LyncUserStatistics.cs" />
|
||||||
<Compile Include="HostedSolution\LyncStatisticsReport.cs" />
|
<Compile Include="HostedSolution\LyncStatisticsReport.cs" />
|
||||||
<Compile Include="HostedSolution\LyncUser.cs" />
|
<Compile Include="HostedSolution\LyncUser.cs" />
|
||||||
|
|
|
@ -0,0 +1,721 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Management.Automation;
|
||||||
|
using System.Management.Automation.Runspaces;
|
||||||
|
using Microsoft.Rtc.Management.WritableConfig.Settings.Edge;
|
||||||
|
|
||||||
|
namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
{
|
||||||
|
public class Lync2013 : LyncBase
|
||||||
|
{
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
static Lync2013()
|
||||||
|
{
|
||||||
|
LyncRegistryPath = "SOFTWARE\\Microsoft\\Real-Time Communications";
|
||||||
|
LyncVersion = "5";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
#region Organizations
|
||||||
|
|
||||||
|
/// <summary> Creates organization. </summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier. </param>
|
||||||
|
/// <param name="sipDomain"> The sip domain. </param>
|
||||||
|
/// <param name="enableConferencingVideo"> True - if conferencing video should be enabled.</param>
|
||||||
|
/// <param name="maxConferenceSize"> The max conference size.</param>
|
||||||
|
/// <param name="enabledFederation"> True - if federations should be enabled.</param>
|
||||||
|
/// <param name="enabledEnterpriseVoice"> True - if enterprise voice should be enabled.</param>
|
||||||
|
/// <returns> The tenant identifier. </returns>
|
||||||
|
internal override string CreateOrganizationInternal(string organizationId, string sipDomain, bool enableConferencingVideo, int maxConferenceSize, bool enabledFederation, bool enabledEnterpriseVoice)
|
||||||
|
{
|
||||||
|
sipDomain = sipDomain.ToLower();
|
||||||
|
HostedSolutionLog.LogStart("CreateOrganizationInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("sipDomain: {0}", sipDomain);
|
||||||
|
string tenantId;
|
||||||
|
LyncTransaction transaction = StartTransaction();
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
var command = new Command("New-CsSipDomain");
|
||||||
|
command.Parameters.Add("Identity", sipDomain);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewSipDomain(sipDomain);
|
||||||
|
Guid id = Guid.NewGuid();
|
||||||
|
|
||||||
|
AddAdDomainName(organizationId, sipDomain);
|
||||||
|
|
||||||
|
CreateSimpleUrl(runspace, id);
|
||||||
|
transaction.RegisterNewSimpleUrl(sipDomain, id.ToString());
|
||||||
|
|
||||||
|
command = new Command("New-CsConferencingPolicy");
|
||||||
|
command.Parameters.Add("Identity", organizationId);
|
||||||
|
command.Parameters.Add("MaxMeetingSize", ((maxConferenceSize == -1) | (maxConferenceSize > 250)) ? 250 : maxConferenceSize);
|
||||||
|
command.Parameters.Add("AllowIPVideo", enableConferencingVideo);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewConferencingPolicy(organizationId);
|
||||||
|
|
||||||
|
command = new Command("New-CsExternalAccessPolicy");
|
||||||
|
command.Parameters.Add("Identity", organizationId);
|
||||||
|
command.Parameters.Add("EnableFederationAccess", true);
|
||||||
|
command.Parameters.Add("EnableOutsideAccess", true);
|
||||||
|
command.Parameters.Add("EnablePublicCloudAccess", false);
|
||||||
|
command.Parameters.Add("EnablePublicCloudAudioVideoAccess", false);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewCsExternalAccessPolicy(organizationId);
|
||||||
|
|
||||||
|
var allowList = new AllowList();
|
||||||
|
var domain = new DomainPattern(sipDomain);
|
||||||
|
allowList.AllowedDomain.Add(domain);
|
||||||
|
|
||||||
|
AddFederationDomainInternal("", domain.Domain, PoolFQDN);
|
||||||
|
|
||||||
|
command = new Command("New-CsMobilityPolicy");
|
||||||
|
command.Parameters.Add("Identity", organizationId + " EnableOutSideVoice");
|
||||||
|
command.Parameters.Add("EnableMobility", true);
|
||||||
|
command.Parameters.Add("EnableOutsideVoice", true);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewCsMobilityPolicy(organizationId + " EnableOutSideVoice");
|
||||||
|
|
||||||
|
command = new Command("New-CsMobilityPolicy");
|
||||||
|
command.Parameters.Add("Identity", organizationId + " DisableOutSideVoice");
|
||||||
|
command.Parameters.Add("EnableMobility", true);
|
||||||
|
command.Parameters.Add("EnableOutsideVoice", false);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewCsMobilityPolicy(organizationId + " DisableOutSideVoice");
|
||||||
|
|
||||||
|
command = new Command("Invoke-CsManagementStoreReplication");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
tenantId = id.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("CreateOrganizationInternal", ex);
|
||||||
|
RollbackTransaction(transaction);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("CreateOrganizationInternal");
|
||||||
|
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes organization.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="sipDomain"> The sip domain.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool DeleteOrganizationInternal(string organizationId, string sipDomain)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteOrganizationInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("sipDomain: {0}", sipDomain);
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
string path = AddADPrefix(GetOrganizationPath(organizationId));
|
||||||
|
DirectoryEntry ou = ActiveDirectoryUtils.GetADObject(path);
|
||||||
|
string[] sipDs = ActiveDirectoryUtils.GetADObjectPropertyMultiValue(ou, "Url");
|
||||||
|
|
||||||
|
foreach (string sipD in sipDs)
|
||||||
|
{
|
||||||
|
DeleteSipDomain(runspace, sipD);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DeleteConferencingPolicy(runspace, organizationId);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DeleteExternalAccessPolicy(runspace, organizationId);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DeleteMobilityPolicy(runspace, organizationId + " EnableOutSideVoice");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DeleteMobilityPolicy(runspace, organizationId + " DisableOutSideVoice");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
var command = new Command("Invoke-CsManagementStoreReplication");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("DeleteOrganizationInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("DeleteOrganizationInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Users
|
||||||
|
|
||||||
|
/// <summary> Creates the user.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
/// <param name="plan"> The Lync user plan.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool CreateUserInternal(string organizationId, string userUpn, LyncUserPlan plan)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("CreateUserInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn);
|
||||||
|
LyncTransaction transaction = StartTransaction();
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
Guid guid = GetObjectGuid(organizationId, runspace);
|
||||||
|
string[] tmp = userUpn.Split('@');
|
||||||
|
|
||||||
|
if (tmp.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var command = new Command("Get-CsSipDomain");
|
||||||
|
Collection<PSObject> sipDomains = ExecuteShellCommand(runspace, command, false);
|
||||||
|
bool bSipDomainExists = sipDomains.Select(domain => (string) GetPSObjectProperty(domain, "Name")).Any(d => d.ToLower() == tmp[1].ToLower());
|
||||||
|
|
||||||
|
if (!bSipDomainExists)
|
||||||
|
{
|
||||||
|
command = new Command("New-CsSipDomain");
|
||||||
|
command.Parameters.Add("Identity", tmp[1].ToLower());
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewSipDomain(tmp[1].ToLower());
|
||||||
|
AddAdDomainName(organizationId, tmp[1].ToLower());
|
||||||
|
CreateSimpleUrl(runspace, guid);
|
||||||
|
transaction.RegisterNewSimpleUrl(tmp[1].ToLower(), guid.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
command = new Command("Enable-CsUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
command.Parameters.Add("RegistrarPool", PoolFQDN);
|
||||||
|
command.Parameters.Add("SipAddressType", "UserPrincipalName");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
transaction.RegisterNewCsUser(userUpn);
|
||||||
|
|
||||||
|
command = new Command("Get-CsAdUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
SetLyncUserPlanInternal(organizationId, userUpn, plan, runspace);
|
||||||
|
command = new Command("Update-CsAddressBook");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
command = new Command("Update-CsUserDatabase");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("CreateUserInternal", ex);
|
||||||
|
RollbackTransaction(transaction);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("CreateUserInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets users general settings.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
/// <returns> User settings.</returns>
|
||||||
|
internal override LyncUser GetLyncUserGeneralSettingsInternal(string organizationId, string userUpn)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("GetLyncUserGeneralSettingsInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn);
|
||||||
|
var lyncUser = new LyncUser();
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
|
||||||
|
var command = new Command("Get-CsUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runspace, command, false);
|
||||||
|
PSObject user = result[0];
|
||||||
|
|
||||||
|
lyncUser.DisplayName = (string) GetPSObjectProperty(user, "DisplayName");
|
||||||
|
lyncUser.SipAddress = (string) GetPSObjectProperty(user, "SipAddress");
|
||||||
|
lyncUser.LineUri = (string) GetPSObjectProperty(user, "LineURI");
|
||||||
|
|
||||||
|
lyncUser.SipAddress = lyncUser.SipAddress.ToLower().Replace("sip:", "");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("GetLyncUserGeneralSettingsInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("GetLyncUserGeneralSettingsInternal");
|
||||||
|
|
||||||
|
return lyncUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Sets users general settings.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
/// <param name="lyncUser"> The lync user settings.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool SetLyncUserGeneralSettingsInternal(string organizationId, string userUpn, LyncUser lyncUser)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("SetLyncUserGeneralSettingsInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn);
|
||||||
|
|
||||||
|
bool ret = true;
|
||||||
|
Runspace runspace = null;
|
||||||
|
LyncTransaction transaction = StartTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
Guid tenantId = GetObjectGuid(organizationId, runspace);
|
||||||
|
string[] tmp = userUpn.Split('@');
|
||||||
|
|
||||||
|
if (tmp.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var command = new Command("Get-CsSipDomain");
|
||||||
|
Collection<PSObject> sipDomains = ExecuteShellCommand(runspace, command, false);
|
||||||
|
bool bSipDomainExists = sipDomains.Select(domain => (string) GetPSObjectProperty(domain, "Name")).Any(d => d.ToLower() == tmp[1].ToLower());
|
||||||
|
|
||||||
|
if (!bSipDomainExists)
|
||||||
|
{
|
||||||
|
command = new Command("New-CsSipDomain");
|
||||||
|
command.Parameters.Add("Identity", tmp[1].ToLower());
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
transaction.RegisterNewSipDomain(tmp[1].ToLower());
|
||||||
|
|
||||||
|
string path = AddADPrefix(GetOrganizationPath(organizationId));
|
||||||
|
DirectoryEntry ou = ActiveDirectoryUtils.GetADObject(path);
|
||||||
|
string[] sipDs = ActiveDirectoryUtils.GetADObjectPropertyMultiValue(ou, "Url");
|
||||||
|
var listSipDs = new List<string>();
|
||||||
|
listSipDs.AddRange(sipDs);
|
||||||
|
listSipDs.Add(tmp[1]);
|
||||||
|
|
||||||
|
ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "Url", listSipDs.ToArray());
|
||||||
|
ou.CommitChanges();
|
||||||
|
|
||||||
|
CreateSimpleUrl(runspace, tenantId);
|
||||||
|
transaction.RegisterNewSimpleUrl(tmp[1].ToLower(), tenantId.ToString());
|
||||||
|
|
||||||
|
path = AddADPrefix(GetResultObjectDN(organizationId, runspace));
|
||||||
|
DirectoryEntry user = ActiveDirectoryUtils.GetADObject(path);
|
||||||
|
|
||||||
|
if (tmp.Length > 0)
|
||||||
|
{
|
||||||
|
string Url = SimpleUrlRoot + tmp[1];
|
||||||
|
ActiveDirectoryUtils.SetADObjectPropertyValue(user, "msRTCSIP-BaseSimpleUrl", Url.ToLower());
|
||||||
|
}
|
||||||
|
|
||||||
|
user.CommitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
command = new Command("Set-CsUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(lyncUser.SipAddress))
|
||||||
|
{
|
||||||
|
command.Parameters.Add("SipAddress", "SIP:" + lyncUser.SipAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(lyncUser.SipAddress))
|
||||||
|
{
|
||||||
|
command.Parameters.Add("LineUri", lyncUser.LineUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Update-CsAddressBook");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Update-CsUserDatabase");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ret = false;
|
||||||
|
HostedSolutionLog.LogError("SetLyncUserGeneralSettingsInternal", ex);
|
||||||
|
RollbackTransaction(transaction);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("SetLyncUserGeneralSettingsInternal");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Sets users lync plan.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
/// <param name="plan"> The lync plan.</param>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool SetLyncUserPlanInternal(string organizationId, string userUpn, LyncUserPlan plan, Runspace runspace)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("SetLyncUserPlanInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn);
|
||||||
|
bool bCloseRunSpace = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (runspace == null)
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
bCloseRunSpace = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var command = new Command("Grant-CsExternalAccessPolicy");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
command.Parameters.Add("PolicyName", plan.Federation ? organizationId : null);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Grant-CsConferencingPolicy");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
command.Parameters.Add("PolicyName", plan.Federation ? organizationId : null);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Grant-CsMobilityPolicy");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
|
||||||
|
if (plan.Mobility)
|
||||||
|
{
|
||||||
|
command.Parameters.Add("PolicyName", plan.MobilityEnableOutsideVoice ? organizationId + " EnableOutSideVoice" : organizationId + " DisableOutSideVoice");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
command.Parameters.Add("PolicyName", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
command = new Command("Update-CsUserDatabase");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("SetLyncUserPlanInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (bCloseRunSpace)
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("SetLyncUserPlanInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes user.</summary>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool DeleteUserInternal(string userUpn)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteUserInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn);
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
DeleteUser(runspace, userUpn);
|
||||||
|
|
||||||
|
var command = new Command("Get-CsAdUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Update-CsAddressBook");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Update-CsUserDatabase");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("DeleteUserInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("DeleteUserInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Sytsem Related Methods
|
||||||
|
|
||||||
|
/// <summary> Refreshes configuration.</summary>
|
||||||
|
internal override void ReloadConfigurationInternal()
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("ReloadConfigurationInternal");
|
||||||
|
Runspace runspace = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
|
||||||
|
var command = new Command("Enable-CsComputer");
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("ReloadConfigurationInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
HostedSolutionLog.LogEnd("ReloadConfigurationInternal");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Federation Domains
|
||||||
|
|
||||||
|
/// <summary> Gets allowed domains.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <returns> Allowed domains.</returns>
|
||||||
|
internal override LyncFederationDomain[] GetFederationDomainsInternal(string organizationId)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("GetFederationDomainsInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
LyncFederationDomain[] domains;
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
domains = GetFederationDomainsInternal(runspace);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("GetFederationDomainsInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("GetFederationDomainsInternal");
|
||||||
|
|
||||||
|
return domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets allowed domains. </summary>
|
||||||
|
/// <param name="runspace">The runspace.</param>
|
||||||
|
/// <returns> Allowed domains.</returns>
|
||||||
|
private LyncFederationDomain[] GetFederationDomainsInternal(Runspace runspace)
|
||||||
|
{
|
||||||
|
var domains = new List<LyncFederationDomain>();
|
||||||
|
var command = new Command("Get-CsAllowedDomain");
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
if ((result != null) && (result.Count > 0))
|
||||||
|
{
|
||||||
|
domains = result.Select(psObject => new LyncFederationDomain {DomainName = psObject.Properties["Domain"].Value.ToString()}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return domains.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Adds domain to allowed list.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="domainName"> The domain name.</param>
|
||||||
|
/// <param name="proxyFqdn"> The ProxyFQDN.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool AddFederationDomainInternal(string organizationId, string domainName, string proxyFqdn)
|
||||||
|
{
|
||||||
|
domainName = domainName.ToLower();
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
var command = new Command("Get-CsAllowedDomain");
|
||||||
|
command.Parameters.Add("Identity", domainName);
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
if (result != null && !result.Any())
|
||||||
|
{
|
||||||
|
command = new Command("New-CsAllowedDomain");
|
||||||
|
command.Parameters.Add("Identity", domainName);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("Set-CsAllowedDomain");
|
||||||
|
command.Parameters.Add("Identity", domainName);
|
||||||
|
command.Parameters.Add("ProxyFQDN", PoolFQDN);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("AddFederationDomainInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("AddFederationDomainInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Removes domain from allowed list.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="domainName"> The domain name.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal override bool RemoveFederationDomainInternal(string organizationId, string domainName)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("RemoveFederationDomainInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId);
|
||||||
|
HostedSolutionLog.DebugInfo("domainName: {0}", domainName);
|
||||||
|
Runspace runspace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
var command = new Command("Remove-CsAllowedDomain");
|
||||||
|
command.Parameters.Add("Identity", domainName);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("RemoveFederationDomainInternal", ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("RemoveFederationDomainInternal");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets organization lync identifier.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <returns> Organization lync identifier.</returns>
|
||||||
|
private Guid GetObjectGuid(string organizationId, Runspace runspace)
|
||||||
|
{
|
||||||
|
string path = GetOrganizationPath(organizationId);
|
||||||
|
var scripts = new List<string> {string.Format("Get-ADOrganizationalUnit -Identity \"{0}\"", path)};
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runspace, scripts);
|
||||||
|
|
||||||
|
if (result != null && result.Any())
|
||||||
|
{
|
||||||
|
return new Guid(result.First().Properties["ObjectGuid"].Value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Guid.NewGuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets organization distinguished name.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <returns> The distinguished name.</returns>
|
||||||
|
private string GetResultObjectDN(string organizationId, Runspace runspace)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("GetResultObjectDN");
|
||||||
|
|
||||||
|
string path = GetOrganizationPath(organizationId);
|
||||||
|
var scripts = new List<string> {string.Format("Get-ADOrganizationalUnit -Identity \"{0}\"", path)};
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runspace, scripts);
|
||||||
|
|
||||||
|
if (result != null && result.Any())
|
||||||
|
{
|
||||||
|
return result.First().Properties["DistinguishedName"].Value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("Execution result does not contain DistinguishedName property");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Adds domain to AD.</summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <param name="domainName"> The domain name.</param>
|
||||||
|
private void AddAdDomainName(string organizationId, string domainName)
|
||||||
|
{
|
||||||
|
string path = AddADPrefix(GetOrganizationPath(organizationId));
|
||||||
|
DirectoryEntry ou = ActiveDirectoryUtils.GetADObject(path);
|
||||||
|
ActiveDirectoryUtils.SetADObjectPropertyValue(ou, "Url", new[] {domainName});
|
||||||
|
ou.CommitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,611 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Management.Automation;
|
||||||
|
using System.Management.Automation.Runspaces;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
{
|
||||||
|
public class LyncBase : HostingServiceProviderBase, ILyncServer
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private static InitialSessionState session;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
internal static string LyncRegistryPath { get; set; }
|
||||||
|
internal static string LyncVersion { get; set; }
|
||||||
|
|
||||||
|
internal string PoolFQDN
|
||||||
|
{
|
||||||
|
get { return ProviderSettings[LyncConstants.PoolFQDN]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string SimpleUrlRoot
|
||||||
|
{
|
||||||
|
get { return ProviderSettings[LyncConstants.SimpleUrlRoot]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string PrimaryDomainController
|
||||||
|
{
|
||||||
|
get { return ProviderSettings["PrimaryDomainController"]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string RootOU
|
||||||
|
{
|
||||||
|
get { return ProviderSettings["RootOU"]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string RootDomain
|
||||||
|
{
|
||||||
|
get { return ServerSettings.ADRootDomain; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public string CreateOrganization(string organizationId, string sipDomain, bool enableConferencing, bool enableConferencingVideo, int maxConferenceSize, bool enabledFederation, bool enabledEnterpriseVoice)
|
||||||
|
{
|
||||||
|
return CreateOrganizationInternal(organizationId, sipDomain, enableConferencingVideo, maxConferenceSize, enabledFederation, enabledEnterpriseVoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool DeleteOrganization(string organizationId, string sipDomain)
|
||||||
|
{
|
||||||
|
return DeleteOrganizationInternal(organizationId, sipDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool CreateUser(string organizationId, string userUpn, LyncUserPlan plan)
|
||||||
|
{
|
||||||
|
return CreateUserInternal(organizationId, userUpn, plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual LyncUser GetLyncUserGeneralSettings(string organizationId, string userUpn)
|
||||||
|
{
|
||||||
|
return GetLyncUserGeneralSettingsInternal(organizationId, userUpn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool SetLyncUserGeneralSettings(string organizationId, string userUpn, LyncUser lyncUser)
|
||||||
|
{
|
||||||
|
return SetLyncUserGeneralSettingsInternal(organizationId, userUpn, lyncUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool SetLyncUserPlan(string organizationId, string userUpn, LyncUserPlan plan)
|
||||||
|
{
|
||||||
|
return SetLyncUserPlanInternal(organizationId, userUpn, plan, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool DeleteUser(string userUpn)
|
||||||
|
{
|
||||||
|
return DeleteUserInternal(userUpn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual LyncFederationDomain[] GetFederationDomains(string organizationId)
|
||||||
|
{
|
||||||
|
return GetFederationDomainsInternal(organizationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool AddFederationDomain(string organizationId, string domainName, string proxyFqdn)
|
||||||
|
{
|
||||||
|
return AddFederationDomainInternal(organizationId, domainName, proxyFqdn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool RemoveFederationDomain(string organizationId, string domainName)
|
||||||
|
{
|
||||||
|
return RemoveFederationDomainInternal(organizationId, domainName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void ReloadConfiguration()
|
||||||
|
{
|
||||||
|
ReloadConfigurationInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsInstalled()
|
||||||
|
{
|
||||||
|
bool bResult = false;
|
||||||
|
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(LyncRegistryPath);
|
||||||
|
|
||||||
|
if (registryKey != null)
|
||||||
|
{
|
||||||
|
var value = (string) registryKey.GetValue("ProductVersion", null);
|
||||||
|
|
||||||
|
if (value.StartsWith(LyncVersion))
|
||||||
|
{
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
registryKey.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual string CreateOrganizationInternal(string organizationId, string sipDomain, bool enableConferencingVideo, int maxConferenceSize, bool enabledFederation, bool enabledEnterpriseVoice)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool DeleteOrganizationInternal(string organizationId, string sipDomain)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool CreateUserInternal(string organizationId, string userUpn, LyncUserPlan plan)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual LyncUser GetLyncUserGeneralSettingsInternal(string organizationId, string userUpn)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool SetLyncUserGeneralSettingsInternal(string organizationId, string userUpn, LyncUser lyncUser)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool SetLyncUserPlanInternal(string organizationId, string userUpn, LyncUserPlan plan, Runspace runspace)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool DeleteUserInternal(string userUpn)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual LyncFederationDomain[] GetFederationDomainsInternal(string organizationId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool AddFederationDomainInternal(string organizationId, string domainName, string proxyFqdn)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual bool RemoveFederationDomainInternal(string organizationId, string domainName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual void ReloadConfigurationInternal()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region PowerShell integration
|
||||||
|
|
||||||
|
/// <summary> Opens runspace.</summary>
|
||||||
|
/// <returns> The runspace.</returns>
|
||||||
|
internal Runspace OpenRunspace()
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("OpenRunspace");
|
||||||
|
|
||||||
|
if (session == null)
|
||||||
|
{
|
||||||
|
session = InitialSessionState.CreateDefault();
|
||||||
|
session.ImportPSModule(new[] {"ActiveDirectory", "Lync"});
|
||||||
|
}
|
||||||
|
|
||||||
|
Runspace runspace = RunspaceFactory.CreateRunspace(session);
|
||||||
|
runspace.Open();
|
||||||
|
runspace.SessionStateProxy.SetVariable("ConfirmPreference", "none");
|
||||||
|
HostedSolutionLog.LogEnd("OpenRunspace");
|
||||||
|
|
||||||
|
return runspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Closes runspace.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
internal void CloseRunspace(Runspace runspace)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
|
||||||
|
{
|
||||||
|
runspace.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("Runspace error", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Executes shell command.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="scripts"> Scripts list.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal Collection<PSObject> ExecuteShellCommand(Runspace runspace, List<string> scripts)
|
||||||
|
{
|
||||||
|
object[] errors;
|
||||||
|
return ExecuteShellCommand(runspace, scripts, out errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Executes shell command.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="command"> The command.</param>
|
||||||
|
/// <param name="useDomainController"> True - if domain controller should be used.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal Collection<PSObject> ExecuteShellCommand(Runspace runspace, Command command, bool useDomainController)
|
||||||
|
{
|
||||||
|
object[] errors;
|
||||||
|
return ExecuteShellCommand(runspace, command, useDomainController, out errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Executes shell command.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="command"> The command.</param>
|
||||||
|
/// <param name="errors"> Errors list.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal Collection<PSObject> ExecuteShellCommand(Runspace runspace, Command command, out object[] errors)
|
||||||
|
{
|
||||||
|
return ExecuteShellCommand(runspace, command, true, out errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Executes shell command.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="command"> The command.</param>
|
||||||
|
/// <param name="useDomainController"> True - if domain controller should be used.</param>
|
||||||
|
/// <param name="errors"> Errors list.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal Collection<PSObject> ExecuteShellCommand(Runspace runspace, Command command, bool useDomainController, out object[] errors)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("ExecuteShellCommand");
|
||||||
|
var errorList = new List<object>();
|
||||||
|
|
||||||
|
if (useDomainController)
|
||||||
|
{
|
||||||
|
var dc = new CommandParameter("DomainController", PrimaryDomainController);
|
||||||
|
if (!command.Parameters.Contains(dc))
|
||||||
|
{
|
||||||
|
command.Parameters.Add(dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.DebugCommand(command);
|
||||||
|
Collection<PSObject> results;
|
||||||
|
Pipeline pipeLine = runspace.CreatePipeline();
|
||||||
|
|
||||||
|
using (pipeLine)
|
||||||
|
{
|
||||||
|
pipeLine.Commands.Add(command);
|
||||||
|
results = pipeLine.Invoke();
|
||||||
|
|
||||||
|
if (pipeLine.Error != null && pipeLine.Error.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (object item in pipeLine.Error.ReadToEnd())
|
||||||
|
{
|
||||||
|
errorList.Add(item);
|
||||||
|
string errorMessage = string.Format("Invoke error: {0}", item);
|
||||||
|
HostedSolutionLog.LogWarning(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
errors = errorList.ToArray();
|
||||||
|
HostedSolutionLog.LogEnd("ExecuteShellCommand");
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Executes shell command.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="scripts"> Scripts list.</param>
|
||||||
|
/// <param name="errors"> Errors list.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal Collection<PSObject> ExecuteShellCommand(Runspace runspace, List<string> scripts, out object[] errors)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("ExecuteShellCommand");
|
||||||
|
var errorList = new List<object>();
|
||||||
|
Collection<PSObject> results;
|
||||||
|
|
||||||
|
using (Pipeline pipeLine = runspace.CreatePipeline())
|
||||||
|
{
|
||||||
|
foreach (string script in scripts)
|
||||||
|
{
|
||||||
|
pipeLine.Commands.AddScript(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
results = pipeLine.Invoke();
|
||||||
|
|
||||||
|
if (pipeLine.Error != null && pipeLine.Error.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (object item in pipeLine.Error.ReadToEnd())
|
||||||
|
{
|
||||||
|
errorList.Add(item);
|
||||||
|
string errorMessage = string.Format("Invoke error: {0}", item);
|
||||||
|
HostedSolutionLog.LogWarning(errorMessage);
|
||||||
|
|
||||||
|
throw new ArgumentException(scripts.First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
errors = errorList.ToArray();
|
||||||
|
HostedSolutionLog.LogEnd("ExecuteShellCommand");
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets PSObject property value.</summary>
|
||||||
|
/// <param name="obj"> The object.</param>
|
||||||
|
/// <param name="name"> The property name.</param>
|
||||||
|
/// <returns> The property value.</returns>
|
||||||
|
internal object GetPSObjectProperty(PSObject obj, string name)
|
||||||
|
{
|
||||||
|
return obj.Members[name].Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Transactions
|
||||||
|
|
||||||
|
/// <summary> Starts the transaction.</summary>
|
||||||
|
/// <returns> The transaction.</returns>
|
||||||
|
internal LyncTransaction StartTransaction()
|
||||||
|
{
|
||||||
|
return new LyncTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Rollbacks the transaction.</summary>
|
||||||
|
/// <param name="transaction"> The transaction.</param>
|
||||||
|
internal void RollbackTransaction(LyncTransaction transaction)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("RollbackTransaction");
|
||||||
|
Runspace runspace = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runspace = OpenRunspace();
|
||||||
|
|
||||||
|
for (int i = transaction.Actions.Count - 1; i > -1; i--)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RollbackAction(transaction.Actions[i], runspace);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("Rollback error", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogError("Rollback error", ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runspace);
|
||||||
|
}
|
||||||
|
HostedSolutionLog.LogEnd("RollbackTransaction");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Rollbacks lync action.</summary>
|
||||||
|
/// <param name="action"> The action.</param>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
private void RollbackAction(TransactionAction action, Runspace runspace)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogInfo("Rollback action: {0}", action.ActionType);
|
||||||
|
switch (action.ActionType)
|
||||||
|
{
|
||||||
|
case TransactionAction.TransactionActionTypes.LyncNewSipDomain:
|
||||||
|
DeleteSipDomain(runspace, action.Id);
|
||||||
|
break;
|
||||||
|
case TransactionAction.TransactionActionTypes.LyncNewUser:
|
||||||
|
DeleteUser(runspace, action.Id);
|
||||||
|
break;
|
||||||
|
case TransactionAction.TransactionActionTypes.LyncNewConferencingPolicy:
|
||||||
|
DeleteConferencingPolicy(runspace, action.Id);
|
||||||
|
break;
|
||||||
|
case TransactionAction.TransactionActionTypes.LyncNewExternalAccessPolicy:
|
||||||
|
DeleteExternalAccessPolicy(runspace, action.Id);
|
||||||
|
break;
|
||||||
|
case TransactionAction.TransactionActionTypes.LyncNewMobilityPolicy:
|
||||||
|
DeleteMobilityPolicy(runspace, action.Id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Helpers
|
||||||
|
|
||||||
|
/// <summary> Gets organizations AD path. </summary>
|
||||||
|
/// <param name="organizationId"> The organization identifier.</param>
|
||||||
|
/// <returns> The organization AD path.</returns>
|
||||||
|
internal string GetOrganizationPath(string organizationId)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
AppendOUPath(sb, organizationId);
|
||||||
|
AppendOUPath(sb, RootOU);
|
||||||
|
AppendDomainPath(sb, RootDomain);
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Appends organizational unit path.</summary>
|
||||||
|
/// <param name="sb"> The string builder.</param>
|
||||||
|
/// <param name="ou"> The organizational unit.</param>
|
||||||
|
internal static void AppendOUPath(StringBuilder sb, string ou)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ou))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string path = ou.Replace("/", "\\");
|
||||||
|
string[] parts = path.Split('\\');
|
||||||
|
for (int i = parts.Length - 1; i != -1; i--)
|
||||||
|
{
|
||||||
|
sb.Append("OU=").Append(parts[i]).Append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Appends domain path.</summary>
|
||||||
|
/// <param name="sb"> The string builder.</param>
|
||||||
|
/// <param name="domain"> The domain name.</param>
|
||||||
|
internal static void AppendDomainPath(StringBuilder sb, string domain)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(domain))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] parts = domain.Split('.');
|
||||||
|
|
||||||
|
for (int i = 0; i < parts.Length; i++)
|
||||||
|
{
|
||||||
|
sb.Append("DC=").Append(parts[i]);
|
||||||
|
|
||||||
|
if (i < (parts.Length - 1))
|
||||||
|
{
|
||||||
|
sb.Append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Adds AD prefix.</summary>
|
||||||
|
/// <param name="path"> The path.</param>
|
||||||
|
/// <returns> The result.</returns>
|
||||||
|
internal string AddADPrefix(string path)
|
||||||
|
{
|
||||||
|
string dn = path;
|
||||||
|
if (!dn.ToUpper().StartsWith("LDAP://"))
|
||||||
|
{
|
||||||
|
dn = string.Format("LDAP://{0}/{1}", PrimaryDomainController, dn);
|
||||||
|
}
|
||||||
|
return dn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes sip domain.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="id"> The identifier.</param>
|
||||||
|
internal void DeleteSipDomain(Runspace runspace, string id)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteSipDomain");
|
||||||
|
HostedSolutionLog.DebugInfo("SipDomain : {0}", id);
|
||||||
|
var command = new Command("Remove-CsSipDomain");
|
||||||
|
command.Parameters.Add("Identity", id);
|
||||||
|
command.Parameters.Add("Confirm", false);
|
||||||
|
command.Parameters.Add("Force", true);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
HostedSolutionLog.LogEnd("DeleteSipDomain");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes user.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="userUpn"> The user UPN.</param>
|
||||||
|
internal void DeleteUser(Runspace runspace, string userUpn)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteUser");
|
||||||
|
HostedSolutionLog.DebugInfo("userUpn : {0}", userUpn);
|
||||||
|
|
||||||
|
var command = new Command("Disable-CsUser");
|
||||||
|
command.Parameters.Add("Identity", userUpn);
|
||||||
|
command.Parameters.Add("Confirm", false);
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
HostedSolutionLog.LogEnd("DeleteUser");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes conferencing policy.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="policyName"> The policy name.</param>
|
||||||
|
internal void DeleteConferencingPolicy(Runspace runspace, string policyName)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteConferencingPolicy");
|
||||||
|
HostedSolutionLog.DebugInfo("policyName : {0}", policyName);
|
||||||
|
|
||||||
|
var command = new Command("Remove-CsConferencingPolicy");
|
||||||
|
command.Parameters.Add("Identity", policyName);
|
||||||
|
command.Parameters.Add("Confirm", false);
|
||||||
|
command.Parameters.Add("Force", true);
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
HostedSolutionLog.LogEnd("DeleteConferencingPolicy");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes external access policy.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="policyName"> The policy name.</param>
|
||||||
|
internal void DeleteExternalAccessPolicy(Runspace runspace, string policyName)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteExternalAccessPolicy");
|
||||||
|
HostedSolutionLog.DebugInfo("policyName : {0}", policyName);
|
||||||
|
|
||||||
|
var command = new Command("Remove-CsExternalAccessPolicy");
|
||||||
|
command.Parameters.Add("Identity", policyName);
|
||||||
|
command.Parameters.Add("Confirm", false);
|
||||||
|
command.Parameters.Add("Force", true);
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
HostedSolutionLog.LogEnd("DeleteExternalAccessPolicy");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Deletes mobility policy.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="policyName"> The policy name.</param>
|
||||||
|
internal void DeleteMobilityPolicy(Runspace runspace, string policyName)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DeleteMobilityPolicy");
|
||||||
|
HostedSolutionLog.DebugInfo("policyName : {0}", policyName);
|
||||||
|
|
||||||
|
var command = new Command("Remove-CsMobilityPolicy");
|
||||||
|
command.Parameters.Add("Identity", policyName);
|
||||||
|
command.Parameters.Add("Confirm", false);
|
||||||
|
command.Parameters.Add("Force", true);
|
||||||
|
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
HostedSolutionLog.LogEnd("DeleteMobilityPolicy");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Creates simple url.</summary>
|
||||||
|
/// <param name="runspace"> The runspace.</param>
|
||||||
|
/// <param name="id"> The identifier.</param>
|
||||||
|
internal void CreateSimpleUrl(Runspace runspace, Guid id)
|
||||||
|
{
|
||||||
|
var command = new Command("Get-CsSipDomain");
|
||||||
|
Collection<PSObject> sipDomains = ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
IList<PSObject> SimpleUrls = new List<PSObject>();
|
||||||
|
|
||||||
|
foreach (PSObject domain in sipDomains)
|
||||||
|
{
|
||||||
|
var d = (string) GetPSObjectProperty(domain, "Name");
|
||||||
|
string Url = SimpleUrlRoot + d;
|
||||||
|
|
||||||
|
command = new Command("New-CsSimpleUrlEntry");
|
||||||
|
command.Parameters.Add("Url", Url);
|
||||||
|
Collection<PSObject> simpleUrlEntry = ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
command = new Command("New-CsSimpleUrl");
|
||||||
|
command.Parameters.Add("Component", "meet");
|
||||||
|
command.Parameters.Add("Domain", d);
|
||||||
|
command.Parameters.Add("SimpleUrl", simpleUrlEntry[0]);
|
||||||
|
command.Parameters.Add("ActiveUrl", Url);
|
||||||
|
Collection<PSObject> simpleUrl = ExecuteShellCommand(runspace, command, false);
|
||||||
|
|
||||||
|
SimpleUrls.Add(simpleUrl[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
command = new Command("Set-CsSimpleUrlConfiguration");
|
||||||
|
command.Parameters.Add("Identity", "Global");
|
||||||
|
command.Parameters.Add("Tenant", id);
|
||||||
|
command.Parameters.Add("SimpleUrl", SimpleUrls);
|
||||||
|
ExecuteShellCommand(runspace, command, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WebsitePanel.Providers.HostedSolution.Lync2013")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("WebsitePanel.Providers.HostedSolution.Lync2013")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("24c20bdd-51ad-406c-9999-96e432477a79")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{EF36A05F-5573-4ED2-A47D-689F1CA1A209}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WebsitePanel.Providers.HostedSolution.Lync2013</RootNamespace>
|
||||||
|
<AssemblyName>WebsitePanel.Providers.HostedSolution.Lync2013</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Rtc.Management.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Rtc.Management.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Rtc.Management.WritableConfig, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Rtc.Management.WritableConfig.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.DirectoryServices" />
|
||||||
|
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Lync2013.cs" />
|
||||||
|
<Compile Include="LyncBase.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WebsitePanel.Providers.Base\WebsitePanel.Providers.Base.csproj">
|
||||||
|
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
|
||||||
|
<Name>WebsitePanel.Providers.Base</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\WebsitePanel.Providers.HostedSolution\WebsitePanel.Providers.HostedSolution.csproj">
|
||||||
|
<Project>{A06DE5E4-4331-47E1-8F46-7B846146B559}</Project>
|
||||||
|
<Name>WebsitePanel.Providers.HostedSolution</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -122,7 +122,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void DebugCommand(Command cmd)
|
public static void DebugCommand(Command cmd)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(cmd.CommandText);
|
StringBuilder sb = new StringBuilder(cmd.CommandText);
|
||||||
foreach (CommandParameter parameter in cmd.Parameters)
|
foreach (CommandParameter parameter in cmd.Parameters)
|
||||||
|
|
|
@ -156,7 +156,6 @@
|
||||||
<Compile Include="Exchange2010SP2.cs" />
|
<Compile Include="Exchange2010SP2.cs" />
|
||||||
<Compile Include="HostedSharePointServer2010.cs" />
|
<Compile Include="HostedSharePointServer2010.cs" />
|
||||||
<Compile Include="Lync2010.cs" />
|
<Compile Include="Lync2010.cs" />
|
||||||
<Compile Include="LyncTransaction.cs" />
|
|
||||||
<Compile Include="OCSEdge2007R2.cs" />
|
<Compile Include="OCSEdge2007R2.cs" />
|
||||||
<Compile Include="OCS2007R2.cs" />
|
<Compile Include="OCS2007R2.cs" />
|
||||||
<Compile Include="CRMProvider.cs" />
|
<Compile Include="CRMProvider.cs" />
|
||||||
|
|
|
@ -132,6 +132,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Providers.Host
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Providers.HostedSolution.SharePoint2013", "WebsitePanel.Providers.HostedSolution.SharePoint2013\WebsitePanel.Providers.HostedSolution.SharePoint2013.csproj", "{24762DC8-6078-4F10-A524-C94ED59BD5D1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Providers.HostedSolution.SharePoint2013", "WebsitePanel.Providers.HostedSolution.SharePoint2013\WebsitePanel.Providers.HostedSolution.SharePoint2013.csproj", "{24762DC8-6078-4F10-A524-C94ED59BD5D1}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.Providers.HostedSolution.Lync2013", "WebsitePanel.Providers.HostedSolution.Lync2013\WebsitePanel.Providers.HostedSolution.Lync2013.csproj", "{EF36A05F-5573-4ED2-A47D-689F1CA1A209}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -672,6 +674,16 @@ Global
|
||||||
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|x86.ActiveCfg = Release|Any CPU
|
{24762DC8-6078-4F10-A524-C94ED59BD5D1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{EF36A05F-5573-4ED2-A47D-689F1CA1A209}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue