Search code examples
c#ldapc#-2.0terminal-servicesiadstsuserex

How to read TermainsServices IADsTSUserEx Property from LDAP in C#?


I have read the following properties from AD,

TerminalServicesProfilePath
TerminalServicesHomeDirectory
TerminalServicesHomeDrive

I've tried DirectoryEntry and DirectorySearcher. But they does not include the properties.

I found some example in vbscript and VC to read them. However I failed to make it working in C#. Am I missing some tricky thing?

EDIT: Am I have to run it on "Windows Server" to make it works? Can it be read from win XP?


Solution

  • I don't remember exactly, but it's something like this:

    //user is a DirectoryEntry
    IADsTSUserEx adsiUser = (IADsTSUserEx)user.NativeObject; 
    

    then you can get the TerminalServices properties you want via adsiUser.

    From my experience you're better off developing on a Windows Server with access to AD due to the libraries you use. Then you'll probably make the above work, too :)