UserPrincipal.GetGroups を呼び出す単純なコンソール アプリを実行すると、問題なくユーザー グループが列挙されます。ただし、同じサーバー上で同じユーザーと同じコードを実行すると、WCF をホストしている Windows サービスから、次の一連のエラーが発生します。
Message : The socket transfer timed out after 00:00:10. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout.
Inner Exception
---------------
Message : The read operation failed, see inner exception.
Inner Exception
---------------
Message : The socket transfer timed out after 00:00:10. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout.
Inner Exception
---------------
Message : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
これは、WCF スレッドの偽装と関係がありますか? WindowsIdentity.GetCurrent().Name
同じユーザーを返しますが、Thread.CurrentPrincipal.Identity.Name
異なる - コンソール アプリの場合は空の文字列ですが、Windoes サービスの場合は偽装された WCF ユーザーです。