惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs
博客园 - 叶小钗
P
Privacy International News Feed
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
IT之家
IT之家
博客园 - 聂微东
Know Your Adversary
Know Your Adversary
Help Net Security
Help Net Security
罗磊的独立博客
I
Intezer
S
Schneier on Security
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
Cisco Talos Blog
Cisco Talos Blog
宝玉的分享
宝玉的分享
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
P
Privacy & Cybersecurity Law Blog
T
The Exploit Database - CXSecurity.com
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
H
Heimdal Security Blog
S
Secure Thoughts
Hacker News: Ask HN
Hacker News: Ask HN
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
T
Threat Research - Cisco Blogs
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - vuejs3

More on SQL Server Service Broker [转]Android试验:如果View的ID相同会出现什么效果? 父子关系排序,无确定根节点 Silverlight 操作技巧 [文摘]怎么使用Sticky Footer代码(让页脚紧贴页面底部的方法) Sharepoint development toolbox 通过对象模型上传List Template - vuejs3 - 博客园 在文档库中隐藏多文件上传/Disable the Upload Multiple Document option in Document Library - vuejs3 [转]SharePoint Document Library and List – File Upload ASP.NET 2.0 TreeView控件在IE7中断开的连接线 Team Foundation Server讲义 通过CertEnroll在CA上(1创建证书请求2得到证书3安装证书) 如何在WSS中利用KeywordQuery创建搜索查询 SharePoint开发中对ListViewWebPart的几个操作 【转】免费SharePoint资源 Enum操作技巧 LINQ概述-通用和便利的信息查询方式 NetShopForge网上商店程序(VB)源码—讨论-发布 Microsoft AJAX添加自定义智能感知(intellisense)
SharePoint Web Service的身份验证
vuejs3 · 2008-11-10 · via 博客园 - vuejs3

WebPart中对SharePoint Web Service的身份验证(Form Authentication)

主要是拿到Request中的Cookie(system.web.HttpCookie)转换成CookieContainer中需要的Cookie(system.net.Cookie)
假设我们使用最常用的lists.asmx来获取SharePoint列表数据,添加的Web引用的命名空间是spwsList

            Dim serviceURL As String = SPContext.Current.Site.OpenWeb.Site.Url & "/_vti_bin/lists.asmx"
            
Dim server As spwsList.Lists = Nothing
            server 
= New spwsList.Lists
            server.CookieContainer 
= New Net.CookieContainerFor i As Integer = 0 To Me.Context.Request.Cookies.Count - 1
                
Dim c As Web.HttpCookie = Me.Context.Request.Cookies(i)
                
If c.Name.ToUpper = ".ASPXAUTH" Then
                    
Dim coo As New Net.Cookie(c.Name, c.Value, c.Path)
                    server.CookieContainer.Add(
New Uri(serviceURL), coo)
                    
Exit For
                
End If
            
Next
            
Return server

--------------------以下转载自http://blog.joycode.com/erucy/archive/2008/07/28/115205.aspx--------------------

 SharePoint内置了一套相对比较完整的Web Services提供给开发者,这样就可以在客户端、跨平台的程序中读取甚至修改SharePoint中的内容。不过当SharePoint网站不允许匿名访问的时候,调用Web Services自然也需要提供身份验证。

    SharePoint身份验证最常用的是Windows验证(Windows Authentication)和表单验证(Form Authentication)两种。

    Windows验证即使用Windows账号或者AD账号来进行身份验证,对于这种验证方式,在SharePoint SDK中已经给出了如何提供身份验证的方法,假设我们使用最常用的lists.asmx来获取SharePoint列表数据,添加的Web引用的命名空间是spwsList:

使用当前帐户身份:

1 spwsList.Lists wsLists = new spwsList.Lists(); 2 wsLists.Credentials = CredentialCache.DefaultCredential; 3 Console.WriteLine(wsLists.GetListCollection().OuterXml);

使用指定帐户:

1 spwsList.Lists wsLists = new spwsList.Lists(); 2 wsLists.Credentials = new NetworkCredential("username", "password", "domain"); 3 Console.WriteLine(wsLists.GetListCollection().OuterXml);

    上面的CredentialCache、NetworkCredential都是在System.Net命名空间下。

    表单认证是SharePoint 2007新加入的一种身份认证方式,其后台是使用.Net Framework中的Membership机制进行用户身份的识别,对于外网来说,大都是使用表单认证的方式来实现的。在使用表单认证的SharePoint网站中通过Web Service获取数据稍微麻烦一些,不过也可以通过SharePoint提供的表单认证Web Service来创建用户身份相关的Cookie。

    表单认证Web Service的地址是:http://[server]/[site]/_vti_bin/authentication.asmx

    在使用Web Service的程序中再次加入上面这个Web引用,假设其命名空间是spwsAuth,那么使用表单认证构造身份并访问数据的代码实例如下:

1 spwsAuth.Authentication auth = new spwsAuth.Authentication(); 2 auth.CookieContainer = new CookieContainer(); 3 auth.AllowAutoRedirect = true; 4 spwsAuth.LoginResult lr = auth.Login("username", "password"); 5 if (lr.ErrorCode == spwsAuth.LoginErrorCode.NoError) 6 { 7 spwsList.Lists wsList = new spwsList.Lists(); 8 wsList.CookieContainer = auth.CookieContainer; 9 XmlNode res = wsList.GetListCollection(); 10 Console.WriteLine(res.OuterXml); 11 }