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 package = PackageController.GetPackage(org.PackageId);
|
||||
|
||||
var tenant = UserController.GetUser(package.UserId);
|
||||
|
||||
rds.CreateCollection(org.OrganizationId, tenant.Username, collection);
|
||||
rds.CreateCollection(org.OrganizationId, collection);
|
||||
|
||||
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description);
|
||||
|
||||
|
@ -324,11 +320,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
|
||||
|
||||
var package = PackageController.GetPackage(org.PackageId);
|
||||
|
||||
var tenant = UserController.GetUser(package.UserId);
|
||||
|
||||
rds.RemoveCollection(org.OrganizationId, tenant.Username, collection.Name);
|
||||
rds.RemoveCollection(org.OrganizationId, collection.Name);
|
||||
|
||||
DataProvider.DeleteRDSCollection(collection.Id);
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
/// </summary>
|
||||
public interface IRemoteDesktopServices
|
||||
{
|
||||
bool CreateCollection(string organizationId, string tenantName, RdsCollection collection);
|
||||
bool CreateCollection(string organizationId, RdsCollection collection);
|
||||
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);
|
||||
void AddSessionHostServerToCollection(string organizationId, string collectionName, RdsServer server);
|
||||
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 RdsGroupFormat = "rds-{0}-{1}";
|
||||
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
|
||||
|
||||
#region Properties
|
||||
|
@ -139,7 +139,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
|
||||
#region RDS Collections
|
||||
|
||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection)
|
||||
public bool CreateCollection(string organizationId, RdsCollection collection)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
|
@ -194,13 +194,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name));
|
||||
}
|
||||
|
||||
var policyName = GetPolicyName(tenantName, organizationId, collection.Name);
|
||||
var policyName = GetPolicyName(organizationId, collection.Name);
|
||||
|
||||
foreach (var gateway in Gateways)
|
||||
{
|
||||
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) });
|
||||
|
@ -263,7 +263,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
return collection;
|
||||
}
|
||||
|
||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName)
|
||||
public bool RemoveCollection(string organizationId, string collectionName)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
|
@ -280,7 +280,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
|
||||
ExecuteShellCommand(runSpace, cmd, false);
|
||||
|
||||
var policyName = GetPolicyName(tenantName, organizationId, collectionName);
|
||||
var policyName = GetPolicyName(organizationId, collectionName);
|
||||
|
||||
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 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);
|
||||
|
||||
|
@ -567,7 +571,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
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
|
||||
//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 computerGroupParameter = string.Format("\"{0}@{1}\"", GetComputersGroupName(collectionName), RootDomain);
|
||||
|
||||
Command rdCapCommand = new Command("New-Item");
|
||||
rdCapCommand.Parameters.Add("Path", string.Format("\"{0}\"", CapPath));
|
||||
rdCapCommand.Parameters.Add("Name", string.Format("\"{0}\"", policyName));
|
||||
rdCapCommand.Parameters.Add("UserGroups", userGroupParametr);
|
||||
rdCapCommand.Parameters.Add("ComputerGroups", computerGroupParameter);
|
||||
rdCapCommand.Parameters.Add("AuthMethod", 1);
|
||||
|
||||
ExecuteRemoteShellCommand(runSpace, gatewayHost, rdCapCommand, RdsModuleName);
|
||||
|
@ -930,9 +936,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
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)
|
||||
|
|
|
@ -117,19 +117,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
|||
/// <remarks/>
|
||||
[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)]
|
||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection) {
|
||||
public bool CreateCollection(string organizationId, RdsCollection collection) {
|
||||
object[] results = this.Invoke("CreateCollection", new object[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collection});
|
||||
return ((bool)(results[0]));
|
||||
}
|
||||
|
||||
/// <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[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collection}, callback, asyncState);
|
||||
}
|
||||
|
||||
|
@ -140,18 +138,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
|||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void CreateCollectionAsync(string organizationId, string tenantName, RdsCollection collection) {
|
||||
this.CreateCollectionAsync(organizationId, tenantName, collection, null);
|
||||
public void CreateCollectionAsync(string organizationId, RdsCollection collection) {
|
||||
this.CreateCollectionAsync(organizationId, collection, null);
|
||||
}
|
||||
|
||||
/// <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)) {
|
||||
this.CreateCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCollectionOperationCompleted);
|
||||
}
|
||||
this.InvokeAsync("CreateCollection", new object[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collection}, this.CreateCollectionOperationCompleted, userState);
|
||||
}
|
||||
|
||||
|
@ -207,19 +204,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
|||
/// <remarks/>
|
||||
[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)]
|
||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName) {
|
||||
public bool RemoveCollection(string organizationId, string collectionName) {
|
||||
object[] results = this.Invoke("RemoveCollection", new object[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collectionName});
|
||||
return ((bool)(results[0]));
|
||||
}
|
||||
|
||||
/// <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[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collectionName}, callback, asyncState);
|
||||
}
|
||||
|
||||
|
@ -230,18 +225,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices {
|
|||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void RemoveCollectionAsync(string organizationId, string tenantName, string collectionName) {
|
||||
this.RemoveCollectionAsync(organizationId, tenantName, collectionName, null);
|
||||
public void RemoveCollectionAsync(string organizationId, string collectionName) {
|
||||
this.RemoveCollectionAsync(organizationId, collectionName, null);
|
||||
}
|
||||
|
||||
/// <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)) {
|
||||
this.RemoveCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveCollectionOperationCompleted);
|
||||
}
|
||||
this.InvokeAsync("RemoveCollection", new object[] {
|
||||
organizationId,
|
||||
tenantName,
|
||||
collectionName}, this.RemoveCollectionOperationCompleted, userState);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ namespace WebsitePanel.Server
|
|||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection)
|
||||
public bool CreateCollection(string organizationId, RdsCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
@ -94,12 +94,12 @@ namespace WebsitePanel.Server
|
|||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public bool RemoveCollection(string organizationId, string tenantName, string collectionName)
|
||||
public bool RemoveCollection(string organizationId, string collectionName)
|
||||
{
|
||||
try
|
||||
{
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue