Create a FedAuth cookie from SecurityToken

What I want to do is connect to the sharepoint site (it uses an ADFS server) using HttpWebRequest. How do i do this:

  • I got SecurityToken using WSTrustChannelFactory (see this post here )
  • Convert SecurityToken to FedAuth Cookie
  • Create an HttpWebRequest and attach a FedAuth cookie.
  • Sending an HttpWebRequest request and receiving a response.

PROBLEM: In step 2, you need to convert SecurityToken (that '_a9e1657d-9360-4578-9075-9a84617a6826') in FedAuth cookies, which should be something like "77u / PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48U1A + MGUudHxsc3QgYWRmc3xldWdlbmlqdXNyQGxzdC5pbnRlcm5hbCwwZS50fGxzdCBhZGZzfGV1Z2VuaWp1c3JAbHN0LmludGVybmFsLDEzMDA0NzA4NzU4MTYzMDAwMCxUcnVlLEswN0FqZWdlTWZTMUpwZWhka3FlOGtQN0I4MUxxL3ZKOS8zM2NtRnk2KzNvQ3M5Sy9pM1dYZmU4SHlxWHdTOGhLRDdLWkgyaG9QcytZNEJBOHkrcnFRR3BVUFQxUGtOaTJqL0EvRHZKOWk0Z0V5Z2ZNT3oyUDlpRER6K2tST2FrQVpybG5xM0hxYTlCVWs4S1JuSGJEUXpyK3h1TDk1SEl4K3dibnJQMlY3cVdDSFBmRXhsc0Ftc2duWjl3c3E3ZVlnL1AxL2FaWFphWWtseFYyQ1ZEdGN3eENLRWpQWnF2TVlRNlo1M3NUZFVvQ3dwRlB6SzIzNnpGeHhZZnIvUXFn

The cookie value seems to be encrypted. How to create an encrypted cookie from a token string? Somebody knows?

Thanks.

+4
source share
1 answer

I found an example that parses a security token and decrypts it using local storage certificates. You will then receive a FedAuth cookie and try connecting you to the sharepoint instance using CSOM. Example

However, I still get an error message when I log in to Sharepoint, but it seems to be happening with the name mistmatch of the certificate.

0
source

All Articles