I'd be grateful if anyone could point me towards the right direction for the following problem.
Given: Sharepoint 2010 project. FBA Authentication with custom user profile (class called UserProfile, inherited from ProfileBase). Custom user profile class is located in the Test.Utils library.
Required: Run a custom timer job once a day to get the list of user emails (require to fetch and compare data from UserProfile) to send notifications.
I've managed to get timer job running and fetching membership data, however I'm failing to fetch user profile details for a given user.
My owstimer.exe.config looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<connectionStrings>
<remove name="Test-FBA" />
<add connectionString="Data source=(local)\Sharepoint;Integrated Security=True;Initial Catalog=Test_dev;" name="Test-FBA" />
</connectionStrings>
<system.web>
<compilation>
<assemblies>
<add assembly="Test.UserUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5f674de4cd3d93d8" />
</assemblies>
</compilation>
<httpModules>
<add name="Profile" type="System.Web.Profile.ProfileModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="ProfileBase" type="System.Web.Profile.ProfileBase, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpModules>
<membership defaultProvider="FBAMembershipProvider">
<providers>
<clear/>
<add name="FBAMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
applicationName="/" connectionStringName="Test-FBA" enablePasswordReset="true"
enablePasswordRetrieval="true" passwordFormat="Clear" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="3" minRequiredNonalphanumericCharacters="0" />
</providers>
</membership>
<roleManager cacheRolesInCookie="false" defaultProvider="FBARoleProvider" enabled="true">
<providers>
<clear/>
<add name="FBARoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
applicationName="/" connectionStringName="Test-FBA" />
</providers>
</roleManager>
<profile enabled="true" defaultProvider="SqlProfileProvider" inherits="Test.UserUtils.UserProfile, Test.UserUtils">
<providers>
<clear/>
<add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="Test-FBA" />
</providers>
<properties>
</properties>
</profile>
<authentication mode="Forms">
<forms loginUrl="~/_layouts/FBA/Login.aspx" />
</authentication>
</system.web>
</configuration>
When I try to access UserProfile from timerjob class, i.e.
UserProfile profile = UserProfile.GetProfile(memberuser.UserName);
I get this error: Could not load file or assembly 'Test.Utils' or one of its dependencies. The system cannot find the file specified.
What I've tried: - This assembly is in the GAC. - I've stopped the SP timer, deployed the solution, restarted the timer to attach to the OWSTimer process - I've rebooted the IIS
Do I miss something else?
Thanks in advance!
Galiya
-- Update 13/09
First comments made me change the structure a bit. Now I have Test.UserUtils which don't reference to any custom DLLs except System and Sharepoint- related ones.
I have updated my OWSTimer.config.exe above to reflect my latest (still not working) version.
ULS Viewer provides me with the following error:
Exception stack trace:
at System.Web.Profile.ProfileBase.InitializeStatic()
at System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated)
at Test.UserUtils.UserProfile.GetProfile(String username)
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.GetListRegisteredUsers(SPSite site, String connectionString)
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.GetListOfConfirmedSubscribers(String alertSectorsAsString, SPSite site, String connectionString)
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.Execute(Guid contentDbId)
at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result)
The code still fails at the call to UserProfile:
using System.Web.Profile;
namespace Test.UserUtils
{
public class UserProfile: ProfileBase
{
public static UserProfile GetProfile(string username)
{
**return Create(username, true) as UserProfile;** <- fails here
}
}
}