You are doing this correctly. Is it possible that the actual COM
interfaces
have not been registered? You can't just copy them to your machine.
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services
Programming"
http://www.directoryprogramming.net
--
"Manuel Moser" <Manuel Moser@[EMAIL PROTECTED]
> wrote in message
news:B62CAA3B-A68E-41A6-89D3-FD6B44D5FE69@[EMAIL PROTECTED]
> Hello guys!
>
> I am trying to access to User-Properties from my C#-Programm.
> It is no problem to set "Sirname", "Mail", "scriptPath", "HomeDirectory"
> and
> so on.
>
> But I have problems with the "TerminalServices"-Attributes like
> "TerminalServicesProfilePath".
>
> First time I tried it like that:
>
> DirectoryEntry entry = new
> DirectoryEntry("LDAP://OU=Users,DC=COMPANY,DC=COM");DirectoryEntries
> entries
> = entry.Children;
> entry = entries.Add("CN=" + textBox_name.Text, "user");
>
> entry.Properties["TerminalServicesProfilePath"].Value =
> textBox_TerminalServiceProfil.Text;
>
> But I read that I can't access to this attribute in that way.
>
> Then I heard about ActiveDs.dll and TSUSEREXLib.dll. I got these 2
> dll-Files
> and set a reference to them.
> Now my code looks like that:
>
>
> DirectoryEntry entry1 = new DirectoryEntry("path to user");
> ActiveDs.IADsUser iADsUser1 = (ActiveDs.IADsUser)entry1.NativeObject;
> TSUSEREXLib.IADsTSUserEx m_TsUser = (TSUSEREXLib.IADsTSUserEx)iADsUser1;
> m_TsUser.TerminalServicesProfilePath = path1;
> entry1.CommitChanges();
>
> But now my programm throws an exception:
>
> System.InvalidCastException: Das COM-Objekt des Typs
"System.__ComObject"
> kann nicht in den Schnittstellentyp "TSUSEREXLib.IADsTSUserEx"
umgewandelt
> werden. Dieser Vorgang konnte nicht durchgeführt werden, da der
> QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit
der
> IID
> "{C4930E79-2989-4462-8A60-2FCF2F2955EF}" aufgrund des folgenden Fehlers
> nicht
> durchgeführt werden konnte: Schnittstelle nicht unterstützt (Ausnahme
von
> HRESULT: 0x80004002 (E_NOINTERFACE)).
>
> in english:
> System.InvalidCastException: The COM-Object of the type
> "System.__ComObject"
> cannot be casted to the interface type "TSUSEREXLib.IADsTSUserEx". This
> process could not be performed because the QueryInterface-call to the
> COM-component for the inteface with the IID
> "{C4930E79-2989-4462-8A60-2FCF2F2955EF}" could not be performed because
of
> the following error: interface not provided (Exception HRESULT:
0x80004002
> (E_NOINTERFACE)).
>
> I also tried it only with:
> TSUSEREXLib.IADsTSUserEx m_TsUser =
> (TSUSEREXLib.IADsTSUserEx)entry1.NativeObject;
>
> But the Programm got the same error again.
>
> I am working with Windows 2k and the Visual Studio 2005.
>
> I hope you can help me.
>
> Greetings
> Manuel


|