仅允许 RemoteApp,不允许远程桌面

仅允许 RemoteApp,不允许远程桌面

我发现了以下问题,具有类似的前提,但问题的答案是将问题改述为陈述!

RemoteApp 阻止用户运行远程桌面

如何允许 RemoteApp 但禁止远程桌面?为了允许远程应用程序,我似乎必须将用户添加到“远程桌面用户”组。这样就可以允许远程桌面。

我尝试使用“TS Web Access Computers”组,但这并未授予他们运行 RemoteApp 的权限。

禁用远程桌面但保留 RemoteApp 功能的配置在哪里?

答案1

没有“官方认可”的方法来实现这一点,因为从根本上讲,TS RemoteApp 功能只是利用现有的远程桌面代码。您可以做一些愚蠢的事情,例如使用组策略将用户的 shell 设置为“logoff.exe”,这样如果他们试图访问机器的桌面,他们就会立即被注销。但是,任何使用通用“文件/打开”对话框的应用程序都可用于在服务器桌面上打开命令提示符或其他程序。

您最好确保遵循最小权限原则,并为您的 TS RemoteApp 用户提供运行所需软件所需的最少权限。如果他们最终进入服务器计算机的桌面,其受限权限应可防止他们对服务器计算机进行任何破坏。

答案2

如果您使用 Windows 7 或 Windows 2008 R2,最好在安全设置中使用“应用程序控制策略”,仅允许必要的应用程序或脚本

答案3

我已将桌面锁定为仅供服务器管理员和指定的 AD 组访问。不属于给定 AD 组的用户将收到一条消息,告知他们使用 RDWeb,而不是桌面/标准 mstsc。

  1. 创建一个 vbscript 并将其放在服务器上所有用户都可以读取+执行的文件夹中
  2. 将以下行添加到%windir%\system32\USRLOGON.CMD

    cscript <sourcefolder>\DesktopUserCheck.vbs
    

vbscript 代码(请在下面的<>条目中添加您的个人信息)

'Script created by Tord Bergset, Jan 2014
'This script is called from the file called C:\Windows\System32\USRLOGON.CMD
'The script check if a user logging on to the server desktop is a allowed to do this.
'The string called StrGroupName controls the access group to check for. 
'AD group used for this script = "G WTS Grant Desktop Access"
'---------------------------------------------------------------------------------------

Const strComputer = "."
Const EWX_LOGOFF = 0 

Dim objShell, objWMIService, colProcessList, objNetwork, StrGroupName, strUsername, strUserIsMember, strUserFullName

Set objShell = WScript.CreateObject ("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'userinit.exe'")
Set objNetwork = CreateObject("Wscript.Network")
strUsername = EnvString("username")

' Mention any AD Group Name Here. Also works for Domain Admins, Enterprise Admins etc.
' -------------------------------------------------------------------------------------
StrGroupName = "G WTS Grant Desktop Access"
' -------------------------------------------------------------------------------------

If IsAdmin = 0 Then wscript.Quit

CheckADGroupMembership()

If strUserIsMember = "YES" Then
    ' Do something here if user is a member of the group
    'MsgBox "Is member"
    Wscript.Quit
Else
    ' Do something here if user is NOT a member of the group
    'MsgBox "Is not member" 
    For Each objProcess in colProcessList
        MsgBox "You (" & strUsername & " ) are not allowed to log in to the server desktop." & VBLF & "Please connect through the Remote Desktop Web Page (RDWeb):" & VBLF & VBLF & "<rdweb server address>", vbExclamation + vbSystemModal, strUsername & " - Access Denied !"
        objShell.run "logoff"
        WScript.Quit
    Next    
End If

Wscript.Quit 


' *****************************************************
'This function checks to see if the logged on user has local admin rights
Function IsAdmin()
    With CreateObject("Wscript.Shell")
        IsAdmin = .Run("%comspec% /c OPENFILES > nul", 0, True)
    End With
End Function

' *****************************************************
'This function checks to see if the passed group name contains the current user as a member. Returns True or False
Function IsMember(groupName)
    If IsEmpty(groupListD) then
        Set groupListD = CreateObject("Scripting.Dictionary")
        groupListD.CompareMode = TextCompare
        ADSPath = EnvString("userdomain") & "/" & EnvString("username")
        Set userPath = GetObject("WinNT://" & ADSPath & ",user")
        For Each listGroup in userPath.Groups
            groupListD.Add listGroup.Name, "-"
        Next
    End if
    IsMember = CBool(groupListD.Exists(groupName))
End Function

