当我运行调用 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 用户。