如何从 userParameters 属性获取 Active Directory 中的终端服务属性值 [英] How to get terminal services property values in Active Directory from userParameters attribute

查看:19
本文介绍了如何从 userParameters 属性获取 Active Directory 中的终端服务属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 dirsync 来获取在 Active Directory 中已更改的属性值(更改日志).以下链接解释了如何使用 dirsync 获取属性值:

'http:///blogs.technet.com/b/isrpfeplat/archive/2010/09/20/using-the-dirsync-control.aspx'

我正在更改用户远程桌面服务配置文件下的本地路径属性.我运行了一个客户端,它使用 dirsync 来获取 AD 中更改的对象.在客户端,更改的属性是 userParameters 并且值是加密形式的.

CtxCfgPresent P☺CtxCfgPresent????☻☺CtxWFProfilePath?↑→☺CtxWFHomeDir?????????????"☻☺CtxWFHomeDirDrive?☺CtxShadow????☺CtxMaxDisconnectionTime????☺CtxMaxConnectionTime????☺CtxMaxIdleTime????☻☺CtxWorkDirectory?☺CtxCfgFlags1????"☻☺CtxInitialProgram?

有没有办法从 userParameters 中获取实际值.

解决方案

方法一:自己解析:)

信息的结构在 [MS-TSTS] 规范中描述:

http://msdn.microsoft.com/en-us/library/ff635189.aspx

方法二:IADsTSUserEx接口

例如,在 C# 中:

DirectoryEntry userEntry = new DirectoryEntry("LDAP://domain.com/CN=user1,CN=Users,DC=domain,DC=com", "user", "pwd")IADsTSUserEx tsUser = userEntry.NativeObject 作为 IADsTSUserEx;

IADsTSUserEx 的定义是这样的:
(我只需要阅读我的项目中的信息,所以只有getter没有setter)

<预><代码>[进口,接口类型(ComInterfaceType.InterfaceIsIDispatch),Guid("C4930E79-2989-4462-8A60-2FCF2F2955EF")]专用接口 IADsTSUserEx{字符串 TerminalServicesProfilePath { get;}字符串 TerminalServicesHomeDirectory { get;}字符串 TerminalServicesHomeDrive { get;}bool AllowLogon { 获取;}长 EnableRemoteControl { 获取;}长 MaxDisconnectionTime { 获取;}长 MaxConnectionTime { 获取;}长 MaxIdleTime { 得到;}int ReconnectionAction { 获取;}int BrokenConnectionAction { 获取;}bool ConnectClientDrivesAtLogon { get;}bool ConnectClientPrintersAtLogon { get;}bool DefaultToMainPrinter { get;}字符串 TerminalServicesWorkDirectory { get;}字符串 TerminalServicesInitialProgram { get;}}

您也可以使用其他脚本语言,它会比 C# 更简单.

vbscript:

http://www.wisesoft.co.uk/scripts/vbscript_read-write_terminal_services_settings.aspx

PowerShell:

http://blogs.technet.com/b/heyscriptingguy/archive/2008/10/23/how-can-i-edit-terminal-server-profiles-for-users-in-active-directory.aspx

I am using dirsync to get the attributes value that have changed in Active Directory(changelog). The following link explains how the dirsync is used to get attribute values :

'http://blogs.technet.com/b/isrpfeplat/archive/2010/09/20/using-the-dirsync-control.aspx'

I am changing the attribute Local path under Remote Desktop Services Profile of a user. I have ran a client which uses dirsync to get the changed objects in AD. In the client the attribute that is changed is userParameters and the value is in encrypted form.

CtxCfgPresent                                   P☺CtxCfgPresent???? ☻☺CtxWFProfi
lePath?↑→☺CtxWFHomeDir?????????????"☻☺CtxWFHomeDirDrive?☺CtxShadow????☺CtxMaxDis
connectionTime????☺CtxMaxConnectionTime????☺CtxMaxIdleTime???? ☻☺CtxWorkDirector
y?☺CtxCfgFlags1????"☻☺CtxInitialProgram?

Is there a way to get the actual value form the userParameters.

解决方案

Method 1: Parse yourself :)

Structure of the info is described in the [MS-TSTS] spec:

http://msdn.microsoft.com/en-us/library/ff635189.aspx

Method 2: IADsTSUserEx interface

For example, in C#:

DirectoryEntry userEntry = new DirectoryEntry("LDAP://domain.com/CN=user1,CN=Users,DC=domain,DC=com", "user", "pwd")
IADsTSUserEx tsUser = userEntry.NativeObject as IADsTSUserEx;

Definition of IADsTSUserEx is something like this:
(I only need to read the info in my project, so only have the getter but no setter)

[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
Guid("C4930E79-2989-4462-8A60-2FCF2F2955EF")
]
private interface IADsTSUserEx
{
    string TerminalServicesProfilePath { get;}
    string TerminalServicesHomeDirectory { get;}
    string TerminalServicesHomeDrive { get;}
    bool AllowLogon { get;}
    long EnableRemoteControl { get;}
    long MaxDisconnectionTime { get;}
    long MaxConnectionTime { get;}
    long MaxIdleTime { get;}
    int ReconnectionAction { get;}
    int BrokenConnectionAction { get;}
    bool ConnectClientDrivesAtLogon { get;}
    bool ConnectClientPrintersAtLogon { get;}
    bool DefaultToMainPrinter { get;}
    string TerminalServicesWorkDirectory { get;}
    string TerminalServicesInitialProgram { get;}
}

You may also use other scripting language, which will be simpler than C#.

vbscript:

http://www.wisesoft.co.uk/scripts/vbscript_read-write_terminal_services_settings.aspx

PowerShell:

http://blogs.technet.com/b/heyscriptingguy/archive/2008/10/23/how-can-i-edit-terminal-server-profiles-for-users-in-active-directory.aspx

这篇关于如何从 userParameters 属性获取 Active Directory 中的终端服务属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