0

I have a c# .NET 3.5 application which retrieves various user properties. Out of them 'TerminalServicesHomeDirectory', 'TerminalServicesHomeDrive' are 2 properties I need to fetch. On the DirectorySearcher, if I add these 2 propertiesToLoad property and do a FindAll(), the SearchResult object does not contain these properties.

I will have to do SearchResult.GetDirectoryEntry() and from the obtained directory entry, when I do InvokeGet, I get the values.

My question is, is there a way I can get value for these properties without having to create directory entries for each SearchResult ?

Is there anything I am missing? Thanks!

user1576882
  • 147
  • 2
  • 3
  • 13
  • *without having to create directory entries*.. You will always have to load a DirectoryEntry if you want to get the properties of an user. – C0d1ngJammer Apr 15 '15 at 05:35
  • @manuchao: You are talking about terminal services properties right ? – user1576882 Apr 15 '15 at 05:59
  • Yes. The funny thing is, I cant find the properties in the msdn documentation. [msdn](https://msdn.microsoft.com/en-us/library/ms675090%28v=vs.85%29.aspx) – C0d1ngJammer Apr 15 '15 at 06:03
  • 1
    I ran in to this problem myself [a few years ago](http://stackoverflow.com/questions/2000544/managing-terminal-users-through-system-directoryservices/2002217). As the linked duplicate says, do `IADsTSUserEx adsiUser = (IADsTSUserEx)user.NativeObject;` and then `adsiUser` will have the properties you are looking for. [Here is the MSDN](https://msdn.microsoft.com/en-us/library/dd919962(v=vs.85).aspx) for the property you want – Scott Chamberlain Apr 15 '15 at 06:49
  • @ScottChamberlain: Yes, this is the solution I know. This means that you will have to get 'DirectoryEntry' object with the SearchResult, with that get the NativeObject and get values for terminal services properties. I was just thinking is there any way where we can avoid these. Thanks! – user1576882 Apr 15 '15 at 07:25

0 Answers0