简体   繁体   中英

How to logoff from a SharePoint 2010 site using a c# client?

I found this Remote Authentication in SharePoint Client Object Model which has examples to popup a IE window in order to get all the cookies for remote SharePoint access. Ideally, the program popups a window to the site, asks the user to login, and then disappears. The program then can insert items into the SharePoint site.

Problem Description

I observed that this example application pops up a window but redirected to our company's example SharePoint site, instead of my site, and it didn't ask me to log in. Then if I close this window manually the clientContext (from ClaimClientContext.GetAuthenticatedContext(siteUrl) ) in the example code will be null pointer. To fix this, I first manually open an IE window, go to my site, I will be automatically logged in (which I think that's the problem since the example application wasn't able to get a cookie because there was no logging in), then if I manually log off from the IE window, run the example application, it will pop up a window, seems it automatically log in and then the window disappeared and the items can be added to the list.

My Question

Is there a way to programmatically log off the SharePoint site from the application at first?

Problem is in authorization cookie. You must delete FedAuth cookie to "logout".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM