The latest 1.8.1 release of the directory web service Json2Ldap adds a new JSON-RPC method for validating search filters. It can be used for example to check user input filter strings before making an actual
ldap.search
request.
This is a simple utility method that takes just one parameter – the filter string. Note that an LDAP connection is not required for this operation, so no CID (connection identifier) needs to be passed.
Example JSON request:
{ "method" : "ldap.util.isValidFilter", "params" : { "filter" : "&(objectClass=person)(givenName=Alice)" }, "id" : "0001", "jsonrpc" : "2.0" }
And here is the resulting JSON response indicating the filter was correct:
{ "result" : true, "id" : "0001", "jsonrpc" : "2.0" }
With this the “static” utility methods of Json2Ldap become five. The other served requests are:
- Validate a directory distinct name (DN) with
ldap.util.isValidDN
. - Normalise a DN with
ldap.util.normalizeDN
. - Compare (order) two DNs with
ldap.util.compareDNs
. - Encode a search filter assertion value with
ldap.util.encodeFilterValue
.
The online Json2Ldap API docs have full details on these JSON calls.