1
votes

I'm using C# and I'm able to read a lot of values from Active Directory, however I can't figure out how to read the Profile Path, or the Remote Desktop Services Home Folder which are both found on the Remote Desktop Services Profile tab when looking at a user in Active Directory.

1
What Server OS? The Profile Path should just be the "profilePath" properties. I'm guessing the other one was supposed to be Remote Desktop Services Home Folder, look for TerminalServicesHomeDrive ,TerminalServicesHomeDirectory & TerminalServicesProfilePath in Server 2003 and msTSHomeDrive , msTSHomeDirectory , & msTSProfilePath in Server 2008 - Infinite Possibilities
I'm using Windows Server 2008. You are correct the 2nd value was supposed to be the Remote Desktop Services Home Folder, I've updated my post to fix the typo. - Rossini
I've checked all the values you suggested, and all of them are null - Rossini
Try using this code in the debugger, it's no where near perfect but will help you see what properties you have on that entry. Dictionary<string, string> dictonaryOfValues = directoryEntry .Properties .OfType<PropertyValueCollection>() .ToDictionary(p => p.PropertyName, p => (p.Value ?? "").ToString()); - Infinite Possibilities
I took your suggestion and used that code to see all the properties. The values you suggested are not listed, nor anything like them. Is it possible the values I want are in the "UserParameters" property? That's the only property that I can't read, it's encoded some how and I don't know how to decode it. - Rossini

1 Answers

0
votes

These values store in UserParameters attribute and to get them you can to use InvokeGet here, for example to get Remote Service Profile path:

// Get Directory Entry for the object
DirectoryEntry de = New DirectoryEntry(ldapPath, logonName, password);
object prPAth = de.InvokeGet("TerminalServicesProfilePath"); // Remote Desktop Services profile path. If value is empty you'll get an exception here
object homeFolder = de.InvokeGet("TerminalServicesHomeDirectory"); // Remote Desktop Services home folder