Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using the crowd client api 2.2.2, and trying to query for all inactive users (Boolean) fails

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.

2 answers

0 votes

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:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;user name="username" expand="attributes"&gt;
  &lt;first-name&gt;First&lt;/first-name&gt;
  &lt;last-name&gt;Last&lt;/last-name&gt;
  &lt;display-name&gt;First Last&lt;/display-name&gt;
  &lt;email&gt;email@email.com&lt;/email&gt;
  &lt;active&gt;true&lt;/active&gt;
  &lt;attributes&gt;
    &lt;link rel="self" href="link_to_user_attributes"/&gt;
  &lt;/attributes&gt;
  &lt;password&gt;
    &lt;link rel="edit" href="link_to_user_password"/&gt; &lt;!-- /user/password?username=&lt;username&gt; --&gt;
    &lt;value&gt;password&lt;/value&gt; &lt;!-- only used when creating a user, otherwise not filled in --&gt;
  &lt;/password&gt;
&lt;/user&gt;

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?

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

181 views 6 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you