Json2Ldap with improved directory search

Json2Ldap iconJson2Ldap 1.5 is out.

The most recent release of the web gateway for connecting to LDAP v4 compatible directories via JSON-RPC delivers several incremental improvements, the most notable being the expanded capabilities of the ldap.search command. It now gives programmers finer control over the entry attributes which the method returns.

The available choices:

  • Return all user attributes.
  • Return all operational attributes (attributes associated with a directory object for administrative purposes).
  • Return only the specified attributes.
  • Don’t return any attributes.

Let’s illustrate these choices with a few example JSON-RPC 2.0 requests/responses.

First, connect to the default remote directory with ldap.connect.

The connect request:

{ "method"  : "ldap.connect",
  "id"      : 1,
  "jsonrpc" : "2.0" }

The connect response, returning a string token to identify the LDAP connection (CID = connection identifier) in later requests:

{ "result"  : "-31ccd4bdbe6170b69956fe1c2eeffb42", 
  "id"      : 1,
  "jsonrpc" : "2.0" }

Example 1: Return all user attributes.

This is the default action. To do that simply omit the attributes parameter (or set it to “*”).

The request:

{ "method" : "ldap.search",
  "params" : { "CID"    : "-31ccd4bdbe6170b69956fe1c2eeffb42",
               "scope"  : "ONE",
               "baseDN" : "ou=people,dc=example,dc=com",
	       "filter" : "(uid=user.0)" },
  "id":1,
  "jsonrpc" : "2.0" }

The response:

{ "result"  : { "matches" : [ { "DN"          : "uid=user.0,ou=People,dc=example,dc=com",
                                "objectClass" : [ "person",
						  "inetorgperson",
						  "organizationalperson",
						  "top"],
			        "uid"         : ["user.0" ],
				"cn"          : ["Aaccf Amar"],
				"sn"          : ["Amar"],
				"givenName"   : ["Aaccf"],
				"initials"    : ["ASA"],
				"mail"        : ["user.0@maildomain.net"],
				"street"      : ["0125 Chestnut Street"],
				"l"           : ["Panama City"],
				"mobile"      : ["+1 010 154 3228"] } ],
                "referrals" : [] },
  "id"      : 1,						
  "jsonrpc" : "2.0" }

Example 2: Return all operational attributes

Set the attributes parameter to “+”:

The request:

{ "method" : "ldap.search",
  "params" : { "CID"        : "-31ccd4bdbe6170b69956fe1c2eeffb42",
               "scope"      : "ONE",
               "baseDN"     : "ou=people,dc=example,dc=com",
	       "filter"     : "(uid=user.0)",
	       "attributes" : "+" },
  "id":1,
  "jsonrpc" : "2.0" }

The response:

{ "result"  : { "matches" : [ { "DN"                : "uid=user.0,ou=People,dc=example,dc=com",
                                "subschemaSubentry" : ["cn=schema"],
			        "entryUUID"	    : ["ad55a34a-763f-358f-93f9-da86f9ecd9e4"],
			        "entryDN"	    : ["uid=user.0,ou=people,dc=example,dc=com"],
			        "modifiersName"     : ["cn=Directory Manager,cn=Root DNs,cn=config"],
			        "modifyTimestamp"   : ["20100622033521Z"] } ],
                "referrals" : [] },
  "id"      : 1,						
  "jsonrpc" : "2.0" }

Example 3: Return only the specified attributes

Set the attributes parameter to a string listing the required attribute names.

The request:

{ "method" : "ldap.search",
  "params" : { "CID"        : "-31ccd4bdbe6170b69956fe1c2eeffb42",
               "scope"      : "ONE",
               "baseDN"     : "ou=people,dc=example,dc=com",
	       "filter"     : "(uid=user.0)",
	       "attributes" : "cn mail" },
  "id":1,
  "jsonrpc" : "2.0" }

The response:

{ "result"  : { "matches" : [ { "DN"   : "uid=user.0,ou=People,dc=example,dc=com",
                                "cn"   : ["Aaccf Amar"],
				"mail" : ["user.0@maildomain.net"] } ],
                "referrals" : [] },
  "id"      : 1,						
  "jsonrpc" : "2.0" }

Example 4: Don’t return any attributes

Set the attributes parameter to an empty string.

The request:

{ "method" : "ldap.search",
  "params" : { "CID"        : "-31ccd4bdbe6170b69956fe1c2eeffb42",
               "scope"      : "ONE",
               "baseDN"     : "ou=people,dc=example,dc=com",
	       "filter"     : "(uid=user.0)",
	       "attributes" : "" },
  "id":1,
  "jsonrpc" : "2.0" }

The response:

{ "result"  : { "matches"   : [ { "DN" : "uid=user.0,ou=People,dc=example,dc=com" } ],
                "referrals" : [] },
  "id"      : 1,						
  "jsonrpc" : "2.0" }

So, what’s next on the Json2Ldap roadmap? HTTP Cross-Origin Resource Sharing (CORS) support!