Problems to constrain a reference set selector with a Xpath constraint on userroles

7
I have a reference set selector for object System.User. I want to prevent other users to select users with userroles 'Developer' and MxAdministrator. Therefore, I set the following Xpath constraints: [System.UserRoles/System.UserRole/Name != 'MxAdministrator'] [System.UserRoles/System.UserRole/Name != 'Developer'] However, I'm still able to select users with these userroles. What is going wrong?
asked
4 answers
6

Floor, thanks for the suggestion. Instead of the Xpath in my question I tried:

[not(System.UserRoles/System.UserRole/Name = 'MxAdministrator')] [not(System.UserRoles/System.UserRole/Name = 'Developer')]

This works fine. However, I think the other way around should work as well since on a reference set selector with object System.Userrole I use Xpath constraints:

[Name != 'MxAdministrator'] [Name != 'Developer']

These Xpath constraints are working fine. Maybe someone from R&D can add a comment?

answered
3

Is the Xpath constraint set on the datagrid or the selector?

Make sure it is set on the selector and not on the grid. Hope this helps.

You can also try [not(Name='MxAdministrator)]

answered
3

Jornt,

The constraints that you propose in your own answer are the correct ones. These differ from the ones you proposed earlier as follows:

[System.UserRoles/System.UserRole/Name != 'MxAdministrator'] states that the User should have at least one user role of which the Name is not 'MxAdministrator' (this is generally true for most users).

[not(System.UserRoles/System.UserRole/Name = 'MxAdministrator')] states that the User should not have a user role called 'MxAdministrator' (which is the desired behavior in this case).

Of course, setting the constraint [Name != 'MxAdministrator] on a reference selector for UserRole will have the desired effect, as this constraint is applied directly to the UserRole objects.

answered
3

Sorry, this text has too many characters for a comment, so I post it as an answer.

Suppose we have the following query: //System.User[System.UserRoles/System.UserRole/Name = 'MxAdministrator']. With this query, you say: return all users from which each have at least one user role which name is 'MxAdministrator'.

Suppose we have the following query: //System.User[System.UserRoles/System.UserRole/Name != 'MxAdministrator']. With this query, you say: return all users from which each have at least one user role which name is not 'MxAdministrator'. When you have a user who has two roles, 'Employee' and 'MxAdministrator', then this user still is returned! The reason is that the user has the role 'Employee' and that name is not equal to 'MxAdministrator'.

This query really differs from the query: //System.User[not(System.UserRoles/System.UserRole/Name = 'MxAdministrator')]. In this case you say: return all users which does not have any association with the role 'MxAdministrator'.

answered