Search Google Appliance

Home >> Accounts >> Core User Directory >> CUD REST Query Examples

CUD REST Query Examples

The REST Interface user guide does also have some examples too, but some simple queries are shown here for starters.


  • You have a CUD service principal
  • You've created a keytab
  • You have curl installed on your server. 

Example query 

This example query searches for everyone that *currently* has an affiliation to your unit. 

If you run the query in the CUD UI (User Interface), below the results you will see some information text: Query Used.  This is always a very useful starting point when constructing any query that you might intend to use to query CUD via the REST interface.

E.g.   Query used:cud\:cas\:current_affiliation:lady

Note the backslashes: they will be required for the REST query.


On your server, at the command line
KRB5CCNAME=cudprincipalcache; kinit cud/<server>.<unit> -k -t <PathToKeytab>/<keytabFile>

Run an empty query, 

curl --negotiate -u : ''

And the output is, 


Now with an actual query...

curl --negotiate -u : '\:cas\:current_affiliation:lady'  

And, all being well, you should get the full results set written to the terminal window. Better to redirect to a file. 

curl --negotiate -u : '\:cas\:current_affiliation:lady'  >  results.csv

More options

Note that there are default fields included in the output (see the empty query, above) and that the default output is csv.  These can be changed,  but for now this page is just looking at some examples to get you started.  

The AND and OR operators are available..  

curl --negotiate -u : '\:cas\:lastname:Bloggs AND cud\:cas\:firstname:Joe'  >  results.csv
Combine with brackets to limit your results further
curl --negotiate -u : '\:cas\:lastname:Bloggs AND (cud\:cas\:firstname:Joe OR cud\:cas\:firstname:Kate)' > results.csv
If you have access to the University Card end-date attribute, you can query for date ranges, but you will need to escape the square bracket range limiters.
curl --negotiate -u : '\:uas\:universitycard_comp_date:\[NOW TO *\]'  >  results.csv
That query returns everyone with a current university card so you may not want to run that query! Not without some extra parameters, anyway, to cut down the number of results. 

Written by IT Services. Latest revision 20 February 2017