SharePoint 2007:将SqlProfileProvider与Windows集成身份验证一起使用?

时间:2009-08-12 21:56:32

标签: sharepoint sharepoint-2007

我试图弄清楚是否可以使用 SqlProfileProvider(aspnetdb)来存储Windows集成身份验证向SharePoint 2007网站进行身份验证的用户的某些配置文件信息。目标是能够开发ASP.NET代码,为每个用户存储一些个性化字符串,并将在ASP.NET或SharePoint站点中运行。我希望我可以使用SqlProfileProvider然后它可以在ASP.NET或SharePoint中使用,只要我将正确的提供程序添加到 web.config

这是我在SharePoint Web应用程序中的web.config中所拥有的内容,但是在我的ASPX代码隐藏 Context.Profile 中始终为null:

<profile automaticSaveEnabled="true" defaultProvider="AspNetSqlProfileProvider">
<providers>
    <clear/>
    <add name="AspNetSqlProfileProvider" 
         connectionStringName="aspnetdb" 
         applicationName="simple_test" 
         type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
<properties>
    <add name="TestName" type="System.String" allowAnonymous="false"/>
</properties>

(请注意,aspnetdb是web.config中其他位置的有效连接字符串。)

任何人都有与Windows身份验证结合使用aspnetdb配置文件提供程序的经验,或者仅在表单/成员身份验证生效时才有效?关于如何在ASP.NET / SharePoint中保留用户设置而不必使用cookie或从头开始编写数据模型和访问层的任何其他建议?

2 个答案:

答案 0 :(得分:1)

根据this文章

,它应该是可能的
  

由于配置文件存储在特定于用户的记录中,因此您需要先验证当前用户,然后才能读取或写入配置文件信息。 您可以使用任何类型的身份验证系统,包括基于Windows的身份验证和基于表单的身份验证。配置文件系统并不关心 - 它只是将用户特定信息存储在基于用户ID标识的记录中。看到每个身份验证系统都按用户ID唯一标识用户,任何身份验证系统都可以正常工作。

但我以前从未尝试过。

另外,我在SO上发现了这篇文章,详细内容如下:

SO Post

答案 1 :(得分:0)

经过更多搜索和原型设计后,我设法偶然发现了解决方案,感谢this MSDN Forum post。 SharePoint删除了ASP.NET Profile模块,因此您必须将其重新添加到Web.config httpModules部分:

<add name="Profile" type="System.Web.Profile.ProfileModule" />  

访问web.config中定义的Profile属性还需要一些变通方法,这样就不会出现编译时错误。您可以将自定义提供商开发为described in Becky's post for forms-based authentication,也可以拨打Profile.GetPropertyValueProfile.SetPropertyValue来获取和设置当前用户的配置文件值。