public override String[] GetUsersInRole(String roleName)
    {
        if (String.IsNullOrEmpty(roleName))
        {
            throw new ProviderException("Role name cannot be empty or null.");
        }
        if (!RoleExists(roleName))
        {
            throw new ProviderException("Role does not exist.");
        }

        string[] users;

        using (Session session = XpoHelper.GetNewSession()) {
            XPView xpvUsers = new XPView(session, typeof(XpoUser),
                                         new CriteriaOperatorCollection()
            {
                OperandProperty.Parse("UserName")
            },
                                         new GroupOperator(
                                             GroupOperatorType.And,
                                             new BinaryOperator("ApplicationName", ApplicationName, BinaryOperatorType.Equal),
                                             new ContainsOperator("Roles", new BinaryOperator("RoleName", roleName, BinaryOperatorType.Equal))));

            List <String> usersList = new List <String>();
            for (int i = 0; i < xpvUsers.Count; i++)
            {
                usersList.Add(xpvUsers[i][0].ToString());
            }
            users = usersList.ToArray();
        }

        return(users);
    }
    public override String[] GetRolesForUser(String username)
    {
        if (String.IsNullOrEmpty(username))
        {
            throw new ProviderException("User name cannot be empty or null.");
        }

        String[] roles;

        using (Session session = XpoHelper.GetNewSession()) {
            XPView xpvRoles = new XPView(session, typeof(XpoRole),
                                         new CriteriaOperatorCollection()
            {
                OperandProperty.Parse("RoleName")
            },
                                         new GroupOperator(
                                             GroupOperatorType.And,
                                             new BinaryOperator("ApplicationName", ApplicationName, BinaryOperatorType.Equal),
                                             new ContainsOperator("Users", new BinaryOperator("UserName", username, BinaryOperatorType.Equal))));
            List <String> rolesList = new List <String>();
            for (int i = 0; i < xpvRoles.Count; i++)
            {
                rolesList.Add(xpvRoles[i][0].ToString());
            }
            roles = rolesList.ToArray();
        }

        return(roles);
    }
    public override String[] FindUsersInRole(String roleName, String userNameToMatch)
    {
        String[] users;

        if (!RoleExists(roleName))
        {
            throw new ProviderException("Role does not exist.");
        }

        using (Session session = XpoHelper.GetNewSession()) {
            CriteriaOperator theCriteria = CriteriaOperator.Parse("ApplicationName = ? and contains(UserName, ?) and Roles[RoleName = ?]", ApplicationName, userNameToMatch, roleName);
            XPView           xpvUsers    = new XPView(session, typeof(XpoUser), new CriteriaOperatorCollection()
            {
                OperandProperty.Parse("UserName")
            }, theCriteria);

            List <String> usersList = new List <String>();
            for (int i = 0; i < xpvUsers.Count; i++)
            {
                usersList.Add(xpvUsers[i][0].ToString());
            }
            users = usersList.ToArray();
        }

        return(users);
    }
    public override String[] GetAllRoles()
    {
        String[] roles;

        using (Session session = XpoHelper.GetNewSession()) {
            XPView xpvRoles = new XPView(session, typeof(XpoRole),
                                         new CriteriaOperatorCollection()
            {
                OperandProperty.Parse("RoleName")
            },
                                         new BinaryOperator("ApplicationName", ApplicationName, BinaryOperatorType.Equal));

            List <String> rolesList = new List <String>();
            for (int i = 0; i < xpvRoles.Count; i++)
            {
                rolesList.Add(xpvRoles[i][0].ToString());
            }
            roles = rolesList.ToArray();
        }

        return(roles);
    }