2

i am trying to delete extranet users through code. (same functionality that is in user manager)

Code:

User user = User.FromName(username, true);

user.Delete();

i am not getting any error but user is also not getting deleted either.

any suggestions.

thanks,

1
  • how are you passing username? are you adding the domain as well with username? Oct 5, 2021 at 14:49

1 Answer 1

0

You need to pass domain name with a user name like below code :

string domainUser = @"domain\user";

if (Sitecore.Security.Accounts.User.Exists(domainUser))
{

 Sitecore.Security.Accounts.User user =
 Sitecore.Security.Accounts.User.FromName(domainUser,true);
 user.Delete();

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.