Can anyone tell me how to delete a SharePoint user profile remotely? I don't see a way to do this using SharePoint Web Services or User Profile Services. The following code works fine when run on the SharePoint server but will not work remotely. When it tries to the run the constructor for SPSite it throws an error about not being able to find Microsoft.Sharepoint.Intl which is in the GAC on the SharePoint server.
using (new Person.Utilities.Impersonation.Impersonator("sharepoint.service", "fakeDomain", "fakePassword", Person.Utilities.Impersonation.LogonType.LOGON32_LOGON_NEW_CREDENTIALS, Person.Utilities.Impersonation.LogonProvider.LOGON32_PROVIDER_WINNT50))
{
using (SPSite site = new SPSite("https://www.mySharepointSite.com/"))
{
ServerContext context = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
if (profileManager.UserExists(username))
{
profileManager.RemoveUserProfile(username);
}
}
}