windows 远程桌面研究-程序员宅基地

技术标签: 操作系统  

最近因为一个监控相关的项目,深入研究了一下 windows 的 远程桌面的相关知识。

1. 如何让关闭了远程桌面连接的用户,对应的 session 立即退出 windows server。

大家使用 mstsc.exe 远程桌面登录windows server时,退出时,99.99%的人会直接关闭 mstsc.exe 窗口,而不会点击开始--->退出。导致的问题是,登录用户已经提出了,但是 query user 和 query session 时,发现退出的用户,在 windows server 中还是 Active/运行中 则状态。这样会白白占用一个sesion的资源,可能会导致,别人登录时,报 类似 “超过人数” 的错误。

解决办法:

注册表[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp],修改

MaxDisconnectionTime

将该值改为0x3e8(1000),也就是1000毫秒(也就是1秒),重启系统就ok。

 

Next look to the following key in the registry:

HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\Console

&

HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp 

Look for fInheritresetBroken (make dword 0) 不继承客户端的设置

fInheritReconnectSame (make dword 0) 不继承客户端的设置--连接到以前的同一个session

fReconnectSame (make dword 0) 是否连接到以前的同一个session

fResetBroken (make dword 1)  是否断开连接之后,进行连接的重置,也即使 不使用以前的session,重新初始化一个新的session

If all those values are OK then we'll look at the MaxDisconnectionTime values under the Terminal Server Key. You'll need to expand each subskey and look for these two entries in EVERY key, it exists multiple times

fInheritMaxDisconnectionTime (make this dword 0 to disable Inherit) -- 不继承客户端的设置

&

MaxDisconnectionTime (1000毫秒,也就是在 rdp 连接 端口 1秒 之后,立即将 rdp session 从 windows server中踢掉。)

 

2. 限制一个用户仅仅能够同时连接一次

 监控时,我们要实现,一个用户名,只能同时登录一次,也就是同一个用户名,在windows server中,只能有一个登录会话存在,解决办法:

设置注册表:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\fSingleSessionPerUser  为 1. 启用一个用户只能有一个session的限制。

fSingleSessionPerUser: TRUE indicates each user can have only a single session; FALSE otherwise.

 

3. 限制/放开限制  rdp 连接的总数

默认时,有些版本的系统,最多仅仅只能运行两个 administor 和 一个 console 登录session的存在。

去掉该限制的方法:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\MaxInstanceCount

设置为 ffffffff。对 rdp session 的并发数量不进行限制。

 

MaxInstanceCount

 

Updated: March 28, 2003

 

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

 

 HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services

Description

Stores configuration data for the policy setting Limit number of connections. (限制 rdp 连接的数量

Change Method

To change the value of this entry, use the Group Policy Object Editor (Gpedit.msc). The corresponding policy is located in Administrative Templates\Windows Components\Terminal Services.

 

https://technet.microsoft.com/en-us/library/cc758332(v=ws.10).aspx

 

相关参考资料:

1)http://remotedesktoprdp.com/force-single-session-allow-multiple-sessions-per-user 

Force a single session or allow multiple Remote Desktop sessions per user

Remote Desktop/Terminal Services has two settings for multiple sessions. You can either allow multiple sessions per user (in which case if you log in twice, you'll get two sessions), or force a single session per user (in which case you can only log in once and subsequent sessions will be redirectedto the original session.

To change this setting, you'll need to perform a registry change. The following steps describe the process:

    1. Start Registry Editor (by default, this is located at c:\windows\regedit.exe).
    2. Go to the following registry key:

      HKEY_LOCAL_MACHINE\
          System\CurrentControlSet\Control\TerminalServer

    3. If the fSingleSessionPerUser value doesn't exist, create a new DWORD value named fSingleSessionPerUser
    4. Open the fSingleSessionPerUser value. The possible values for this setting are as follows:
      0x0
      Allow multiple sessions per user
      0x1
      Force each user to a single session
    5. Enter the new setting, and then click OK.

 

2)

 

