RDS CAP RAP name forming changed, added pc group to RAP CAP settings
This commit is contained in:
parent
5d2a934867
commit
e49f5223d0
5 changed files with 36 additions and 44 deletions
|
@ -252,11 +252,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
|
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
|
||||||
|
|
||||||
var package = PackageController.GetPackage(org.PackageId);
|
rds.CreateCollection(org.OrganizationId, collection);
|
||||||
|
|
||||||
var tenant = UserController.GetUser(package.UserId);
|
|
||||||
|
|
||||||
rds.CreateCollection(org.OrganizationId, tenant.Username, collection);
|
|
||||||
|
|
||||||
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description);
|
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description);
|
||||||
|
|
||||||
|
@ -324,11 +320,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
|
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
|
||||||
|
|
||||||
var package = PackageController.GetPackage(org.PackageId);
|
rds.RemoveCollection(org.OrganizationId, collection.Name);
|
||||||
|
|
||||||
var tenant = UserController.GetUser(package.UserId);
|
|
||||||
|
|
||||||
rds.RemoveCollection(org.OrganizationId, tenant.Username, collection.Name);
|
|
||||||
|
|
||||||
DataProvider.DeleteRDSCollection(collection.Id);
|
DataProvider.DeleteRDSCollection(collection.Id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IRemoteDesktopServices
|
public interface IRemoteDesktopServices
|
||||||
{
|
{
|
||||||
bool CreateCollection(string organizationId, string tenantName, RdsCollection collection);
|
bool CreateCollection(string organizationId, RdsCollection collection);
|
||||||
RdsCollection GetCollection(string collectionName);
|
RdsCollection GetCollection(string collectionName);
|
||||||
bool RemoveCollection(string organizationId, string tenantName, string collectionName);
|
bool RemoveCollection(string organizationId, string collectionName);
|
||||||
bool SetUsersInCollection(string organizationId, string collectionName, List<string> users);
|
bool SetUsersInCollection(string organizationId, string collectionName, List<string> users);
|
||||||
void AddSessionHostServerToCollection(string organizationId, string collectionName, RdsServer server);
|
void AddSessionHostServerToCollection(string organizationId, string collectionName, RdsServer server);
|
||||||
void AddSessionHostServersToCollection(string organizationId, string collectionName, List<RdsServer> servers);
|
void AddSessionHostServersToCollection(string organizationId, string collectionName, List<RdsServer> servers);
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
private const string Users = "users";
|
private const string Users = "users";
|
||||||
private const string RdsGroupFormat = "rds-{0}-{1}";
|
private const string RdsGroupFormat = "rds-{0}-{1}";
|
||||||
private const string RdsModuleName = "RemoteDesktopServices";
|
private const string RdsModuleName = "RemoteDesktopServices";
|
||||||
private const string AddNpsString = "netsh nps add np name=\"\"{0}\"\" policysource=\"1\" processingorder=\"{1}\" conditionid=\"0x3d\" conditiondata=\"^5$\" conditionid=\"0x1fb5\" conditiondata=\"{2}\" conditionid=\"0x1e\" conditiondata=\"UserAuthType:(PW|CA)\" profileid=\"0x1005\" profiledata=\"TRUE\" profileid=\"0x100f\" profiledata=\"TRUE\" profileid=\"0x1009\" profiledata=\"0x7\" profileid=\"0x1fe6\" profiledata=\"0x40000000\"";
|
private const string AddNpsString = "netsh nps add np name=\"\"{0}\"\" policysource=\"1\" processingorder=\"{1}\" conditionid=\"0x3d\" conditiondata=\"^5$\" conditionid=\"0x1fb5\" conditiondata=\"{2}\" conditionid=\"0x1fb4\" conditiondata=\"{3}\" conditionid=\"0x1e\" conditiondata=\"UserAuthType:(PW|CA)\" profileid=\"0x1005\" profiledata=\"TRUE\" profileid=\"0x100f\" profiledata=\"TRUE\" profileid=\"0x1009\" profiledata=\"0x7\" profileid=\"0x1fe6\" profiledata=\"0x40000000\"";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
@ -139,7 +139,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
|
|
||||||
#region RDS Collections
|
#region RDS Collections
|
||||||
|
|
||||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection)
|
public bool CreateCollection(string organizationId, RdsCollection collection)
|
||||||
{
|
{
|
||||||
var result = true;
|
var result = true;
|
||||||
|
|
||||||
|
@ -194,13 +194,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name));
|
ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
var policyName = GetPolicyName(tenantName, organizationId, collection.Name);
|
var policyName = GetPolicyName(organizationId, collection.Name);
|
||||||
|
|
||||||
foreach (var gateway in Gateways)
|
foreach (var gateway in Gateways)
|
||||||
{
|
{
|
||||||
if (!CentralNps)
|
if (!CentralNps)
|
||||||
{
|
{
|
||||||
CreateRdCapForce(runSpace, gateway, policyName, new List<string> { GetUsersGroupName(collection.Name) });
|
CreateRdCapForce(runSpace, gateway, policyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) });
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateRdRapForce(runSpace, gateway, policyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) });
|
CreateRdRapForce(runSpace, gateway, policyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) });
|
||||||
|
@ -263,7 +263,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName)
|
public bool RemoveCollection(string organizationId, string collectionName)
|
||||||
{
|
{
|
||||||
var result = true;
|
var result = true;
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
|
|
||||||
ExecuteShellCommand(runSpace, cmd, false);
|
ExecuteShellCommand(runSpace, cmd, false);
|
||||||
|
|
||||||
var policyName = GetPolicyName(tenantName, organizationId, collectionName);
|
var policyName = GetPolicyName(organizationId, collectionName);
|
||||||
|
|
||||||
foreach (var gateway in Gateways)
|
foreach (var gateway in Gateways)
|
||||||
{
|
{
|
||||||
|
@ -549,11 +549,15 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
|
|
||||||
var count = showResult.Count(x => Convert.ToString(x).Contains("policy conf")) + 1001;
|
var count = showResult.Count(x => Convert.ToString(x).Contains("policy conf")) + 1001;
|
||||||
|
|
||||||
var groupAd = ActiveDirectoryUtils.GetADObject(GetUsersGroupPath(organizationId, collectionName));
|
var userGroupAd = ActiveDirectoryUtils.GetADObject(GetUsersGroupPath(organizationId, collectionName));
|
||||||
|
|
||||||
var sid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(groupAd, "objectSid");
|
var userGroupSid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(userGroupAd, "objectSid");
|
||||||
|
|
||||||
var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count, ConvertByteToStringSid(sid));
|
var computerGroupAd = ActiveDirectoryUtils.GetADObject(GetComputerGroupPath(organizationId, collectionName));
|
||||||
|
|
||||||
|
var computerGroupSid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(computerGroupAd, "objectSid");
|
||||||
|
|
||||||
|
var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count, ConvertByteToStringSid(userGroupSid), ConvertByteToStringSid(computerGroupSid));
|
||||||
|
|
||||||
Command addCmd = new Command(addCmdString);
|
Command addCmd = new Command(addCmdString);
|
||||||
|
|
||||||
|
@ -567,7 +571,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
var removeResult = ExecuteRemoteShellCommand(runSpace, centralNpshost, removeCmd);
|
var removeResult = ExecuteRemoteShellCommand(runSpace, centralNpshost, removeCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void CreateRdCapForce(Runspace runSpace, string gatewayHost, string policyName, List<string> groups)
|
internal void CreateRdCapForce(Runspace runSpace, string gatewayHost, string policyName, string collectionName, List<string> groups)
|
||||||
{
|
{
|
||||||
//New-Item -Path "RDS:\GatewayServer\CAP" -Name "Allow Admins" -UserGroups "Administrators@." -AuthMethod 1
|
//New-Item -Path "RDS:\GatewayServer\CAP" -Name "Allow Admins" -UserGroups "Administrators@." -AuthMethod 1
|
||||||
//Set-Item -Path "RDS:\GatewayServer\CAP\Allow Admins\SessionTimeout" -Value 480 -SessionTimeoutAction 0
|
//Set-Item -Path "RDS:\GatewayServer\CAP\Allow Admins\SessionTimeout" -Value 480 -SessionTimeoutAction 0
|
||||||
|
@ -578,11 +582,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
}
|
}
|
||||||
|
|
||||||
var userGroupParametr = string.Format("@({0})",string.Join(",", groups.Select(x => string.Format("\"{0}@{1}\"", x, RootDomain)).ToArray()));
|
var userGroupParametr = string.Format("@({0})",string.Join(",", groups.Select(x => string.Format("\"{0}@{1}\"", x, RootDomain)).ToArray()));
|
||||||
|
var computerGroupParameter = string.Format("\"{0}@{1}\"", GetComputersGroupName(collectionName), RootDomain);
|
||||||
|
|
||||||
Command rdCapCommand = new Command("New-Item");
|
Command rdCapCommand = new Command("New-Item");
|
||||||
rdCapCommand.Parameters.Add("Path", string.Format("\"{0}\"", CapPath));
|
rdCapCommand.Parameters.Add("Path", string.Format("\"{0}\"", CapPath));
|
||||||
rdCapCommand.Parameters.Add("Name", string.Format("\"{0}\"", policyName));
|
rdCapCommand.Parameters.Add("Name", string.Format("\"{0}\"", policyName));
|
||||||
rdCapCommand.Parameters.Add("UserGroups", userGroupParametr);
|
rdCapCommand.Parameters.Add("UserGroups", userGroupParametr);
|
||||||
|
rdCapCommand.Parameters.Add("ComputerGroups", computerGroupParameter);
|
||||||
rdCapCommand.Parameters.Add("AuthMethod", 1);
|
rdCapCommand.Parameters.Add("AuthMethod", 1);
|
||||||
|
|
||||||
ExecuteRemoteShellCommand(runSpace, gatewayHost, rdCapCommand, RdsModuleName);
|
ExecuteRemoteShellCommand(runSpace, gatewayHost, rdCapCommand, RdsModuleName);
|
||||||
|
@ -930,9 +936,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
||||||
ExecuteRemoteShellCommand(runSpace, hostname, rdRapCommand, imports);
|
ExecuteRemoteShellCommand(runSpace, hostname, rdRapCommand, imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPolicyName(string tenantName,string organizationId, string collectionName)
|
private string GetPolicyName(string organizationId, string collectionName)
|
||||||
{
|
{
|
||||||
return string.Format("{0}-{1}-{2}", tenantName, organizationId, collectionName);
|
return string.Format("rds-{0}-{1}", organizationId, collectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetComputersGroupName(string collectionName)
|
private string GetComputersGroupName(string collectionName)
|
||||||
|
|
|
@ -117,19 +117,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection) {
|
public bool CreateCollection(string organizationId, RdsCollection collection) {
|
||||||
object[] results = this.Invoke("CreateCollection", new object[] {
|
object[] results = this.Invoke("CreateCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collection});
|
collection});
|
||||||
return ((bool)(results[0]));
|
return ((bool)(results[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public System.IAsyncResult BeginCreateCollection(string organizationId, string tenantName, RdsCollection collection, System.AsyncCallback callback, object asyncState) {
|
public System.IAsyncResult BeginCreateCollection(string organizationId, RdsCollection collection, System.AsyncCallback callback, object asyncState) {
|
||||||
return this.BeginInvoke("CreateCollection", new object[] {
|
return this.BeginInvoke("CreateCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collection}, callback, asyncState);
|
collection}, callback, asyncState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,18 +138,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public void CreateCollectionAsync(string organizationId, string tenantName, RdsCollection collection) {
|
public void CreateCollectionAsync(string organizationId, RdsCollection collection) {
|
||||||
this.CreateCollectionAsync(organizationId, tenantName, collection, null);
|
this.CreateCollectionAsync(organizationId, collection, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public void CreateCollectionAsync(string organizationId, string tenantName, RdsCollection collection, object userState) {
|
public void CreateCollectionAsync(string organizationId, RdsCollection collection, object userState) {
|
||||||
if ((this.CreateCollectionOperationCompleted == null)) {
|
if ((this.CreateCollectionOperationCompleted == null)) {
|
||||||
this.CreateCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCollectionOperationCompleted);
|
this.CreateCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCollectionOperationCompleted);
|
||||||
}
|
}
|
||||||
this.InvokeAsync("CreateCollection", new object[] {
|
this.InvokeAsync("CreateCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collection}, this.CreateCollectionOperationCompleted, userState);
|
collection}, this.CreateCollectionOperationCompleted, userState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,19 +204,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RemoveCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RemoveCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName) {
|
public bool RemoveCollection(string organizationId, string collectionName) {
|
||||||
object[] results = this.Invoke("RemoveCollection", new object[] {
|
object[] results = this.Invoke("RemoveCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collectionName});
|
collectionName});
|
||||||
return ((bool)(results[0]));
|
return ((bool)(results[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public System.IAsyncResult BeginRemoveCollection(string organizationId, string tenantName, string collectionName, System.AsyncCallback callback, object asyncState) {
|
public System.IAsyncResult BeginRemoveCollection(string organizationId, string collectionName, System.AsyncCallback callback, object asyncState) {
|
||||||
return this.BeginInvoke("RemoveCollection", new object[] {
|
return this.BeginInvoke("RemoveCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collectionName}, callback, asyncState);
|
collectionName}, callback, asyncState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,18 +225,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public void RemoveCollectionAsync(string organizationId, string tenantName, string collectionName) {
|
public void RemoveCollectionAsync(string organizationId, string collectionName) {
|
||||||
this.RemoveCollectionAsync(organizationId, tenantName, collectionName, null);
|
this.RemoveCollectionAsync(organizationId, collectionName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public void RemoveCollectionAsync(string organizationId, string tenantName, string collectionName, object userState) {
|
public void RemoveCollectionAsync(string organizationId, string collectionName, object userState) {
|
||||||
if ((this.RemoveCollectionOperationCompleted == null)) {
|
if ((this.RemoveCollectionOperationCompleted == null)) {
|
||||||
this.RemoveCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveCollectionOperationCompleted);
|
this.RemoveCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveCollectionOperationCompleted);
|
||||||
}
|
}
|
||||||
this.InvokeAsync("RemoveCollection", new object[] {
|
this.InvokeAsync("RemoveCollection", new object[] {
|
||||||
organizationId,
|
organizationId,
|
||||||
tenantName,
|
|
||||||
collectionName}, this.RemoveCollectionOperationCompleted, userState);
|
collectionName}, this.RemoveCollectionOperationCompleted, userState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,12 @@ namespace WebsitePanel.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
[WebMethod, SoapHeader("settings")]
|
[WebMethod, SoapHeader("settings")]
|
||||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection)
|
public bool CreateCollection(string organizationId, RdsCollection collection)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.WriteStart("'{0}' CreateCollection", ProviderSettings.ProviderName);
|
Log.WriteStart("'{0}' CreateCollection", ProviderSettings.ProviderName);
|
||||||
var result = RDSProvider.CreateCollection(organizationId, tenantName, collection);
|
var result = RDSProvider.CreateCollection(organizationId, collection);
|
||||||
Log.WriteEnd("'{0}' CreateCollection", ProviderSettings.ProviderName);
|
Log.WriteEnd("'{0}' CreateCollection", ProviderSettings.ProviderName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -94,12 +94,12 @@ namespace WebsitePanel.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
[WebMethod, SoapHeader("settings")]
|
[WebMethod, SoapHeader("settings")]
|
||||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName)
|
public bool RemoveCollection(string organizationId, string collectionName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.WriteStart("'{0}' RemoveCollection", ProviderSettings.ProviderName);
|
Log.WriteStart("'{0}' RemoveCollection", ProviderSettings.ProviderName);
|
||||||
var result = RDSProvider.RemoveCollection(organizationId, tenantName, collectionName);
|
var result = RDSProvider.RemoveCollection(organizationId, collectionName);
|
||||||
Log.WriteEnd("'{0}' RemoveCollection", ProviderSettings.ProviderName);
|
Log.WriteEnd("'{0}' RemoveCollection", ProviderSettings.ProviderName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue