update readme

This commit is contained in:
yo 2022-11-12 20:53:12 +01:00
parent 6c73cc8b76
commit 7879f3df08

View File

@ -1,7 +1,8 @@
# glapi
Go Ldap API is an HTTP API to an LDAP backend.
Only supporting read at the moment, maybe one day it will write, and break LDAP backends with ease and joy!
Only supporting read at the moment, maybe one day it will write, and break LDAP backends with ease and joy!
UPDATE: Yay, the day has come!
## Usage
Start glapi with parameters on command line:
@ -33,6 +34,7 @@ SSL_PRIVATE_KEY=/etc/ssl/private/server.key
```
## Querying API
### Search entries
Search LDAP entries through the whole subtree, specifying organizationalUnit, commnName, objectClass, attribute to retrieve.
Each of these parameters can be replaced by "ALL" to act like a wildcard.
```
@ -175,7 +177,7 @@ hasSubordinates: FALSE
[...]
```
### Output format
#### Output format
Default output is in json. The following formats are supported:
- json (default)
- text (ini style)
@ -215,7 +217,7 @@ uid: yo
```
### Select attributes to get
#### Select attributes to get
You can select attributes to get by adding them in 4th position :
```
% curl -u admin:admin "http://127.0.0.1:8080/ou=domains/yo/person/mail?format=textvalue"
@ -225,3 +227,31 @@ yo@example.org
% curl -u admin:admin "http://127.0.0.1:8080/ou=domains/yo/person/mail?format=textvalue-nodn"
yo@example.org
```
### Create entries
Create a new OU =users", then a new user :
```
% curl -u "admin:admin" --header "Content-Type: application/json" -X POST
--data '{"objectClass":["organizationalUnit","top"],"ou":"users"' \
https://127.0.0.1:8443/ou=users,dc=example,dc=org
% curl -u "admin:admin" --header "Content-Type: application/json" -X POST
--data '{"objectClass":["person","top"],"cn":"newuser","sn":"New"}' \
https://127.0.0.1:8443/cn=newuser,ou=users,dc=example,dc=org
```
### Modify entries
Add a description to the new account:
```
% curl -u "admin:admin" --header "Content-Type: application/json" -X PUT
--data '{"objectClass":["person","top"],"cn":"newuser","sn":"New","description":"Test account"}' \
https://127.0.0.1:8443/cn=newuser,ou=users,dc=example,dc=org
```
Missing attributes will be removed from entry.
### Delete entries
Remove newuser :
```
% curl -u "admin:admin" -X DELETE \
https://127.0.0.1:8443/cn=newuser,ou=users,dc=example,dc=org
```