WebAuthenticationBroker.AuthenticateAsync throws exception

北城余情 提交于 2019-12-07 02:09:09

问题


My code uses :

WebAuthenticationResult WebAuthenticationResult = await
WebAuthenticationBroker.AuthenticateAsync( 
                                        WebAuthenticationOptions.None, 
                                        StartUri, 
                                        EndUri); 

just like the Microsoft Web authentication broker sample

It used to work on my desktop and on my tablet (Surface) but now it is not working on my desktop. It throws exception

The process terminated unexpectedly. (Exception from HRESULT: 0x8007042B)

It is working on the tablet and on different windows-8 desktop.

Any suggestion what can cause this exception?


回答1:


I'm not sure but I think that the WebAuthBroker needs to be invoke on the UI Thread since it is trying to change something to your UI in the way of showing you the pop-up.




回答2:


WebAuthenticationBroker.AuthenticateAsync kicks off AuthHost.exe process as a child of the app process, and the HRESULT returned by the exception indicates that AuthHost.exe failed unexpectedly. When launched, AuthHost tries to purge cookies, content and history from non sso containers, and if it fails, it backs off. On the other side, a Windows App runs in a sandbox with a set of permissions different from a desktop application. Thus Internet Explorer itself or a desktop application doing SSO might be able to work normally, but AuthHost will not be allowed to do required clean up on start. In my case, a user running the app was a part of the group that was granted full access to the folder, but the user itself did not have direct file access permissions. However, the group rights got stripped off in the app sandbox. In a default set up, permissions are configured properly, and no such problems should arise. However, in come cases a user moves the Temporary Internet Files to a new location, which might have a slightly different set of file access permissions. The other response on this thread suggests that deleting and re-creating profile helps. This operation resets Temporary Internet Files settings in the Internet Explorer to default, indirectly supporting my suggestion.



来源:https://stackoverflow.com/questions/13470843/webauthenticationbroker-authenticateasync-throws-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!