我有一个环境,我需要经常将参数更改为用户登录到终端服务器时启动的程序.现在,我们打开计算机管理管理单元并为用户编辑环境选项卡,并在登录时启动以下程序:"下手动更改参数.我想自动化这个过程.
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.
这篇关于通过 System.DirectoryServices 管理终端用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!