开发者

Managing terminal users through System.DirectoryServices

开发者 https://www.devze.com 2022-12-15 21:54 出处:网络
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

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.

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 nam开发者_StackOverflow中文版e 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 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.

Any help would be greatly appreciated.

EDIT -- I found this answer elsewhere on the internet Asking elsewhere on the internet I found the answer:

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.

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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消