/// <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); }