public override string GetResourceRelativeUrl(RoleAssignment model)
        {
            var scope = new ManagementObjectScope()
            {
                AppGroupName = model.AppGroupName, HostPoolName = model.HostPoolName, TenantName = model.TenantName, TenantGroupName = model.TenantGroupName
            };
            var relativeUrlBuilder = new StringBuilder($"{scope.AsUrlPath().TrimStart('/')}/Rds.Authorization/roleAssignments/{model.RoleDefinitionName}/Users/");

            if (string.IsNullOrEmpty(model.SignInName) == false)
            {
                relativeUrlBuilder.Append($"UPN/{model.SignInName}/");
            }
            else
            {
                relativeUrlBuilder.Append($"appid/{model.AppId}/");
            }
            return(relativeUrlBuilder.ToString());
        }
Exemple #2
0
        private static ManagementObjectScope FromUrlPath(string scope)
        {
            ManagementObjectScope rdMgmtObjectScope = new ManagementObjectScope();

            if (string.IsNullOrWhiteSpace(scope))
            {
                return(rdMgmtObjectScope);
            }
            string[] s = scope.Split('/');
            if (s.Length <= 2 && !string.IsNullOrWhiteSpace(s[0]) && !string.IsNullOrWhiteSpace(s[0]))
            {
                throw new ArgumentException("Invalid scope format in RdMgmtObjectScope '" + scope + "'");
            }
            rdMgmtObjectScope.TenantGroupName = rdMgmtObjectScope.GetObjectName(s, ManagementObjectScope.Type.TenantGroup, scope);
            rdMgmtObjectScope.TenantName      = rdMgmtObjectScope.GetObjectName(s, ManagementObjectScope.Type.Tenant, scope);
            rdMgmtObjectScope.HostPoolName    = rdMgmtObjectScope.GetObjectName(s, ManagementObjectScope.Type.HostPool, scope);
            rdMgmtObjectScope.AppGroupName    = rdMgmtObjectScope.GetObjectName(s, ManagementObjectScope.Type.AppGroup, scope);
            if (s.Length >= 10)
            {
                throw new ArgumentException("Extra scope format in RdMgmtObjectScope '" + scope + "'");
            }
            return(rdMgmtObjectScope);
        }