Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Problem with Auth. in Sharepoint

$
0
0

Hi, I've got from IDP SAML token and based on it I created RequestSecurityTokenResponse object which now has value:

<?xml version="1.0" encoding="utf-8"?><t:RequestSecurityTokenResponse Context="http://sp/SitePages/Home.aspx" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"><t:Lifetime><wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-02-18T11:53:13.069Z</wsu:Created><wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-02-18T11:58:13.069Z</wsu:Expires></t:Lifetime><wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><EndpointReference xmlns="http://www.w3.org/2005/08/addressing"><Address>http://rpsts.repozytorium.pl/</Address></EndpointReference></wsp:AppliesTo><t:RequestedSecurityToken><saml:Assertion Version="2.0" ID="_e4fc3170-532b-410d-9814-f285cb136388" IssueInstant="2013-02-18T11:53:13.0698434Z" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"><saml:Issuer>http://system.sa.us.pl/csioz-dev-sp</saml:Issuer><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI="#_e4fc3170-532b-410d-9814-f285cb136388"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>bUPGyu8ChyU5z7Ro9js8azaev/o=</DigestValue></Reference></SignedInfo><SignatureValue>drH6KqdrJ4q4asdQ5GUI5h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gc78k7EoQJCXhLoYcqHG2bVvvEcbdTMghqDw8k/ZIaL8ahm9FB/M5yAOyvwfSzsykHTp0JLVR2/ljQqTemtcAZhb1GtVdHg9iYMejpFCAyyEL980eTdD8D1KRSEn2vxw0BDg5O9LAaiES3zh6QWvMEcQYtmFsBe1RkxfI7i</X509Certificate></X509Data></KeyInfo></Signature><saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">10b2c3a8-edca-4b01-b61e-3dfb7b1d0c59</saml:NameID><saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"><saml:SubjectConfirmationData /></saml:SubjectConfirmation></saml:Subject><saml:Conditions NotBefore="2013-02-18T11:53:13.0698434Z" NotOnOrAfter="2013-02-18T11:58:13.0698434Z" /><saml:AuthnStatement AuthnInstant="2013-02-18T11:53:13.0718436Z"><saml:AuthnContext><saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement><saml:AttributeStatement><saml:Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"><saml:AttributeValue xmlns:q1="http://www.w3.org/2001/XMLSchema" p7:type="q1:string" xmlns:p7="http://www.w3.org/2001/XMLSchema-instance">Kamil</saml:AttributeValue></saml:Attribute></saml:AttributeStatement></saml:Assertion></t:RequestedSecurityToken><t:TokenType>urn:oasis:names:tc:SAML:2.0:assertion</t:TokenType><t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType><t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType></t:RequestSecurityTokenResponse>

and next I passed this result in wresult (messOutResult) parameter in code like this:

var sharepointSite = new
                                {
                                    Wctx = realm + "_layouts/15/Authenticate.aspx?Source=%2F",
                                    Wtrealm = realm,
                                    Wreply = realm + "_trust/"
                                };

                                string stringData = String.Format("wa=wsignin1.0&wctx={0}&wresult={1}", HttpUtility.UrlEncode(sharepointSite.Wctx), messOut.Result);
                                HttpWebRequest sharepointRequest = HttpWebRequest.Create(sharepointSite.Wreply) as HttpWebRequest;
                                sharepointRequest.Method = "POST";
                                sharepointRequest.ContentType = "application/x-www-form-urlencoded";
                                sharepointRequest.CookieContainer = new CookieContainer();
                                sharepointRequest.AllowAutoRedirect = false; // This is important
                                Stream newStream = sharepointRequest.GetRequestStream();

                                byte[] data = Encoding.UTF8.GetBytes(stringData);
                                newStream.Write(data, 0, data.Length);
                                newStream.Close();
                                HttpWebResponse webResponse = sharepointRequest.GetResponse() as HttpWebResponse;

                                if (webResponse.StatusCode == HttpStatusCode.OK)
                                {
                                    using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
                                    {
                                        string Content = reader.ReadToEnd();
                                    }
                                }

I am used that code to generate response to Sharepoint but unfortunatelly I've got error in bold line, when do GetResponse():

The remote server returned an error: (500) Internal Server Error.

Anybody know why sharepoint return 500? Thanx for any help.



Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>