通过 System.DirectoryServices 管理终端用户
- 作者: 找个陈美嘉那样的女人
- 来源: 51数据库
- 2022-10-28
问题描述
我有一个环境,我需要经常将参数更改为用户登录到终端服务器时启动的程序.现在,我们打开计算机管理管理单元并为用户编辑环境选项卡,并在登录时启动以下程序:"下手动更改参数.我想自动化这个过程.
I have a environment where I need to frequently change the parameters to a program that is launched when a user logs in to the terminal server. As of right now we open the computer management snap-in and edit the environment tab for the user and change the parameters by hand under "Start the following program at logon:". I would like to automate the process.
我一直在研究 System.DirectoryServices 和 System.DirectoryServices.AccountManagement,并尽我所能阅读它.到目前为止,我最好的猜测是我需要编辑的信息存储在参数"属性中(最坏的属性名称,废墟谷歌搜索).这个猜测的原因是当我列出我得到的所有属性
I have been looking in to System.DirectoryServices and System.DirectoryServices.AccountManagement and reading all I can about it. So far my best guess is that the information I need to edit is stored in the "Parameters" Properties (worst name possible for a property, ruins googling). The reason for that guess is when I list all of the Properties I get
(...) Name: HomeDirDrive Value: Name: Parameters Value: P?CtxCfgPresent?????CtxCf gFlags1?????CtxShadow????*??CtxMinEncryptionLevel? @?CtxWorkDirectory??????????? ?????????????????????"C?CtxInitialProgram??????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????? ??????????????? Name: PrimaryGroupID Value: 513 (...)
CtxInitialProgram 和 CtxWorkDirectory 似乎与我的工作相关.
CtxInitialProgram and CtxWorkDirectory seem relevant to what I am working with.
现在我陷入困境,因为我不知道如何正确读取和写入值,或找不到资源来帮助我正确读取和写入值.
Now I am stuck as I can not figure out how to, or find and resources to help me out, reading and writing the values correctly.
任何帮助将不胜感激.
编辑——我在互联网上的其他地方找到了这个答案在互联网上的其他地方询问我找到了答案:
EDIT -- I found this answer elsewhere on the internet Asking elsewhere on the internet I found the answer:
不幸的是,这些数据是以专有格式编码的.唯一支持的以编程方式管理它的方法是使用终端服务附带的 IADsTSUserEx ADSI 接口.您基本上只是将 NativeObject 属性强制转换到此 COM 接口(在创建所需的 COM 引用之后),然后访问该接口公开的属性.
Unfortunately this data is encoded in a proprietary format. The only supported way to manage it programmatically is by using the IADsTSUserEx ADSI interface that comes with terminal services. You basically just cast the NativeObject property to this COM interface (after creating the required COM reference) and then access the properties exposed by the interface.
现在我的问题是如何设置那个 COM 引用,我以前从未做过这样的事情.
Now my question is how do I set up that COM reference, I have never done anything like that before.
推荐答案
在互联网上的其他地方询问我找到了答案:
Asking elsewhere on the internet I found the answer:
不幸的是,这些数据是以专有格式编码的.唯一支持的以编程方式管理它的方法是使用终端服务附带的 IADsTSUserEx ADSI 接口.您基本上只是将 NativeObject 属性强制转换到此 COM 接口(在创建所需的 COM 引用之后),然后访问该接口公开的属性.
Unfortunately this data is encoded in a proprietary format. The only supported way to manage it programmatically is by using the IADsTSUserEx ADSI interface that comes with terminal services. You basically just cast the NativeObject property to this COM interface (after creating the required COM reference) and then access the properties exposed by the interface.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
