Hi,
upgrading an old site from to 8.9.x.x i have an issue in a user syncronization method, where a user is supposed to be deleted if conditions are met:
UserCollection usersInGroup = User.GetUsersByGroupID(groupId);
foreach (User user in usersInGroup) {
if (true) //let's pretend the conditions are met
{
user.Delete();
Here it breaks on:
[Exception: You do not have the required rights to edit user permissions] Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object Description, Object HelpFile, Object HelpContext) +597 Dynamicweb.eCommerce.UserPermissions.UserPermission.DeleteRights(Int32 UserID) +142 Dynamicweb.Modules.UserManagement.User.Delete() +89
It will break when the code is run on a scheduled task, and it will break if run logged in as administrator. eCommerce is NOT in use on the site.
I tried doing login of a "service user" before excecuting:
Dynamicweb.Security security = new Dynamicweb.Security();
security.ExtranetLogin("Administrator", "thepassword");
But that does not help.
Any suggestions on how to make this work again?