How to get terminal services property values in Active Directory from userParameters attribute

耗尽温柔 提交于 2019-12-02 07:21:01

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!