For a specific terminal server session, USERCONFIG indicates the user and session configuration.

 typedef struct _USERCONFIG {
   ULONG fInheritAutoLogon  :1;
   ULONG fInheritResetBroken  :1;
   ULONG fInheritReconnectSame  :1;
   ULONG fInheritInitialProgram  :1;
   ULONG fInheritCallback  :1;
   ULONG fInheritCallbackNumber  :1;
   ULONG fInheritShadow  :1;
   ULONG fInheritMaxSessionTime  :1;
   ULONG fInheritMaxDisconnectionTime  :1;
   ULONG fInheritMaxIdleTime  :1;
   ULONG fInheritAutoClient  :1;
   ULONG fInheritSecurity  :1;
   ULONG fPromptForPassword  :1;
   ULONG fResetBroken  :1;
   ULONG fReconnectSame  :1;
   ULONG fLogonDisabled  :1;
   ULONG fWallPaperDisabled  :1;
   ULONG fAutoClientDrives  :1;
   ULONG fAutoClientLpts  :1;
   ULONG fForceClientLptDef  :1;
   ULONG fRequireEncryption  :1;
   ULONG fDisableEncryption  :1;
   ULONG fUnused1  :1;
   ULONG fHomeDirectoryMapRoot  :1;
   ULONG fUseDefaultGina  :1;
   ULONG fCursorBlinkDisabled  :1;
   ULONG fPublishedApp  :1;
   ULONG fHideTitleBar  :1;
   ULONG fMaximize  :1;
   ULONG fDisableCpm  :1;
   ULONG fDisableCdm  :1;
   ULONG fDisableCcm  :1;
   ULONG fDisableLPT  :1;
   ULONG fDisableClip  :1;
   ULONG fDisableExe  :1;
   ULONG fDisableCam  :1;
   ULONG fDisableAutoReconnect  :1;
   ULONG ColorDepth  :3;
   ULONG fInheritColorDepth  :1;
   ULONG fErrorInvalidProfile  :1;
   ULONG fPasswordIsScPin  :1;
   ULONG fDisablePNPRedir  :1;
   WCHAR UserName[USERNAME_LENGTH + 1];
   WCHAR Domain[DOMAIN_LENGTH + 1];
   WCHAR Password[PASSWORD_LENGTH + 1];
   WCHAR WorkDirectory[DIRECTORY_LENGTH + 1];
   WCHAR InitialProgram[INITIALPROGRAM_LENGTH + 1];
   WCHAR CallbackNumber[CALLBACK_LENGTH + 1];
   CALLBACKCLASS Callback;
   SHADOWCLASS Shadow;
   ULONG MaxConnectionTime;
   ULONG MaxDisconnectionTime;
   ULONG MaxIdleTime;
   ULONG KeyboardLayout;
   BYTE MinEncryptionLevel;
   WCHAR NWLogonServer[NASIFILESERVER_LENGTH + 1];
   APPLICATIONNAME PublishedName;
   WCHAR WFProfilePath[DIRECTORY_LENGTH + 1];
   WCHAR WFHomeDir[DIRECTORY_LENGTH + 1];
   WCHAR WFHomeDirDrive[4];
 } USERCONFIG,
  *PUSERCONFIG;

fInheritAutoLogon: The prompt for the password setting. TRUE indicates the use of client-specified autologon settings, FALSE specifies the use of machine autologon settings.

fInheritResetBroken: Reset the session when the connection is broken. TRUE indicates the value to use for fResetBroken from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritReconnectSame: Reconnect from the same client setting. TRUE indicates the value to use for fReconnectSame from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritInitialProgram: The initial program setting. TRUE indicates the value to use for InitialProgram from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritCallback: The callback setting. TRUE indicates the value to use for Callback from the user properties if the machine/user policy is not set, FALSE otherwise.<63>

fInheritCallbackNumber: The callback number setting. TRUE indicates the value to use for CallbackNumber from the user properties if the machine/user policy is not set, FALSE otherwise.<64>

fInheritShadow: The shadow setting. TRUE indicates the value to use for Shadow from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritMaxSessionTime: The maximum allowed session connection time setting. TRUE indicates the value to use for MaxSessionTime from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritMaxDisconnectionTime: The maximum allowed session disconnect time setting. TRUE indicates the value to use for MaxDisconnectionTime from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritMaxIdleTime: The maximum allowed session idle time. TRUE indicates the value to use for MaxIdleTime from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritAutoClient: The auto client setting. TRUE indicates the value to use for fAutoClientDrivers and fAutoClientLpts from the user properties if the machine/user policy is not set, FALSE otherwise.

fInheritSecurity: Inherit security setting. TRUE indicates the use of security settings from the user properties if the machine/user policy is not set, FALSE otherwise.

fPromptForPassword: Set to TRUE to ignore the credential sent from the client and always prompt for a passwordFALSE otherwise.

fResetBroken: Set to TRUE to log off the session when the idle timers for the session expire. Otherwise, the session will be disconnected when the timer expires.

fReconnectSame: FALSE indicates that the user can reconnect from any client computer to a disconnected session.

TRUE indicates that the user must reconnect to a disconnected session from the same client computer that initially established the disconnected session. Logging on from a different client computer will lead to a new terminal server session being created.

fLogonDisabled: TRUE indicates that a user cannot log on to a session remotely, FALSE otherwise.<65>

fWallPaperDisabled: TRUE indicates display of the desktop wallpaper in the session has been disabled, FALSE otherwise.

fAutoClientDrives: TRUE specifies to automatically redirect local drives on the client so they are accessible to the user in the remote terminal server session, FALSE otherwise.

fAutoClientLpts: TRUE specifies to automatically redirect printers on the client so they are accessible to the user in the remote terminal server session, FALSE otherwise.

fForceClientLptDef: TRUE indicates to force the client's redirected printer to be the default printer for the user, FALSE otherwise.

fRequireEncryption: TRUE indicates the connection must be encrypted, FALSE otherwise.

fDisableEncryption: TRUE indicates the connection does not need encryption, FALSE otherwise.

fUnused1: Not used.

fHomeDirectoryMapRoot: Not used.

fUseDefaultGina: TRUE indicates to override a third-party GINA so that only the default GINA is used for the terminal server session, FALSE otherwise.<66>

fCursorBlinkDisabled: TRUE indicates disable the blinking of the mouse cursor, FALSE otherwise.<67>

fPublishedApp: Not used.

fHideTitleBar: Not used.

fMaximize: Not used.

fDisableCpm: TRUE indicates disable client printer redirection, FALSE otherwise.

fDisableCdm: TRUE indicates disable client drive redirection, FALSE otherwise.

fDisableCcm: TRUE indicates disable client COM port redirection, FALSE otherwise.

fDisableLPT: TRUE indicates disable client printer (LPT) port redirection, FALSE otherwise.

fDisableClip: TRUE indicates disable client clipboard redirection, FALSE otherwise.

fDisableExe: TRUE indicates disable .exe file execution, FALSE otherwise.

fDisableCam: TRUE indicates disable client audio redirection, FALSE otherwise.

fDisableAutoReconnect: TRUE indicates disable auto-reconnect functionality, FALSE otherwise.<68>

ColorDepth: The color depth of the session.<69>

fInheritColorDepth: Set to TRUE to inherit color depth from the user or client configuration, FALSE otherwise.<70>

fErrorInvalidProfile: Set to TRUE if WFProfilePath, WFHomeDir, or WFHomeDirDrive is invalid (too long), FALSE otherwise.<71>

fPasswordIsScPin: Set to TRUE if the password field contains a smart card PIN.<72>

fDisablePNPRedir: Set to TRUE if Plug and Play (PnP) redirection is disabled, FALSE otherwise.

UserName: The user name used in autologon scenarios.

Domain: The domain name used in autologon scenarios.

Password: The password used in autologon scenarios.

WorkDirectory: The work directory for the initial program.

InitialProgram: The program to run instead of the default.<73>

CallbackNumber: The telephone number that will be returned by the Terminal Services server to the client when the server is unable to complete the connection request from the client. The user on the client side can use this number to call back for technical support.<74>

Callback: The callback class for callback operations.<75>

Shadow: The shadow setting of the session.

MaxConnectionTime: The maximum allowed session connection time setting of the session in milliseconds. The session will disconnect/logoff once the limit is reached.

MaxDisconnectionTimeThe maximum allowed session disconnect time of the session in milliseconds(千分之一秒)The session will logoff once the limit is reached.

MaxIdleTime: The maximum allowed session idle time setting of the session in milliseconds. The session will disconnect/logoff once the limit is reached.(10分钟)

KeyboardLayout: The keyboard layout (HKL) of the session.

MinEncryptionLevel: The minimum allowed encryption level. Possible numeric values for this parameter include 1 (Low), 2 (Client Compatible), 3 (High), and 4 (FIPS). Detailed description of these encryption levels is included in [MS-RDPBCGR] sections 5.3.1 and 5.4.1.

NWLogonServer: The NetWare logon server name.<76>

PublishedName: Not used.

WFProfilePath: The terminal server profile path. Overrides the standard profile path.

WFHomeDir: The terminal server home directory path. Overrides the standard home directory.

WFHomeDirDrive: The terminal server home directory drive. Overrides the standard home directory.

3)https://msdn.microsoft.com/en-us/library/cc248657.aspx

 

后记:随便一个 google 相关资料还是很多的,也很权威。没有了google,或者英语阅读能力不太好,会产生很大的障碍。

     

 

 

转载于:https://www.cnblogs.com/digdeep/p/5316665.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30878361/article/details/96708498

智能推荐

c# 调用c++ lib静态库_c#调用lib-程序员宅基地

文章浏览阅读2w次,点赞7次,收藏51次。四个步骤1.创建C++ Win32项目动态库dll 2.在Win32项目动态库中添加 外部依赖项 lib头文件和lib库3.导出C接口4.c#调用c++动态库开始你的表演...①创建一个空白的解决方案,在解决方案中添加 Visual C++ , Win32 项目空白解决方案的创建:添加Visual C++ , Win32 项目这......_c#调用lib

deepin/ubuntu安装苹方字体-程序员宅基地

文章浏览阅读4.6k次。苹方字体是苹果系统上的黑体,挺好看的。注重颜值的网站都会使用,例如知乎:font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, W..._ubuntu pingfang

html表单常见操作汇总_html表单的处理程序有那些-程序员宅基地

文章浏览阅读159次。表单表单概述表单标签表单域按钮控件demo表单标签表单标签基本语法结构<form action="处理数据程序的url地址“ method=”get|post“ name="表单名称”></form><!--action,当提交表单时,向何处发送表单中的数据,地址可以是相对地址也可以是绝对地址--><!--method将表单中的数据传送给服务器处理,get方式直接显示在url地址中,数据可以被缓存,且长度有限制;而post方式数据隐藏传输,_html表单的处理程序有那些

PHP设置谷歌验证器(Google Authenticator)实现操作二步验证_php otp 验证器-程序员宅基地

文章浏览阅读1.2k次。使用说明:开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码。实现Google Authenticator功能需要服务器端和客户端的支持。服务器端负责密钥的生成、验证一次性密码是否正确。客户端记录密钥后生成一次性密码。下载谷歌验证类库文件放到项目合适位置(我这边放在项目Vender下面)https://github.com/PHPGangsta/GoogleAuthenticatorPHP代码示例://引入谷_php otp 验证器

【Python】matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距-程序员宅基地

文章浏览阅读4.3k次,点赞5次,收藏11次。matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距

docker — 容器存储_docker 保存容器-程序员宅基地

文章浏览阅读2.2k次。①Storage driver 处理各镜像层及容器层的处理细节,实现了多层数据的堆叠,为用户 提供了多层数据合并后的统一视图②所有 Storage driver 都使用可堆叠图像层和写时复制(CoW)策略③docker info 命令可查看当系统上的 storage driver主要用于测试目的,不建议用于生成环境。_docker 保存容器

随便推点

网络拓扑结构_网络拓扑csdn-程序员宅基地

文章浏览阅读834次,点赞27次,收藏13次。网络拓扑结构是指计算机网络中各组件(如计算机、服务器、打印机、路由器、交换机等设备)及其连接线路在物理布局或逻辑构型上的排列形式。这种布局不仅描述了设备间的实际物理连接方式,也决定了数据在网络中流动的路径和方式。不同的网络拓扑结构影响着网络的性能、可靠性、可扩展性及管理维护的难易程度。_网络拓扑csdn

JS重写Date函数,兼容IOS系统_date.prototype 将所有 ios-程序员宅基地

文章浏览阅读1.8k次,点赞5次,收藏8次。IOS系统Date的坑要创建一个指定时间的new Date对象时,通常的做法是:new Date("2020-09-21 11:11:00")这行代码在 PC 端和安卓端都是正常的,而在 iOS 端则会提示 Invalid Date 无效日期。在IOS年月日中间的横岗许换成斜杠,也就是new Date("2020/09/21 11:11:00")通常为了兼容IOS的这个坑,需要做一些额外的特殊处理,笔者在开发的时候经常会忘了兼容IOS系统。所以就想试着重写Date函数,一劳永逸,避免每次ne_date.prototype 将所有 ios

如何将EXCEL表导入plsql数据库中-程序员宅基地

文章浏览阅读5.3k次。方法一:用PLSQL Developer工具。 1 在PLSQL Developer的sql window里输入select * from test for update; 2 按F8执行 3 打开锁, 再按一下加号. 鼠标点到第一列的列头,使全列成选中状态,然后粘贴,最后commit提交即可。(前提..._excel导入pl/sql

Git常用命令速查手册-程序员宅基地

文章浏览阅读83次。Git常用命令速查手册1、初始化仓库git init2、将文件添加到仓库git add 文件名 # 将工作区的某个文件添加到暂存区 git add -u # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,不处理untracked的文件git add -A # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,包括untracked的文件...

分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120-程序员宅基地

文章浏览阅读202次。分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120

【C++缺省函数】 空类默认产生的6个类成员函数_空类默认产生哪些类成员函数-程序员宅基地

文章浏览阅读1.8k次。版权声明:转载请注明出处 http://blog.csdn.net/irean_lau。目录(?)[+]1、缺省构造函数。2、缺省拷贝构造函数。3、 缺省析构函数。4、缺省赋值运算符。5、缺省取址运算符。6、 缺省取址运算符 const。[cpp] view plain copy_空类默认产生哪些类成员函数

推荐文章

热门文章

相关标签