' *****************************************************
'This function returns a particular environment variable's value.
' for example, if you use EnvString("username"), it would return the value of %username%.
Function EnvString(variable)
    variable = "%" & variable & "%"
    EnvString = objShell.ExpandEnvironmentStrings(variable)
End Function


' *****************************************************
Sub CheckADGroupMembership()
    ' =============================================================
    ' List All Members of a Group; Including Nested Members
    ' =============================================================
    Dim ObjRootDSE, ObjConn, ObjRS, ObjCustom
    Dim StrDomainName, StrGroupName, StrSQL
    Dim StrGroupDN, StrEmptySpace

    strUserIsMember = ""

    Set ObjRootDSE = GetObject("LDAP://RootDSE")
    StrDomainName = Trim(ObjRootDSE.Get("DefaultNamingContext"))
    Set ObjRootDSE = Nothing

    StrSQL = "Select ADsPath From 'LDAP://" & StrDomainName & "' Where ObjectCategory = 'Group' AND Name = '" & StrGroupName & "'"

    Set ObjConn = CreateObject("ADODB.Connection")
    ObjConn.Provider = "ADsDSOObject":  ObjConn.Open "Active Directory Provider"
    Set ObjRS = CreateObject("ADODB.Recordset")
    ObjRS.Open StrSQL, ObjConn
    If ObjRS.EOF Then
        'WScript.Echo VbCrLf & "This Group: " & StrGroupName & " does not exist in Active Directory"
    End If
    If Not ObjRS.EOF Then   
        WScript.Echo vbNullString
        ObjRS.MoveLast: ObjRS.MoveFirst
        'WScript.Echo "Total No of Groups Found: " & ObjRS.RecordCount
        'WScript.Echo "List of Members In " & StrGroupName & " are: " & VbCrLf
        While Not ObjRS.EOF     
            StrGroupDN = Trim(ObjRS.Fields("ADsPath").Value)
            Set ObjCustom = CreateObject("Scripting.Dictionary")
            StrEmptySpace = " "
            GetAllNestedMembers StrGroupDN, StrEmptySpace, ObjCustom
            Set ObjCustom = Nothing
            ObjRS.MoveNext
        Wend
    End If
    ObjRS.Close:    Set ObjRS = Nothing
    ObjConn.Close:  Set ObjConn = Nothing
End Sub

Private Function GetAllNestedMembers (StrGroupADsPath, StrEmptySpace, ObjCustom)
    Dim ObjGroup, ObjMember
    Set ObjGroup = GetObject(StrGroupADsPath)
    For Each ObjMember In ObjGroup.Members      
        'WScript.Echo Trim(ObjMember.CN) & " --- " & Trim(ObjMember.DisplayName) & " (" & Trim(ObjMember.Class) & ")" & " (" & Trim(ObjMember.sAMAccountName) & ")"
        strThisUser = Trim(ObjMember.sAMAccountName)

        If lCase(strUsername) = lCase(strThisUser) Then 
            strUserIsMember = "YES"
            strUserFullName = Trim(ObjMember.DisplayName)
            Exit Function
        End If

        If Strcomp(Trim(ObjMember.Class), "Group", vbTextCompare) = 0 Then
            If ObjCustom.Exists(ObjMember.ADsPath) Then 
                'WScript.Echo StrEmptySpace & " -- Already Checked Group-Member " & "(Stopping Here To Escape Loop)"
            Else
                ObjCustom.Add ObjMember.ADsPath, 1  
                GetFromHere ObjMember.ADsPath, StrEmptySpace & " ", ObjCustom
            End If
        End If
    Next
End Function

Private Sub GetFromHere(StrGroupADsPath, StrEmptySpace, ObjCustom)
    Dim ObjThisGroup, ObjThisMember
    Set ObjThisGroup = GetObject(StrGroupADsPath)
    'WScript.Echo vbNullString
    'WScript.Echo "  ** Members of this Group are:"
    For Each ObjThisMember In ObjThisGroup.Members      
        'WScript.Echo "    >> " & Trim(ObjThisMember.CN) & " --- " & Trim(ObjThisMember.DisplayName) & " (" & Trim(ObjThisMember.Class) & ")" & " (" & Trim(ObjThisMember.sAMAccountName) & ")"
        strThisUser = Trim(ObjThisMember.sAMAccountName)

        If lCase(strUsername) = lCase(strThisUser) Then 
            strUserIsMember = "YES"
            strUserFullName = Trim(ObjThisMember.DisplayName)
            Exit Sub
        End If

    Next
    'WScript.Echo vbNullString
End Sub

答案4

你可以利用完整用户会话启动userinit.exe进程,而 RemoteApp 会话启动rdpshell.exe进程这一事实。AppLocker 可用于禁止userinit.exe标准用户执行。

相关内容