There is no OOTB functionality to get users that can remove other users, but you can use some workarounds.
I suggest using an API call below to check if you have enough permissions to call the User Manager application for the current user:
SecurityHelper.CanRunApplication("Security/User Manager");
Then you can go through all users and you can use a similar code to check if the specified user can open the application:
List<Sitecore.Security.Accounts.User> powerUsers = Sitecore.Security.Accounts.UserManager.GetUsers()
.Where(user => CanRunApplication("Security/User Manager", user))
.ToList();
public static bool CanRunApplication([CanBeNull] string applicationName, [CanBeNull] Sitecore.Security.Accounts.User user)
{
if (user == null
|| applicationName.IsNullOrWhiteSpace())
{
return false;
}
if (!applicationName.StartsWith("/", StringComparison.InvariantCulture))
{
applicationName = "/sitecore/content/Applications/" + applicationName;
}
using (new UserSwitcher(user))
{
Sitecore.Data.Items.Item item;
using (new Sitecore.SecurityModel.SecurityDisabler())
{
item = Sitecore.Client.CoreDatabase.GetItem(applicationName);
}
return item != null && item.Access.CanRead();
}
}
Few points to highlight there:
- Actually, if you have read permissions to "/sitecore/content/Applications/Security/User Manager" item, then you can call this application.
- "New" and "Delete" buttons are always enabled.
So, if you have permission to open this application then you can create/delete users.