我下面这个教程为SharePoint Online中远程认证,但我做的在C#。
http://allthatjs.com/2012/03/28/remote-authentication-in-sharepoint-online/
我可以从STS的SAML没有问题,但我似乎无法发送该令牌到SharePoint才能收到回饼干,以登录。下面是我的代码,请原谅任何明显的错误,我是新在这!
//Send cookie to SPO. The token is from STS.
byte[] spbyteArray = Encoding.UTF8.GetBytes(theToken);
WebRequest sprequest = WebRequest.Create("https://login.microsoftonline.com/login.srf?wa=wsignin1.0&rpsnv=2&ct=1335885737&rver=6.1.6206.0&wp=MBI&wreply=https%3A%2F%2Fcamida.sharepoint.com%2F_forms%2Fdefault.aspx&lc=1033&id=500046&cbcxt=mai&wlidp=1&guest=1");
sprequest.Method = "POST";
sprequest.ContentLength = spbyteArray.Length;
sprequest.ContentType = "application/x-www-form-urlencoded";
sprequest.Headers.GetType().InvokeMember("ChangeInternal", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, sprequest.Headers, new object[] { "Host", "mydomain.sharepoint.com" });
Stream spdataStream = sprequest.GetRequestStream();
spdataStream.Write(spbyteArray, 0, spbyteArray.Length);
spdataStream.Close();
//Get response from SPO
WebResponse spresponse = sprequest.GetResponse();
spdataStream = spresponse.GetResponseStream();
StreamReader spreader = new StreamReader(spdataStream);
// Read the content.
string spresponseFromServer = spreader.ReadToEnd();
如果我使用的URL在教程中,我得到一个403禁止。 我使用的网址重定向的一个,当我到http://mydomain.sharepoint.com
任何帮助和建议是极大的赞赏。