We have some custom code to send emails out when submitting an item from one workflow state to another and it seems to be sending items to users who have been disabled. I've been trying to find a way to check on the enabled/disabled status of a user, but haven't had much luck. Here is the code:

public class UserFunctions
    public static List<User> ContentAdminsFor(Item i)
        if (i == null) return null;

        var users = new List<User>();

        var contentAdmins = RolesInRolesManager.GetUsersInRole(Role.FromName(@"org\Workflow Admin"), true);

        var orgRoot = Utils.GetRoot(i);

        foreach(var user in contentAdmins)
            using (new UserSwitcher(user))
                if (orgRoot.Access.CanWrite())

        return users;
| improve this question | | | | |

You can get this info the other way around. Check the !user.IsApproved property. But first you need to get the user through the membership provider like this:

var provider = System.Web.Security.Membership.Provider;
var user = provider.GetUser(username, false);
if (!user.IsApproved)
| improve this answer | | | | |
  • That isn't showing up as an option - only user.isAdministrator, isAuthenticated, and isInRole. – Levi Wallach Aug 9 '19 at 15:30
  • 1
    @LeviWallach I updated my answer, you need to use the membership provider to get the membership user. – Tamás Tárnok Aug 9 '19 at 15:33

I think Sitecore PowerShell Extensions could help address both the workflow action feature, as well as finding the users.

The following query would provide enabled users in a given domain:

Get-User -Filter "training\*" | Where-Object { $_.IsEnabled }

enter image description here

The following query provides enabled users in a given role:

Get-RoleMember -Identity "training\editor" | Where-Object { $_.IsEnabled }

enter image description here

| improve this answer | | | | |
  • Thanks, but I'm currently dealing with an issue on our development server where changes to things made my PSE Scripts work initially but then revert, so for now I think I'll be going with a code solution... – Levi Wallach Aug 9 '19 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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