我在 WCF 服务后面有以下代码:
if (Sitecore.Security.Authentication.AuthenticationManager.Login("sitecore\\" + username, password, false))
{
// do something
}
但我得到一个“对象未设置”异常,具有以下堆栈跟踪:
at System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc)
at System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties)
at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
at System.Configuration.SettingsBase.SetPropertyValueByName(String propertyName, Object propertyValue)
at System.Configuration.SettingsBase.set_Item(String propertyName, Object value)
at System.Web.Profile.ProfileBase.SetInternal(String propertyName, Object value)
at System.Web.Profile.ProfileBase.set_Item(String propertyName, Object value)
at System.Web.Profile.ProfileBase.SetPropertyValue(String propertyName, Object propertyValue)
at Sitecore.Security.UserProfile.SetPropertyValueCore(String propertyName, Object value)
at Sitecore.Security.UserProfile.set_SerializedData(Object value)
at Sitecore.Security.UserProfile.get_CustomProperties()
at Sitecore.Security.UserProfile.GetCustomProperty(String propertyName)
at Sitecore.Security.SecurityUtil.GetUserDigestCredentials(User user, Boolean withoutDomain)
at Sitecore.Security.SecurityUtil.UpdateDigestCredentials(String username, String password)
at Sitecore.Security.SitecoreMembershipProvider.ValidateUser(String username, String password)
at System.Web.Security.Membership.ValidateUser(String username, String password)
at Sitecore.Security.Authentication.AuthenticationHelper.ValidateUser(String userName, String password)
at Sitecore.Security.Authentication.MembershipAuthenticationProvider.Login(String userName, String password, Boolean persistent)
at Sitecore.Security.Authentication.AuthenticationManager.Login(String userName, String password, Boolean persistent)
at BaillieGifford.Code.services.DR.LoginToSiteCore(String username, String password) in c:\Dev\Development-Websites\Mainwebsite2012-DR\Code\services\DR.svc.cs:line 26
at SyncInvokeLoginToSiteCore(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
堆栈跟踪似乎表明用户的属性存在问题(某处),但并没有准确说明什么...
有什么想法吗?
更新:
来自 web.config 的配置文件位:
<profile defaultProvider="sql" enabled="true" inherits="Sitecore.Security.UserProfile, Sitecore.Kernel">
<providers>
<clear/>
<add name="sql" type="System.Web.Profile.SqlProfileProvider" connectionStringName="core" applicationName="sitecore"/>
<add name="switcher" type="Sitecore.Security.SwitchingProfileProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/profile"/>
</providers>
<properties>
<clear/>
<add type="System.String" name="SC_UserData"/>
</properties>
</profile>