ssg31415926
2005-08-29 17:52:58 UTC
I need to configure Terminal Services settings in a C# program I'm
working on. System.DirectoryServices doesn't seem to allow this. I've
found a reference to IADsTSUserEx on MSDN but the page says I need to
"call the IADs::GetInfo method or the IADs::GetInfoEx method to load
the property values of the ADSI object from the underlying directory
store into the property cache". So far, I've managed to avoid Interop
and I'm not sure what to do.
Initially, I've created a reference in my project to the "tsexusrm 1.0
Type Library" at C:\Windows\system32\tsuserex.dll and I tried this
bare-minimum code:
public string TerminalServicesProfilePath {
get { TSUSEREXLib.ADsTSUserExClass tsUser =
(TSUSEREXLib.ADsTSUserExClass) this.NativeDSObject;
return tsUser.TerminalServicesProfilePath;
}
}
but it's an invalid cast. I'm guessing I've got to cast
this.NativeDSObject as a standard ADSI object first but I'm not sure
how ADsTSUserExClass will 'link' to it. Any ideas?
Note: The above code is in a class which derives from a class which
holds a reference to a DirectoryEntry where this.NativeDSObject is
defined as:
protected object NativeADObject {
get { return this.m_DirectoryEntry.NativeObject; }
}
working on. System.DirectoryServices doesn't seem to allow this. I've
found a reference to IADsTSUserEx on MSDN but the page says I need to
"call the IADs::GetInfo method or the IADs::GetInfoEx method to load
the property values of the ADSI object from the underlying directory
store into the property cache". So far, I've managed to avoid Interop
and I'm not sure what to do.
Initially, I've created a reference in my project to the "tsexusrm 1.0
Type Library" at C:\Windows\system32\tsuserex.dll and I tried this
bare-minimum code:
public string TerminalServicesProfilePath {
get { TSUSEREXLib.ADsTSUserExClass tsUser =
(TSUSEREXLib.ADsTSUserExClass) this.NativeDSObject;
return tsUser.TerminalServicesProfilePath;
}
}
but it's an invalid cast. I'm guessing I've got to cast
this.NativeDSObject as a standard ADSI object first but I'm not sure
how ADsTSUserExClass will 'link' to it. Any ideas?
Note: The above code is in a class which derives from a class which
holds a reference to a DirectoryEntry where this.NativeDSObject is
defined as:
protected object NativeADObject {
get { return this.m_DirectoryEntry.NativeObject; }
}