We are trying to query crowd for inactive users:
{code}
Collection<searchrestriction> restrictions = new ArrayList<searchrestriction>();
TermRestriction<boolean> test = new TermRestriction<boolean>(UserTermKeys.ACTIVE, MatchMode.EXACTLY_MATCHES, new Boolean(false));
restrictions.add(test);
List<user> tmp = crowdClient.searchUsers(Combine.allOf(restrictions), 0, 1000);
{code}
This give the following error:
{code}
2011-10-31 11:05:23,804 ERROR CrowdUserAccessorDaoImpl:159 - Operation Failed Exception with message Boolean restrictions for property active are not supported
com.atlassian.crowd.exception.OperationFailedException: Boolean restrictions for property active are not supported
at com.atlassian.crowd.integration.rest.service.RestCrowdClient.handleCommonExceptions(RestCrowdClient.java:1084)
at com.atlassian.crowd.integration.rest.service.RestCrowdClient.searchUsers(RestCrowdClient.java:466)
at aero.blue.user.dao.crowd.CrowdUserAccessorDaoImpl.fetchUsers(CrowdUserAccessorDaoImpl.java:147)
{code}
Note that we have the same issue with Date restrictions.
The trouble though Jeremy is that active is not an attribute of the user but rather some arbitrary property. I've attempted to do something similar here too, but have had to resort to testing for the presense of the active property once fetching the users.
Here's the code from com.atlassian.crowd.search.ldap.LDAPQueryTranslaterImpl:
private Filter booleanTermRestrictionAsFilter(final EntityDescriptor entityDescriptor, final PropertyRestriction<Boolean> termRestriction, LDAPPropertiesMapper ldapPropertiesMapper) { // if boolean term restrictions are for anything other than the group/user active flag, then throw exception if (termRestriction.getProperty() != GroupTermKeys.ACTIVE && termRestriction.getProperty() != UserTermKeys.ACTIVE) { throw new IllegalArgumentException("Boolean restrictions for property " + termRestriction.getProperty().getPropertyName() + " are not supported"); } else ... }
So, it looks like you can't define your own TermRestriction, as it won't match that comparison.
Instead, why not get all users, then query to see if they're active?
From the REST Resources:
<?xml version="1.0" encoding="UTF-8"?> <user name="username" expand="attributes"> <first-name>First</first-name> <last-name>Last</last-name> <display-name>First Last</display-name> <email>email@email.com</email> <active>true</active> <attributes> <link rel="self" href="link_to_user_attributes"/> </attributes> <password> <link rel="edit" href="link_to_user_password"/> <!-- /user/password?username=<username> --> <value>password</value> <!-- only used when creating a user, otherwise not filled in --> </password> </user>
Looks like there's a 'active' attribute there. Maybe you can use that, and assemble a list by adding it to a data structure after iterating through all the users?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.