I'm trying to kick off the user profile syc using a web service. Here is what i've tried :
[WebMethod]
public string runUserProfileService()
{
var message = "";
using (SPSite site = new SPSite("http://servernamehere/"))
{
site.AllowUnsafeUpdates = true;
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
if (!upcm.IsSynchronizationRunning())
{
try
{
upcm.StartSynchronization();
message = "running";
return message;
}
catch (Exception ex)
{
message = ex.Message;
return message;
}
}
message = "running";
}
return message;
}
Here is the exception that I continue to get:
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Any help would be appreciated.
thanks,