Skip to content

ldapster/OpenDSRest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

RESTFul API for handler for OpenDS.

Author: Mike Dugan

BUILDING

0. Download, build and test OpenDS.

1. Download Jersey Jars.

Download this zip from Jersey distribution:

http://download.java.net/maven/2/com/sun/jersey/jersey-archive/1.3/jersey-archive-1.3.zip

Unzip and copy all jars in "jersey-archive-1.3/lib" into "opends/lib" source directory.
Files are:
	
	asm-3.1.jar      
	jersey-json-1.3.jar
	jackson-core-asl-1.1.1.jar 
	jersey-server-1.3.jar
	jersey-client-1.3.jar      
	jettison-1.1.jar
	jersey-core-1.3.jar        
	jsr311-api-1.1.1.jar

2. Download Grizzley Jar.

Download grizzly embedded servlet container:

http://download.java.net/maven/glassfish/com/sun/grizzly/grizzly-servlet-webserver/1.9.18-k/grizzly-servlet-webserver-1.9.18-k.jar

Copy to "opends/lib" source directory

3. Re-build OpenDS and start server.

CONFIGURATION

1. Add objectclass found in schema/http_schema.ldif

ldapmodify.bat -c -a -p 4444 -D "cn=directory manager" -w password -X --useSSL -f http_schema.ldif

Stop server
 
1. Non-SSL configuration of OpenDS RestFUL API handler.

Open an editor and add this stanza after LDAPS stanza config.ldif:

dn: cn=HTTP Connection Handler,cn=Connection Handlers,cn=config
objectClass: top
objectClass: ds-cfg-connection-handler
objectClass: ds-cfg-http-connection-handler
cn: HTTP Connection Handler
ds-cfg-java-class: org.opends.server.protocols.http.HTTPConnectionHandler
ds-cfg-enabled: true
ds-cfg-listen-port: 8080
ds-cfg-identity-mapper: cn=Exact Match,cn=Identity Mappers,cn=config

Note: change the port if needed.

2. Re-start the server

3. Test. Add some entries with passwords:

ldapmodify.bat -c -a  -D "cn=directory manager" -w password  -f ex.ldif

head ex.ldif

dn: dc=example,dc=com
objectClass: top
objectClass: domain
dc: example

dn: ou=People,dc=example,dc=com
objectClass: top
objectClass: organizationalunit
ou: People

dn: uid=user.0,ou=People,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalperson
objectClass: inetorgperson
givenName: Aaccf
sn: Amar
cn: Aaccf Amar
initials: ASA
employeeNumber: 0
uid: user.0
mail: user.0@example.com
userPassword: password
telephoneNumber: +1 294 867 8160
homePhone: +1 078 441 7013
pager: +1 973 405 8217 begin_of_the_skype_highlighting              +1 973 405 8217      end_of_the_skype_highlighting
mobile: +1 260 148 0630
street: 24672 Davis Street
l: Flint
st: TX
postalCode: 43306
postalAddress: Aaccf Amar$24672 Davis Street$Flint, TX  43306
description: This is the description for Aaccf Amar.

dn: uid=user.1,ou=People,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalperson
objectClass: inetorgperson
givenName: Aaren
sn: Atp
cn: Aaren Atp
initials: ALA
employeeNumber: 1
uid: user.1
mail: user.1@example.com
userPassword: password
telephoneNumber: +1 776 003 5757
homePhone: +1 405 589 1050
pager: +1 557 202 7946
mobile: +1 665 568 0659
street: 51093 Green Street
l: Flint
st: CT
postalCode: 20660
postalAddress: Aaren Atp$51093 Green Street$Flint, CT  20660
description: This is the description for Aaren Atp.

...

Download a copy of cURL from: http://curl.haxx.se/download.html

SEARCHING

Using the default values:
curl -u user.0:password "http://localhost:8080/directory/search?base=dc=example,dc=com"
{"dc=example,dc=com":{"dn":"dc=example,dc=com","objectclass":["domain","top"],"attributes":{"dc":"example"}}}

Specifying a scope of sub:
curl -u user.0:password "http://localhost:8080/directory/search?base=dc=example,dc=com&scope=sub"
...

Specifying a scope of one and filter of (uid=fost*):
curl -u user.0:password "http://localhost:8080/directory/search?base=dc=example,dc=com&filter=(uid=fost*)&scope=one"
...

Specifying a scope of one, filter of (uid=fost*) and return cn, sn attributes:
curl -u user.0:password "http://localhost:8080/directory/search?base=dc=example,dc=com&filter=(uid=fost*)&scope=sub&attrs=cn,sn"

The default are the same as ldapsearch:

scope: base
filter: (objectclass=*)
attrs: all

DELETE an entry:

Assumes there is a uid=user.5 entry in the directory and that user has delete ACI. The delete ACI is
important.

curl -X DELETE -u user.5:password "http://localhost:8080/directory/uid=user.2,ou=people,dc=example,dc=com"

== 
ADD an entry in JSON format to the directory using curl.
	- Assumes there is a uid=user.5 entry in the directory and that user has add ACI.
	- Again the add ACI is important. 
	- The file json.out2 contains the json format of the entry.

curl -v -H "Content-Type: application/json" -X POST -d @json.out2 -u user.5:password "http://localhost:8080/directory/add"

cat json.out2:
{"dn":"uid=user.555,ou=People,dc=example,dc=com",
"objectclass":["person","inetorgperson","organizationalperson","top"],
"attributes":[
{"postalAddress":"Abagail Abadines$73160 Eleventh Street$Charlotte, NH  51997"},
{"postalCode":"51997"},{"description":"This is the description for Abagail Abadines."},
{"uid":"user.555"},{"userPassword":"password"},{"employeeNumber":"6"},{"initials":"AWA"},
{"givenName":"Abagail"},{"pager":"+1 120 345 8065"},{"mobile":"+1 808 056 4376 begin_of_the_skype_highlighting              +1 808 056 4376      end_of_the_skype_highlighting"},
{"cn":"Abagail Abadines"},{"telephoneNumber":"+1 994 686 5918"},{"sn":"Abadines"},
{"street":"73160 Eleventh Street"},
{"homePhone":"+1 356 416 7060"},{"l":"Charlotte"},
{"mail":"user.6@example.com"},{"st":"NH"}
]}

==
Modify in progress.

==
SSL is supported, directions are being written.

About

Restful API for OpenDS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages