如何使用 VB.Net 检索 Active Directory 环境和会话信息
我希望能够通过 VB.Net 应用程序在“环境”和“会话”选项卡下的 Windows Server 2003 上的 Active Directory 中获取和设置用户的不同信息。我熟悉 System.DirectoryService 但我找不到这些特定选项卡的正确属性。例如,我想检查“登录时连接打印机”或设置“空闲会话限制”。
我找到了“ms-TS-Connect-Printer-Drives Attribute”和其他类似属性,但它们仅在 Server 2008 上实现。旧版本必须有另一种方法。
I'd like to be able to get and set the different information for a user in Active Directory on Windows Server 2003 under Environment and Session tabs through a VB.Net application. I am familiar with System.DirectoryService but I can not find the correct attributes for these particular tabs. For example, I'd like to check "Connect Printer at logon" or set "Idle session limit".
I've found the "ms-TS-Connect-Printer-Drives Attribute" and other attributes like it but they are only implemented on Server 2008. There must be another way for older version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过多次研究后我找到了答案。
在 Windows Server 2003 下,有些信息无法通过 DirectoryServices 获取和设置,尤其是在“会话”、“环境”、“终端服务”等选项卡下
有一个 DLL 可以为您完成此操作:Windows/System32 中的 TSUSEREX.dll。
在您的 Visual Studio 项目中添加对该库的引用,以下是有关如何使用它来获取所需内容的示例:
有一个指向您希望处理的用户的目录条目(dirEntry)。
这会将最大空闲连接时间设置为 10 分钟并自动连接打印机。
I've found the answer after many research.
There is some information you just can't get and set through DirectoryServices under Windows Server 2003, especially under tabs like Session, Environment, Terminal Service, etc
There is a DLL that can do it for you: TSUSEREX.dll found in Windows/System32.
Adding a reference to that library in your visual studio project, here is an example on how to use it to get what you need:
Have a directory entry(dirEntry) pointing on the user you wish to work on.
This will set the max idle connection time to 10 minutes and have the printer connected automatically.