Windows phone 7 如何使用会话cookie通过Windows Phone应用程序以编程方式向UAG for SharePoint进行身份验证

Windows phone 7 如何使用会话cookie通过Windows Phone应用程序以编程方式向UAG for SharePoint进行身份验证,windows-phone-7,sharepoint,authentication,Windows Phone 7,Sharepoint,Authentication,在Windows Phone应用程序中,我尝试读取受UAG保护的SharePoint数据,并希望支持将会话cookie传递给UAG 白皮书《使用SharePoint 2010产品和统一访问网关(UAG)构建Windows Phone 7应用程序》演示了每次向UAG传递用户凭据 但是,如何存储和重用UAG传递回客户端的会话cookie //Example from white paper string url = String.Format(“{0}/my/_layouts/activit

在Windows Phone应用程序中,我尝试读取受UAG保护的SharePoint数据,并希望支持将会话cookie传递给UAG

白皮书《使用SharePoint 2010产品和统一访问网关(UAG)构建Windows Phone 7应用程序》演示了每次向UAG传递用户凭据
但是,如何存储和重用UAG传递回客户端的会话cookie

//Example from white paper string url = String.Format(“{0}/my/_layouts/activityfeed.aspx?consolidated=true", AppSettings.Url); System.Uri authServiceUri = new Uri(url); HttpWebRequest client = WebRequest.CreateHttp(authServiceUri) as HttpWebRequest; client.Headers["User-Agent"] = "Microsoft Office Mobile"; client.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(AppSettings.Username + ":" + AppSettings.Password))+ System.Environment.NewLine; // Call and handle the response... //白皮书举例 字符串url=string.Format(“{0}/my/_layouts/activityfeed.aspx?consolidated=true”,AppSettings.url); System.Uri authServiceUri=新Uri(url); HttpWebRequest client=WebRequest.CreateHttp(authServiceUri)作为HttpWebRequest; client.Headers[“用户代理”]=“Microsoft Office Mobile”; client.Headers[“Authorization”]=“Basic” +Convert.ToBase64String(Encoding.UTF8.GetBytes(AppSettings.Username+):“ +AppSettings.Password))+System.Environment.NewLine; //呼叫并处理响应。。。 这篇为SharePoint 2010开发Windows Phone 7应用程序的博文展示了如何通过FBA身份验证并通过请求传递cookie。但我不知道其中有多少适用于UAG

private void Authenticate() { System.Uri authServiceUri =new Uri("http://phone.contoso.com/_vti_bin/authentication.asmx"); HttpWebRequest spAuthReq = HttpWebRequest.Create(authServiceUri) as HttpWebRequest; spAuthReq.CookieContainer = cookieJar; spAuthReq.Headers["SOAPAction"] = "http://schemas.microsoft.com/sharepoint/soap/Login"; spAuthReq.ContentType = "text/xml; charset=utf-8"; spAuthReq.Method = "POST"; //add the soap message to the request spAuthReq.BeginGetRequestStream(new AsyncCallback(spAuthReqCallBack), spAuthReq); } // After authenticated and cookie is set ListsService.ListsSoapClient lists = new ListsService.ListsSoapClient(); lists.CookieContainer = cookieJar; 私有void身份验证() { System.Uri authServiceUri=新Uri(“http://phone.contoso.com/_vti_bin/authentication.asmx"); HttpWebRequest spAuthReq=HttpWebRequest.Create(authServiceUri)作为HttpWebRequest; spAuthReq.CookieContainer=cookieJar; spAuthReq.Headers[“SOAPAction”]=”http://schemas.microsoft.com/sharepoint/soap/Login"; spAuthReq.ContentType=“text/xml;charset=utf-8”; spAuthReq.Method=“POST”; //将soap消息添加到请求中 BeginGetRequestStream(新的异步回调(spAuthReqCallBack),spAuthReq); } //经过身份验证后,设置cookie ListsService.ListsSoapClient lists=新的ListsService.ListsSoapClient(); lists.CookieContainer=cookieJar;
UAG对cookie进行签名,这意味着用户每次登录时cookie都会被混淆。此外,UAG不进行cookie登录-它将cookie用于会话。

UAG对cookie进行签名,这意味着用户每次登录时cookie都会被混淆。UAG也不进行cookie登录-它将cookie用于会话。

这两种方法在某些情况下都适用于UAGnces。如果您使用HttpWebRequest,您可以通过在每次调用中设置基本授权和useragent头向UAG进行身份验证。您不必将cookie传递给UAG。SharePoint将在下次响应时返回数据

您还可以修改上述FBA示例,使其与UAG协同工作: 必须在Authenticate方法中添加useragent和基本身份验证头

spAuthReq.Headers["User-Agent"] = "Microsoft Office Mobile";
spAuthReq.Headers["Authorization"] = "Basic " . . .  
两个小贴士:

  • 由于您将使用HTTPS,因此还需要将clientconfig安全模式更改为transport
  • 在开始开发之前,针对您的UAG/SharePoint环境测试

在某些情况下,这两种方法都适用于UAG。如果您使用HttpWebRequest,您可以通过在每次调用中设置基本授权和useragent头来向UAG进行身份验证。您不必将cookie传递给UAG。SharePoint将在下一次响应中返回数据

您还可以修改上述FBA示例,使其与UAG协同工作: 必须在Authenticate方法中添加useragent和基本身份验证头

spAuthReq.Headers["User-Agent"] = "Microsoft Office Mobile";
spAuthReq.Headers["Authorization"] = "Basic " . . .  
两个小贴士:

  • 由于您将使用HTTPS,因此还需要将clientconfig安全模式更改为transport
  • 在开始开发之前,针对您的UAG/SharePoint环境测试