如何使用 VB.Net 检索 Active Directory 环境和会话信息

发布于 2024-09-10 07:32:22 字数 266 浏览 0 评论 0原文

我希望能够通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奈何桥上唱咆哮 2024-09-17 07:32:22

经过多次研究后我找到了答案。

在 Windows Server 2003 下,有些信息无法通过 DirectoryServices 获取和设置,尤其是在“会话”、“环境”、“终端服务”等选项卡下
有一个 DLL 可以为您完成此操作:Windows/System32 中的 TSUSEREX.dll。

在您的 Visual Studio 项目中添加对该库的引用,以下是有关如何使用它来获取所需内容的示例:

有一个指向您希望处理的用户的目录条目(dirEntry)。

Dim oUser As ADsTSUserEx = CType(dirEntryUsr.NativeObject, ADsTSUserEx)
oUser.MaxIdleTime = 10
oUser.ConnectClientPrintersAtLogon = 1

这会将最大空闲连接时间设置为 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.

Dim oUser As ADsTSUserEx = CType(dirEntryUsr.NativeObject, ADsTSUserEx)
oUser.MaxIdleTime = 10
oUser.ConnectClientPrintersAtLogon = 1

This will set the max idle connection time to 10 minutes and have the printer connected automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文