Friday, November 8, 2013

OpenDJ Rest API

I had some free time this week, so I continued to explore the Rest2Ldap interface in OpenDJ 2.6.0.


It was fun as this is something new to me. I'm not really a REST/JSON guy. I leave it to our younger colleagues. Ha!

So I was having fun until I hit into the following problem when I attempted to list all users whose user names contains "user.200". 


{"code":400,"reason":"Bad Request","message":"The value 'userName co user.200' for parameter '_queryFilter' could not be parsed as a valid query filter"} ...

What's that? I was fairly sure I typed words by words from the examples in OpenDJ Administration Guide.

After a while, I spent some more time reading the documentation again and found out how silly I was.



Make sure you URL encode the filter expressions! Ok, so sorry.

So I downloaded Simple REST Client add-on for my Chrome and that solved the issue.



Overall, I found it a refreshing way to query a LDAP server which traditionally has to go via the LDAP connection route. e.g. if you write a Java class, you would need to query a LDAP server via Java LDAP Programming/API. And most likely, you'll need to download and deploy LDAP SDK onto the web container.

By using REST API, there is no more hassle. A much cleaner way for modern developers who are very well-versed in REST/JSON.


.


No comments:

Post a Comment