次のコード スニップを使用して、選択した AD ユーザーのターミナル サービス プロファイル パスを読み取ろうとしています。
...
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
...
try
{
Debug.WriteLine("Looking for: " + DisplayName);
DirectoryEntry entry = new DirectoryEntry(strLDAP, strUserName, strPassword);
DirectorySearcher Searcher = new DirectorySearcher(entry);
Searcher.Filter = "(displayName="+ DisplayName +")";
SearchResult result = Searcher.FindOne();
DirectoryEntry found = result.GetDirectoryEntry();
// tell if we found the right user
Debug.WriteLine(found.Properties["mail"][0].ToString());
// tell what the current terminal services profile path is
Debug.WriteLine(found.InvokeGet("TerminalServicesProfilePath").ToString());
}
catch (DirectoryServicesComException e)
{
Debug.WriteLine(e.Message.ToString());
}
悲しいことに、実行すると次のエラーが発生しますInvokeGet
。
... System.DirectoryServices.dll で System.Runtime.InteropServices.COMException' が発生しました System.Runtime.InteropServices.COMException (0x80020006): 不明な名前です。(HRESULT からの例外: 0x80020006 (DISP_E_UNKNOWNNAME))
ここでぶつかりました..パラメーターがハッシュTerminalServicesProfilePath
のADにあることは知っています。"userParameter"
そして、それを呼び出すと、読みやすいものが得られるはずです。
私は何を間違っていますか?
補足: AD は 2003 レベルのドメインに存在します。