配置SharePoint站点的域认证和表单认证双重认证1/2
在SharePoint Portal Server 2003的时代,它被说得最多的一个问题就是其用户系统必须使用Active Directory,我们必须在域里面为用户创建相应的AD账号,然后才能将AD账号添加为SharePoint站点用户。如果企业已经部署了AD,那么这不会是一个多大的问题(反而会成为其一个优点),但是对于没有部署AD的企业,或者要将SharePoint站点发布到Internet上的场景,这就是一个不小的问题了。幸好SharePoint Server 2007中已经完全支持定制的用户管理模块,它使用了ASP.NET 2.0的Membership Provider机制来作为其用户管理的底层机制,这样就带给了我们非常大的灵活性。假如在企业中已经存在了一套用户认证系统(比如某某LDAP服务器,或者某某OA系统),那么我们可以很容易的让SharePoint Server 2007使用同一套用户认证系统,这样,SharePoint Server 2007本身不必要存储用户的信息。当然,通过Membership Provider机制,你也可以将用户名和密码保存在某一个数据源中(比如SQL Server数据库)。
重要说明:先引用Kaneboy老师Blog中的一段文字开展整个文章吧,由于我不善于理论描述,并且接触MOSS2007的时间也不是很长,在网友木偶和十一的指导下,将近期对SharePoint的学习做一个总结,希望能给各位同学一个参考。(因本人所有SharePoint的知识来源都来自网络,故文中如有引用网友的BLOG中内容,恕不注明来源,在本文的最后会统一注明应用了哪些文章的)
软件列表:
在以下图示的安装过程中,使用了下面所列出的软件
[*]Microsoft Windows 2003 SP1 简体中文企业版
[*]由于工作环境中有一台域服务器,故加入了该域
[*]Microsoft SQL Server 2005 简体中文企业版
[*]Microsoft Visual Studio 2005 简体中文企业版
[*].NET Framework 3.0
[*]Office SharePoint Server 2007 简体中文版或WSS3.0
[*]Microsoft Office SharePoint Designer 2007简体中文版
一、创建FORM认证数据库
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint1.png
由于文中用到Form验证,将用户信息存储于数据库中,故我们需要创建一个数据库,最简单的方法是使用Visual Studio新建Web站点
使用SQL2005自带的aspnet_regsql.exe来建立aspnetdb数据库,路径为:%windir%\Microsoft.NET\Framework\v2.0.5027。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint2.png
这是使用刚才dos命令后,在数据库中创建的表的内容;
二、扩展支持form认证的应用程序
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint3.png
现有站点http://moss.3322.org,区域为:默认;使用的认证模式是windows认证。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint4.png
在原有站点基础上,扩展一个web应用程序,http://www.sharepoint.org.cn
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint5.png
允许匿名访问,区域选internet,上面已经有一个应用程序选择了默认区域。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint6.png
创建成功后,默认的验证方式是windows认证。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint7.png
编辑验证,选择表单验证类型
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint8.png
输入正确的提供程序名称和角色管理器,点击保存。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint9.png
保存后的界面。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint10.png
如果此时查看该站点的web.CONFIG文件,将发现有上述的变动。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint11.png
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint12.png
这时,已经完成form认证和windows认证站点的创建和修改。
即:http://moss.3322.org 为windows认证模式
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint13.png
http://www.sharepoint.org.cn 为form认证模式.
三、修改站点的WEB.CONFIG文件
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint14.png
图示的路径为刚才扩展站点的web.CONFIG文件存放位置。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint15.png
在<SYSTEM.WEB>的上方插入<CONNECTIONSTRINGS>节,在<SYSTEM.WEB>的内部插入<MEMBERSHIP>和<rolemanager>节
<CONNECTIONSTRINGS>节:
<connectionStrings>
<remove name="AspNetSqlProvider" />
<add name="AspNetSqlProvider" connectionString="server=server; database=aspnetdb; Trusted_Connection=True" />
</connectionStrings>
<MEMBERSHIP>和<rolemanager>节:
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add connectionStringName="AspNetSqlProvider" passwordAttemptWindow="10" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" description="Stores and retrieves membership data from the Microsoft SQL Server database" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<remove name="AspNetSqlRoleProvider" />
<add connectionStringName="AspNetSqlProvider" applicationName="/" description="Stores and retrieves roles data from the local Microsoft SQL Server database" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
打开管理中心的虚拟目录位置,修改其web.config文件。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint16.png
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint17.png
在管理中心站点的web.config文件中,只插入<ROLEMANAGER>节。
内容和上面的相同。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint18.png
同时将该文件下方的<add name="RoleManager">注释掉!非常重要,为什么呢?这是我尝试的结果,如果不注释的话,在管理中心页面中访问"应用程序管理"时会报错。
http://www.sharepoint.org.cn/Lists/Photos/041707_1014_SharePoint19.png
重新启动一下IIS服务,即完成初步配置,在后面将介绍如何创建一个支持用户自由注册的站点,万里长征开始了第一步啦。
页:
[1]