IIS7 integrated mode closing token between requests
We are migrating to IIS7 integrated mode and have come across an issue. We authenticate using WindowsAuthentication but then store a reference to the WindowsPrincipal so that on future requests we can authorize as needed against AD. In IIS 7 Integrated mode, the token is being closed (between requests) so that when we try to run IsInRole it generates a disposed exception. Is there a way to cache this token or change our use of WindowsPrincipal so that we don't need to make successive AD requests to get it for each authorization request?
Here is the exception being thrown from WindowsPrincipal.IsInRole("") - System.ObjectDisposedException: {"Safe handle has been closed"}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Have you tried letting IIS cache the auth information for you?
Check out the options for the section of web.config. Specifically the
authPersistNonNTLM
andauthPersistSingleRequest
attributes. PersistNonNTLM=True may do exactly what you need w/o any custom implementation in your code.http://www.iis.net/ConfigReference/system.webServer/security/authentication/windowsAuthentication
In
AcquireRequestState
event handler I just touched theHttpContext.Current.User.Identity.Name
as belowand in my WCF services I could use the
Identity
and theProfile
, without aObjectDisposedException
.I don't know why.