I need to set properties related to Remote Desktop Services on Active Directory users in .NET (i.e., via System.DirectoryServices), but I can't see that these properties are exposed by the API? I know there is a COM interface for this purpose, IADsTSUserEx. Please sho开发者_开发百科w me how I can get at these properties in .NET :) Bear in mind that the programming language is Python.
The .NET DirectoryServices API doesn't expose AD properties directly: instead, there's a big Properties
collection on the DirectoryEntry
class. If you can find out the names of the attributes in the underlying AD schema then you be able to find them in this collection.
This list should have the properties you're interested in: http://msdn.microsoft.com/en-us/library/ms675090.aspx
For instance, the msTSMaxIdleTime
attribute: http://msdn.microsoft.com/en-us/library/ms678175.aspx
The problem with some of these properties is that you can see them on the UI via Active Directory Users and Computers, but you cannot set them (or see them) via ADSI Editor.
Usually, for properties that aren't directly available from a DirectoryEntry
object, you can use its Properties
collection as described by Tim Robbinson
(e.g. directoryEntry.Properties["PropertyName"].Value
).
For some properties, however, you cannot use this approach and have to use directoryEntry.InvokeSet("PropertyName", new object[]{ "SomeValue" });
,
e.g. for TerminalServicesHomeDirectory
, TerminalServicesHomeDrive
and TerminalServicesProfilePath
.
As said above, you won't see these three properties using ADSI Editor, you can only see the property values via the "normal" UI on the corresponding tab.
How you can apply all this to Python I don't know, but it seems you've got instances of the DirectoryEntry
class, so you should be fine.
精彩评论