Deleting a user error

Posted by Community Admin on 04-Aug-2018 14:41

Deleting a user error

All Replies

Posted by Community Admin on 26-Nov-2013 00:00

Hello everyone

I just wish to delete a user from Sitefinity and I am encountering the following error:

No data provider decorator could be found for the provider 'DynamicModule.ns.Wrapped_ValpakRoleDataProvider_ea66db37a0c74552869fecc7fd948a0b'. The method 'GetDirtyItems()' has to be overridden and implemented.

How would I go about deleting a user and/or implementing the GetDirtyItems() method?

Apologies if I'm being thick.

Posted by Community Admin on 29-Nov-2013 00:00

Hello Richard,

There is no need to apologize, we know that Sitefinity's learning curve can be steep. In general you do not need to use the GetDirtyItems method in order to delete a user. All you need to do is to get the user by a certain identifier, say Name, and then execute the Delete statement of our UserManager. The code below shows you just that:

public static void DeleteUser(string username)
    UserManager userManager = UserManager.GetManager();
    UserProfileManager profileManager = UserProfileManager.GetManager();
  
    User user = userManager.GetUsers().Where(u => u.UserName == username).SingleOrDefault();
  
    if (user != null)
    
        SitefinityProfile userProfile = profileManager.GetUserProfile<SitefinityProfile>(user);
  
        if (userProfile != null)
        
            profileManager.Delete(userProfile);
        
  
        userManager.Delete(user);
    
  
    profileManager.SaveChanges();
    userManager.SaveChanges();

 You can get a clear idea of how to Query users in our Documentation.

Regards,
Ivan D. Dimitrov
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Dec-2013 00:00

Hello Ivan 

Thank you very much for this information, I'll give it a go now and see how I get on.

Rich

This thread is closed