ldap-rest 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +48 -0
- package/bin/cleanup-external-users.mjs +219 -0
- package/bin/index.mjs +54 -0
- package/bin/sync-james.mjs +190 -0
- package/dist/abstract/ldapFlat.js +1 -0
- package/dist/abstract/plugin.js +1 -0
- package/dist/abstract/twakePlugin.js +1 -0
- package/dist/bin/index.js +1 -0
- package/dist/config/args.js +1 -0
- package/dist/lib/auth/base.js +1 -0
- package/dist/lib/authz/base.js +1 -0
- package/dist/lib/expressFormatedResponses.js +1 -0
- package/dist/lib/ldapActions.js +1 -0
- package/dist/lib/parseConfig.js +1 -0
- package/dist/lib/utils.js +1 -0
- package/dist/logger/winston.js +1 -0
- package/dist/plugins/auth/authzLinid1.js +1 -0
- package/dist/plugins/auth/authzPerBranch.js +1 -0
- package/dist/plugins/auth/crowdsec.js +1 -0
- package/dist/plugins/auth/llng.js +1 -0
- package/dist/plugins/auth/openidconnect.js +1 -0
- package/dist/plugins/auth/rateLimit.js +1 -0
- package/dist/plugins/auth/token.js +1 -0
- package/dist/plugins/configApi.js +1 -0
- package/dist/plugins/demo/helloworld.js +1 -0
- package/dist/plugins/ldap/bulkImport.js +1 -0
- package/dist/plugins/ldap/departmentSync.js +1 -0
- package/dist/plugins/ldap/externalUsersInGroups.js +1 -0
- package/dist/plugins/ldap/flatGeneric.js +1 -0
- package/dist/plugins/ldap/groups.js +1 -0
- package/dist/plugins/ldap/onChange.js +1 -0
- package/dist/plugins/ldap/organization.js +1 -0
- package/dist/plugins/ldap/trash.js +1 -0
- package/dist/plugins/priority.json.js +1 -0
- package/dist/plugins/static.js +1 -0
- package/dist/plugins/twake/calendarResources.js +1 -0
- package/dist/plugins/twake/james.js +1 -0
- package/dist/plugins/weblogs.js +1 -0
- package/dist/src/abstract/ldapFlat.d.ts +94 -0
- package/dist/src/abstract/plugin.d.ts +43 -0
- package/dist/src/abstract/twakePlugin.d.ts +90 -0
- package/dist/src/bin/index.d.ts +43 -0
- package/dist/src/browser/ldap-group-editor/LdapGroupEditor.d.ts +31 -0
- package/dist/src/browser/ldap-group-editor/api/GroupApiClient.d.ts +23 -0
- package/dist/src/browser/ldap-group-editor/components/CreateGroupModal.d.ts +19 -0
- package/dist/src/browser/ldap-group-editor/components/GroupPropertyEditor.d.ts +30 -0
- package/dist/src/browser/ldap-group-editor/components/GroupTree.d.ts +17 -0
- package/dist/src/browser/ldap-group-editor/components/MoveGroupModal.d.ts +20 -0
- package/dist/src/browser/ldap-group-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-group-editor/types.d.ts +58 -0
- package/dist/src/browser/ldap-resource-editor/api/ResourceApiClient.d.ts +53 -0
- package/dist/src/browser/ldap-resource-editor/cache/CacheManager.d.ts +65 -0
- package/dist/src/browser/ldap-resource-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-resource-editor/types.d.ts +78 -0
- package/dist/src/browser/ldap-tree-viewer/LdapTreeViewer.d.ts +26 -0
- package/dist/src/browser/ldap-tree-viewer/api/LdapApiClient.d.ts +30 -0
- package/dist/src/browser/ldap-tree-viewer/components/TreeNode.d.ts +17 -0
- package/dist/src/browser/ldap-tree-viewer/components/TreeRoot.d.ts +14 -0
- package/dist/src/browser/ldap-tree-viewer/index.d.ts +7 -0
- package/dist/src/browser/ldap-tree-viewer/store/Store.d.ts +18 -0
- package/dist/src/browser/ldap-tree-viewer/store/actions.d.ts +28 -0
- package/dist/src/browser/ldap-tree-viewer/store/reducers.d.ts +7 -0
- package/dist/src/browser/ldap-tree-viewer/types.d.ts +34 -0
- package/dist/src/browser/ldap-unit-editor/LdapUnitEditor.d.ts +27 -0
- package/dist/src/browser/ldap-unit-editor/api/UnitApiClient.d.ts +24 -0
- package/dist/src/browser/ldap-unit-editor/components/MoveUnitModal.d.ts +28 -0
- package/dist/src/browser/ldap-unit-editor/components/UnitPropertyEditor.d.ts +28 -0
- package/dist/src/browser/ldap-unit-editor/components/UnitTree.d.ts +18 -0
- package/dist/src/browser/ldap-unit-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-unit-editor/types.d.ts +55 -0
- package/dist/src/browser/ldap-user-editor/LdapUserEditor.d.ts +32 -0
- package/dist/src/browser/ldap-user-editor/api/UserApiClient.d.ts +55 -0
- package/dist/src/browser/ldap-user-editor/cache/CacheManager.d.ts +65 -0
- package/dist/src/browser/ldap-user-editor/components/MoveUserModal.d.ts +28 -0
- package/dist/src/browser/ldap-user-editor/components/PointerField.d.ts +22 -0
- package/dist/src/browser/ldap-user-editor/components/UserEditor.d.ts +46 -0
- package/dist/src/browser/ldap-user-editor/components/UserList.d.ts +24 -0
- package/dist/src/browser/ldap-user-editor/components/UserTree.d.ts +24 -0
- package/dist/src/browser/ldap-user-editor/index.d.ts +7 -0
- package/dist/src/browser/ldap-user-editor/types.d.ts +67 -0
- package/dist/src/browser/shared/components/Modal.d.ts +38 -0
- package/dist/src/browser/shared/components/StatusMessage.d.ts +48 -0
- package/dist/src/browser/shared/index.d.ts +10 -0
- package/dist/src/browser/shared/types/index.d.ts +65 -0
- package/dist/src/browser/shared/utils/dom.d.ts +33 -0
- package/dist/src/browser/shared/utils/form.d.ts +28 -0
- package/dist/src/browser/shared/utils/schema.d.ts +29 -0
- package/dist/src/config/args.d.ts +128 -0
- package/dist/src/config/schema.d.ts +18 -0
- package/dist/src/hooks.d.ts +76 -0
- package/dist/src/lib/auth/base.d.ts +9 -0
- package/dist/src/lib/authz/base.d.ts +63 -0
- package/dist/src/lib/expressFormatedResponses.d.ts +26 -0
- package/dist/src/lib/ldapActions.d.ts +91 -0
- package/dist/src/lib/parseConfig.d.ts +23 -0
- package/dist/src/lib/utils.d.ts +73 -0
- package/dist/src/logger/winston.d.ts +3 -0
- package/dist/src/plugins/auth/authzLinid1.d.ts +46 -0
- package/dist/src/plugins/auth/authzPerBranch.d.ts +59 -0
- package/dist/src/plugins/auth/crowdsec.d.ts +29 -0
- package/dist/src/plugins/auth/llng.d.ts +8 -0
- package/dist/src/plugins/auth/openidconnect.d.ts +11 -0
- package/dist/src/plugins/auth/rateLimit.d.ts +24 -0
- package/dist/src/plugins/auth/token.d.ts +17 -0
- package/dist/src/plugins/configApi.d.ts +24 -0
- package/dist/src/plugins/demo/helloworld.d.ts +12 -0
- package/dist/src/plugins/ldap/bulkImport.d.ts +48 -0
- package/dist/src/plugins/ldap/departmentSync.d.ts +35 -0
- package/dist/src/plugins/ldap/externalUsersInGroups.d.ts +21 -0
- package/dist/src/plugins/ldap/flatGeneric.d.ts +31 -0
- package/dist/src/plugins/ldap/groups.d.ts +95 -0
- package/dist/src/plugins/ldap/onChange.d.ts +32 -0
- package/dist/src/plugins/ldap/organization.d.ts +65 -0
- package/dist/src/plugins/ldap/trash.d.ts +52 -0
- package/dist/src/plugins/static.d.ts +7 -0
- package/dist/src/plugins/twake/calendarResources.d.ts +31 -0
- package/dist/src/plugins/twake/james.d.ts +83 -0
- package/dist/src/plugins/weblogs.d.ts +8 -0
- package/docs/DEVELOPER_GUIDE.md +298 -0
- package/docs/OPENAPI.md +440 -0
- package/docs/PLUGIN_DEPENDENCIES.md +612 -0
- package/docs/README.md +466 -0
- package/docs/api/REFERENCE.md +983 -0
- package/docs/api/REST_API.md +1237 -0
- package/docs/authentication.md +469 -0
- package/docs/authzLinid1.md +521 -0
- package/docs/authzPerBranch.md +596 -0
- package/docs/browser/LIBRARIES.md +1196 -0
- package/docs/examples/EXAMPLES.md +1659 -0
- package/docs/examples/twake-mailbox-type-nomenclature.ldif +37 -0
- package/docs/examples/twake-mailbox-type-schema-amendment.ldif +30 -0
- package/docs/jamesTeamMailboxes.md +343 -0
- package/docs/ldapBulkImport.md +722 -0
- package/docs/ldapExternalUsersInGroups.md +325 -0
- package/docs/ldapFlatGeneric.md +444 -0
- package/docs/ldapGroups.md +589 -0
- package/docs/ldapOrganizations.md +659 -0
- package/docs/ldapTrash.md +260 -0
- package/docs/linagora.png +0 -0
- package/docs/onChange.md +318 -0
- package/docs/plugins/DEVELOPMENT.md +1219 -0
- package/docs/presenterm-fr.md +721 -0
- package/docs/presenterm.md +721 -0
- package/docs/schemas/SCHEMAS.md +1212 -0
- package/docs/static.md +410 -0
- package/docs/twakeCalendarResources.md +148 -0
- package/docs/twakeJames.md +661 -0
- package/docs/weblogs.md +399 -0
- package/examples/web/ldap-group-editor.html +113 -0
- package/examples/web/ldap-tree-viewer.html +368 -0
- package/examples/web/ldap-unit-editor.html +108 -0
- package/examples/web/ldap-user-editor.html +412 -0
- package/package.json +458 -0
- package/static/browser/common-demo.css +450 -0
- package/static/browser/ldap-group-editor/LdapGroupEditor.js +207 -0
- package/static/browser/ldap-group-editor/LdapGroupEditor.js.map +1 -0
- package/static/browser/ldap-group-editor/api/GroupApiClient.js +112 -0
- package/static/browser/ldap-group-editor/api/GroupApiClient.js.map +1 -0
- package/static/browser/ldap-group-editor/components/CreateGroupModal.js +212 -0
- package/static/browser/ldap-group-editor/components/CreateGroupModal.js.map +1 -0
- package/static/browser/ldap-group-editor/components/GroupPropertyEditor.js +497 -0
- package/static/browser/ldap-group-editor/components/GroupPropertyEditor.js.map +1 -0
- package/static/browser/ldap-group-editor/components/GroupTree.js +153 -0
- package/static/browser/ldap-group-editor/components/GroupTree.js.map +1 -0
- package/static/browser/ldap-group-editor/components/MoveGroupModal.js +235 -0
- package/static/browser/ldap-group-editor/components/MoveGroupModal.js.map +1 -0
- package/static/browser/ldap-group-editor/index.js +2 -0
- package/static/browser/ldap-group-editor/index.js.map +1 -0
- package/static/browser/ldap-group-editor/types.js +2 -0
- package/static/browser/ldap-group-editor/types.js.map +1 -0
- package/static/browser/ldap-group-editor.esm.js +1399 -0
- package/static/browser/ldap-group-editor.esm.js.map +1 -0
- package/static/browser/ldap-group-editor.js +1407 -0
- package/static/browser/ldap-group-editor.js.map +1 -0
- package/static/browser/ldap-group-editor.min.js +2 -0
- package/static/browser/ldap-group-editor.min.js.map +1 -0
- package/static/browser/ldap-resource-editor/api/ResourceApiClient.js +226 -0
- package/static/browser/ldap-resource-editor/api/ResourceApiClient.js.map +1 -0
- package/static/browser/ldap-resource-editor/cache/CacheManager.js +123 -0
- package/static/browser/ldap-resource-editor/cache/CacheManager.js.map +1 -0
- package/static/browser/ldap-resource-editor/index.js +2 -0
- package/static/browser/ldap-resource-editor/index.js.map +1 -0
- package/static/browser/ldap-resource-editor/types.js +2 -0
- package/static/browser/ldap-resource-editor/types.js.map +1 -0
- package/static/browser/ldap-tree-viewer/LdapTreeViewer.js +187 -0
- package/static/browser/ldap-tree-viewer/LdapTreeViewer.js.map +1 -0
- package/static/browser/ldap-tree-viewer/api/LdapApiClient.js +50 -0
- package/static/browser/ldap-tree-viewer/api/LdapApiClient.js.map +1 -0
- package/static/browser/ldap-tree-viewer/components/TreeNode.js +140 -0
- package/static/browser/ldap-tree-viewer/components/TreeNode.js.map +1 -0
- package/static/browser/ldap-tree-viewer/components/TreeRoot.js +98 -0
- package/static/browser/ldap-tree-viewer/components/TreeRoot.js.map +1 -0
- package/static/browser/ldap-tree-viewer/index.js +2 -0
- package/static/browser/ldap-tree-viewer/index.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/Store.js +29 -0
- package/static/browser/ldap-tree-viewer/store/Store.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/actions.js +53 -0
- package/static/browser/ldap-tree-viewer/store/actions.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/reducers.js +79 -0
- package/static/browser/ldap-tree-viewer/store/reducers.js.map +1 -0
- package/static/browser/ldap-tree-viewer/types.js +2 -0
- package/static/browser/ldap-tree-viewer/types.js.map +1 -0
- package/static/browser/ldap-tree-viewer.css +2 -0
- package/static/browser/ldap-tree-viewer.css.map +1 -0
- package/static/browser/ldap-tree-viewer.esm.js +606 -0
- package/static/browser/ldap-tree-viewer.esm.js.map +1 -0
- package/static/browser/ldap-tree-viewer.js +614 -0
- package/static/browser/ldap-tree-viewer.js.map +1 -0
- package/static/browser/ldap-tree-viewer.min.js +2 -0
- package/static/browser/ldap-tree-viewer.min.js.map +1 -0
- package/static/browser/ldap-unit-editor/LdapUnitEditor.js +119 -0
- package/static/browser/ldap-unit-editor/LdapUnitEditor.js.map +1 -0
- package/static/browser/ldap-unit-editor/api/UnitApiClient.js +95 -0
- package/static/browser/ldap-unit-editor/api/UnitApiClient.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/MoveUnitModal.js +295 -0
- package/static/browser/ldap-unit-editor/components/MoveUnitModal.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/UnitPropertyEditor.js +321 -0
- package/static/browser/ldap-unit-editor/components/UnitPropertyEditor.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/UnitTree.js +197 -0
- package/static/browser/ldap-unit-editor/components/UnitTree.js.map +1 -0
- package/static/browser/ldap-unit-editor/index.js +2 -0
- package/static/browser/ldap-unit-editor/index.js.map +1 -0
- package/static/browser/ldap-unit-editor/types.js +2 -0
- package/static/browser/ldap-unit-editor/types.js.map +1 -0
- package/static/browser/ldap-unit-editor.esm.js +1013 -0
- package/static/browser/ldap-unit-editor.esm.js.map +1 -0
- package/static/browser/ldap-unit-editor.js +1021 -0
- package/static/browser/ldap-unit-editor.js.map +1 -0
- package/static/browser/ldap-unit-editor.min.js +2 -0
- package/static/browser/ldap-unit-editor.min.js.map +1 -0
- package/static/browser/ldap-user-editor/LdapUserEditor.js +184 -0
- package/static/browser/ldap-user-editor/LdapUserEditor.js.map +1 -0
- package/static/browser/ldap-user-editor/api/UserApiClient.js +209 -0
- package/static/browser/ldap-user-editor/api/UserApiClient.js.map +1 -0
- package/static/browser/ldap-user-editor/cache/CacheManager.js +123 -0
- package/static/browser/ldap-user-editor/cache/CacheManager.js.map +1 -0
- package/static/browser/ldap-user-editor/components/MoveUserModal.js +302 -0
- package/static/browser/ldap-user-editor/components/MoveUserModal.js.map +1 -0
- package/static/browser/ldap-user-editor/components/PointerField.js +152 -0
- package/static/browser/ldap-user-editor/components/PointerField.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserEditor.js +608 -0
- package/static/browser/ldap-user-editor/components/UserEditor.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserList.js +181 -0
- package/static/browser/ldap-user-editor/components/UserList.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserTree.js +164 -0
- package/static/browser/ldap-user-editor/components/UserTree.js.map +1 -0
- package/static/browser/ldap-user-editor/index.js +2 -0
- package/static/browser/ldap-user-editor/index.js.map +1 -0
- package/static/browser/ldap-user-editor/types.js +2 -0
- package/static/browser/ldap-user-editor/types.js.map +1 -0
- package/static/browser/ldap-user-editor.css +2 -0
- package/static/browser/ldap-user-editor.css.map +1 -0
- package/static/browser/ldap-user-editor.esm.js +1897 -0
- package/static/browser/ldap-user-editor.esm.js.map +1 -0
- package/static/browser/ldap-user-editor.js +1905 -0
- package/static/browser/ldap-user-editor.js.map +1 -0
- package/static/browser/ldap-user-editor.min.js +2 -0
- package/static/browser/ldap-user-editor.min.js.map +1 -0
- package/static/browser/shared/components/Modal.js +121 -0
- package/static/browser/shared/components/Modal.js.map +1 -0
- package/static/browser/shared/components/StatusMessage.js +119 -0
- package/static/browser/shared/components/StatusMessage.js.map +1 -0
- package/static/browser/shared/index.js +7 -0
- package/static/browser/shared/index.js.map +1 -0
- package/static/browser/shared/types/index.js +37 -0
- package/static/browser/shared/types/index.js.map +1 -0
- package/static/browser/shared/utils/dom.js +78 -0
- package/static/browser/shared/utils/dom.js.map +1 -0
- package/static/browser/shared/utils/form.js +234 -0
- package/static/browser/shared/utils/form.js.map +1 -0
- package/static/browser/shared/utils/schema.js +121 -0
- package/static/browser/shared/utils/schema.js.map +1 -0
- package/static/browser/shared.esm.js +694 -0
- package/static/browser/shared.esm.js.map +1 -0
- package/static/browser/shared.js +723 -0
- package/static/browser/shared.js.map +1 -0
- package/static/browser/shared.min.js +2 -0
- package/static/browser/shared.min.js.map +1 -0
- package/static/schemas/ad/computers.json +92 -0
- package/static/schemas/ad/groups.json +55 -0
- package/static/schemas/ad/organizations.json +66 -0
- package/static/schemas/ad/users.json +116 -0
- package/static/schemas/standard/devices.json +72 -0
- package/static/schemas/standard/groups.json +54 -0
- package/static/schemas/standard/organizations.json +49 -0
- package/static/schemas/standard/users.json +86 -0
- package/static/schemas/twake/groups.json +75 -0
- package/static/schemas/twake/nomenclature/twakeAccountStatus.json +31 -0
- package/static/schemas/twake/nomenclature/twakeDeliveryMode.json +31 -0
- package/static/schemas/twake/nomenclature/twakeListType.json +31 -0
- package/static/schemas/twake/nomenclature/twakeMailboxType.json +31 -0
- package/static/schemas/twake/nomenclature/twakeTitle.json +31 -0
- package/static/schemas/twake/organizations.json +52 -0
- package/static/schemas/twake/positions.json +32 -0
- package/static/schemas/twake/users.json +112 -0
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete technical reference for the LDAP-Rest REST API including detailed specifications, data formats, and troubleshooting.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [HTTP Status Codes](#http-status-codes)
|
|
8
|
+
- [Request Headers](#request-headers)
|
|
9
|
+
- [Response Headers](#response-headers)
|
|
10
|
+
- [LDAP Modify Format](#ldap-modify-format)
|
|
11
|
+
- [LDAP Attributes Format](#ldap-attributes-format)
|
|
12
|
+
- [URL Encoding](#url-encoding)
|
|
13
|
+
- [Authentication Methods](#authentication-methods)
|
|
14
|
+
- [Troubleshooting](#troubleshooting)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## HTTP Status Codes
|
|
19
|
+
|
|
20
|
+
### Success Codes
|
|
21
|
+
|
|
22
|
+
| Code | Status | Description | Use Case |
|
|
23
|
+
| ---- | ------- | ----------------------------- | --------------------------- |
|
|
24
|
+
| 200 | OK | Request succeeded | GET, PUT, DELETE operations |
|
|
25
|
+
| 201 | Created | Resource created successfully | POST operations |
|
|
26
|
+
|
|
27
|
+
**Example 200 Response:**
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"dn": "uid=john.doe,ou=users,dc=example,dc=com",
|
|
32
|
+
"uid": "john.doe",
|
|
33
|
+
"cn": "John Doe"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Example 201 Response:**
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"success": true,
|
|
42
|
+
"dn": "uid=jane.smith,ou=users,dc=example,dc=com"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Client Error Codes
|
|
47
|
+
|
|
48
|
+
| Code | Status | Description | Common Causes |
|
|
49
|
+
| ---- | ---------------------- | ----------------------------------------- | ----------------------------------------------------------------- |
|
|
50
|
+
| 400 | Bad Request | Invalid request format or data | Missing required fields, invalid attribute values, malformed JSON |
|
|
51
|
+
| 401 | Unauthorized | Authentication required or failed | Missing/invalid token, expired credentials |
|
|
52
|
+
| 403 | Forbidden | Insufficient permissions | User lacks required LDAP permissions |
|
|
53
|
+
| 404 | Not Found | Resource doesn't exist | Invalid DN, deleted resource |
|
|
54
|
+
| 409 | Conflict | Resource already exists or state conflict | Duplicate entry, non-empty organization deletion |
|
|
55
|
+
| 415 | Unsupported Media Type | Wrong Content-Type header | Missing `application/json` header |
|
|
56
|
+
|
|
57
|
+
**Example 400 Response:**
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"error": "Attribute \"sn\" is required"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Example 401 Response:**
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"error": "Unauthorized"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Example 404 Response:**
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"error": "User not found"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Example 409 Response:**
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"error": "Failed to add user uid=john.doe,ou=users,dc=example,dc=com: Entry Already Exists"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Server Error Codes
|
|
90
|
+
|
|
91
|
+
| Code | Status | Description | Common Causes |
|
|
92
|
+
| ---- | --------------------- | ------------------------------ | -------------------------------------------------------- |
|
|
93
|
+
| 500 | Internal Server Error | Server-side failure | LDAP connection issues, database errors, plugin failures |
|
|
94
|
+
| 503 | Service Unavailable | Server temporarily unavailable | LDAP server down, maintenance mode |
|
|
95
|
+
|
|
96
|
+
**Example 500 Response:**
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"error": "LDAP bind error"
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Request Headers
|
|
107
|
+
|
|
108
|
+
### Required Headers
|
|
109
|
+
|
|
110
|
+
All API requests must include:
|
|
111
|
+
|
|
112
|
+
```http
|
|
113
|
+
Accept: application/json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Content-Type Header
|
|
117
|
+
|
|
118
|
+
For POST and PUT requests with a body:
|
|
119
|
+
|
|
120
|
+
```http
|
|
121
|
+
Content-Type: application/json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Authentication Headers
|
|
125
|
+
|
|
126
|
+
#### Token Bearer Authentication
|
|
127
|
+
|
|
128
|
+
```http
|
|
129
|
+
Authorization: Bearer your-secret-token
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### OpenID Connect
|
|
133
|
+
|
|
134
|
+
```http
|
|
135
|
+
Authorization: Bearer oidc-access-token
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### LemonLDAP::NG
|
|
139
|
+
|
|
140
|
+
LemonLDAP::NG sets headers automatically. No manual authentication header needed.
|
|
141
|
+
|
|
142
|
+
### Example Request with All Headers
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
curl -X POST \
|
|
146
|
+
-H "Accept: application/json" \
|
|
147
|
+
-H "Content-Type: application/json" \
|
|
148
|
+
-H "Authorization: Bearer secret-token-1" \
|
|
149
|
+
-d '{"uid": "test", "cn": "Test User", "sn": "User"}' \
|
|
150
|
+
http://localhost:8081/api/v1/ldap/users
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Response Headers
|
|
156
|
+
|
|
157
|
+
### Standard Response Headers
|
|
158
|
+
|
|
159
|
+
All API responses include:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
Content-Type: application/json; charset=utf-8
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### CORS Headers
|
|
166
|
+
|
|
167
|
+
When CORS is enabled (default), responses include:
|
|
168
|
+
|
|
169
|
+
```http
|
|
170
|
+
Access-Control-Allow-Origin: *
|
|
171
|
+
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
|
|
172
|
+
Access-Control-Allow-Headers: Content-Type, Authorization, Accept
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
To restrict CORS origins, use the `--cors-origin` option:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
--cors-origin "https://app.example.com"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## LDAP Modify Format
|
|
184
|
+
|
|
185
|
+
The LDAP modify format is used for PUT operations to update existing entries. It follows the LDAP protocol's modify operation structure.
|
|
186
|
+
|
|
187
|
+
### Format Structure
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"add": {
|
|
192
|
+
"attribute": "value"
|
|
193
|
+
},
|
|
194
|
+
"replace": {
|
|
195
|
+
"attribute": "value"
|
|
196
|
+
},
|
|
197
|
+
"delete": ["attribute1", "attribute2"]
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Or to delete specific values:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"delete": {
|
|
206
|
+
"attribute": "specific-value"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Operation Types
|
|
212
|
+
|
|
213
|
+
#### 1. Replace
|
|
214
|
+
|
|
215
|
+
Replaces the entire attribute value. Creates the attribute if it doesn't exist.
|
|
216
|
+
|
|
217
|
+
**Use Case:** Update single-valued attributes or completely replace multi-valued attributes.
|
|
218
|
+
|
|
219
|
+
**Example:**
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"replace": {
|
|
224
|
+
"mail": "newemail@example.com",
|
|
225
|
+
"telephoneNumber": "+1-555-0199"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**LDAP Effect:**
|
|
231
|
+
|
|
232
|
+
- Old value: `mail: oldemail@example.com`
|
|
233
|
+
- New value: `mail: newemail@example.com`
|
|
234
|
+
|
|
235
|
+
#### 2. Add
|
|
236
|
+
|
|
237
|
+
Adds new values to an attribute. For multi-valued attributes, appends to existing values. Fails if the value already exists.
|
|
238
|
+
|
|
239
|
+
**Use Case:** Add additional values to multi-valued attributes like `mailAlternateAddress`.
|
|
240
|
+
|
|
241
|
+
**Example:**
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"add": {
|
|
246
|
+
"mailAlternateAddress": "alias@example.com",
|
|
247
|
+
"telephoneNumber": "+1-555-0200"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**LDAP Effect:**
|
|
253
|
+
|
|
254
|
+
- Before: `mailAlternateAddress: [primary@example.com]`
|
|
255
|
+
- After: `mailAlternateAddress: [primary@example.com, alias@example.com]`
|
|
256
|
+
|
|
257
|
+
#### 3. Delete
|
|
258
|
+
|
|
259
|
+
Removes attributes or specific values.
|
|
260
|
+
|
|
261
|
+
**Delete Entire Attributes (Array Format):**
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"delete": ["mobile", "faxNumber"]
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Delete Specific Values (Object Format):**
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"delete": {
|
|
274
|
+
"mailAlternateAddress": "old-alias@example.com"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**LDAP Effect (entire attribute):**
|
|
280
|
+
|
|
281
|
+
- Before: `mobile: +1-555-0123`
|
|
282
|
+
- After: `mobile: <removed>`
|
|
283
|
+
|
|
284
|
+
**LDAP Effect (specific value):**
|
|
285
|
+
|
|
286
|
+
- Before: `mailAlternateAddress: [alias1@example.com, alias2@example.com]`
|
|
287
|
+
- After: `mailAlternateAddress: [alias1@example.com]`
|
|
288
|
+
|
|
289
|
+
### Combined Operations Example
|
|
290
|
+
|
|
291
|
+
You can combine multiple operations in a single request:
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"replace": {
|
|
296
|
+
"cn": "John A. Doe",
|
|
297
|
+
"displayName": "John Doe"
|
|
298
|
+
},
|
|
299
|
+
"add": {
|
|
300
|
+
"mailAlternateAddress": "jdoe@example.com",
|
|
301
|
+
"telephoneNumber": "+1-555-0201"
|
|
302
|
+
},
|
|
303
|
+
"delete": ["mobile", "faxNumber"]
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Complete Example
|
|
308
|
+
|
|
309
|
+
**Request:**
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
curl -X PUT \
|
|
313
|
+
-H "Content-Type: application/json" \
|
|
314
|
+
-H "Accept: application/json" \
|
|
315
|
+
-d '{
|
|
316
|
+
"replace": {
|
|
317
|
+
"mail": "john.doe@example.com",
|
|
318
|
+
"telephoneNumber": "+1-555-0100"
|
|
319
|
+
},
|
|
320
|
+
"add": {
|
|
321
|
+
"mailAlternateAddress": "j.doe@example.com"
|
|
322
|
+
},
|
|
323
|
+
"delete": ["mobile"]
|
|
324
|
+
}' \
|
|
325
|
+
http://localhost:8081/api/v1/ldap/users/john.doe
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Response:**
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"success": true
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Special Cases
|
|
337
|
+
|
|
338
|
+
#### Group Members
|
|
339
|
+
|
|
340
|
+
Do **not** use modify operations for group members. Use dedicated endpoints:
|
|
341
|
+
|
|
342
|
+
- Add member: `POST /api/v1/ldap/groups/:cn/members`
|
|
343
|
+
- Remove member: `DELETE /api/v1/ldap/groups/:cn/members/:memberId`
|
|
344
|
+
|
|
345
|
+
**Wrong:**
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"add": {
|
|
350
|
+
"member": "uid=john.doe,ou=users,dc=example,dc=com"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Correct:**
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
curl -X POST \
|
|
359
|
+
-H "Content-Type: application/json" \
|
|
360
|
+
-d '{"member": "uid=john.doe,ou=users,dc=example,dc=com"}' \
|
|
361
|
+
http://localhost:8081/api/v1/ldap/groups/admins/members
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Main Identifier Attribute
|
|
365
|
+
|
|
366
|
+
You cannot modify the main identifier attribute (e.g., `uid` for users, `cn` for groups) using modify operations. Use LDAP rename operations instead (not currently exposed via REST API).
|
|
367
|
+
|
|
368
|
+
**Error:**
|
|
369
|
+
|
|
370
|
+
```json
|
|
371
|
+
{
|
|
372
|
+
"replace": {
|
|
373
|
+
"uid": "new.uid"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Result:**
|
|
379
|
+
|
|
380
|
+
```json
|
|
381
|
+
{
|
|
382
|
+
"error": "Cannot modify identifier attribute"
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## LDAP Attributes Format
|
|
389
|
+
|
|
390
|
+
### Attribute Value Types
|
|
391
|
+
|
|
392
|
+
LDAP attributes can be single-valued or multi-valued. The API handles both formats flexibly.
|
|
393
|
+
|
|
394
|
+
#### Single-Valued Attributes
|
|
395
|
+
|
|
396
|
+
**LDAP Storage:** Always stored as arrays internally
|
|
397
|
+
|
|
398
|
+
**API Input:** Accepts both string and array formats
|
|
399
|
+
|
|
400
|
+
```json
|
|
401
|
+
{
|
|
402
|
+
"uid": "john.doe"
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Or:
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{
|
|
410
|
+
"uid": ["john.doe"]
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**API Output:** Returns as string for single values
|
|
415
|
+
|
|
416
|
+
```json
|
|
417
|
+
{
|
|
418
|
+
"uid": "john.doe",
|
|
419
|
+
"cn": "John Doe",
|
|
420
|
+
"sn": "Doe"
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
#### Multi-Valued Attributes
|
|
425
|
+
|
|
426
|
+
**LDAP Storage:** Stored as arrays
|
|
427
|
+
|
|
428
|
+
**API Input:** Must use array format
|
|
429
|
+
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"mailAlternateAddress": [
|
|
433
|
+
"john@example.com",
|
|
434
|
+
"jdoe@example.com",
|
|
435
|
+
"john.doe@example.com"
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**API Output:** Always returns as arrays
|
|
441
|
+
|
|
442
|
+
```json
|
|
443
|
+
{
|
|
444
|
+
"objectClass": ["top", "inetOrgPerson", "organizationalPerson", "person"],
|
|
445
|
+
"mailAlternateAddress": ["john@example.com", "jdoe@example.com"]
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Common Attributes Reference
|
|
450
|
+
|
|
451
|
+
#### User Attributes
|
|
452
|
+
|
|
453
|
+
| Attribute | Type | Required | Format | Description |
|
|
454
|
+
| -------------------- | ------ | -------- | ------------------------- | ------------------------------- |
|
|
455
|
+
| uid | string | Yes | `^[a-zA-Z0-9._-]{1,255}$` | User identifier |
|
|
456
|
+
| cn | string | Yes | Any | Common name (full name) |
|
|
457
|
+
| sn | string | Yes | Any | Surname (last name) |
|
|
458
|
+
| givenName | string | No | Any | First name |
|
|
459
|
+
| mail | string | No | Email format | Primary email address |
|
|
460
|
+
| mailAlternateAddress | array | No | Email format | Additional email addresses |
|
|
461
|
+
| telephoneNumber | string | No | Any | Primary phone number |
|
|
462
|
+
| mobile | string | No | Any | Mobile phone number |
|
|
463
|
+
| displayName | string | No | Any | Display name |
|
|
464
|
+
| userPassword | string | No | Hashed | User password (SSHA, MD5, etc.) |
|
|
465
|
+
| departmentNumber | string | No | DN format | Department/organization link |
|
|
466
|
+
| objectClass | array | Yes | Fixed | LDAP object classes |
|
|
467
|
+
|
|
468
|
+
#### Group Attributes
|
|
469
|
+
|
|
470
|
+
| Attribute | Type | Required | Format | Description |
|
|
471
|
+
| ----------- | ------ | -------- | --------- | ------------------- |
|
|
472
|
+
| cn | string | Yes | Any | Group name |
|
|
473
|
+
| description | string | No | Any | Group description |
|
|
474
|
+
| member | array | Auto | DN format | Group members (DNs) |
|
|
475
|
+
| objectClass | array | Yes | Fixed | LDAP object classes |
|
|
476
|
+
|
|
477
|
+
**Note:** The `member` attribute requires at least one value. If not provided, a dummy member is automatically added.
|
|
478
|
+
|
|
479
|
+
#### Organization Attributes
|
|
480
|
+
|
|
481
|
+
| Attribute | Type | Required | Format | Description |
|
|
482
|
+
| ----------- | ------ | -------- | ------ | ------------------------ |
|
|
483
|
+
| ou | string | Yes | Any | Organizational unit name |
|
|
484
|
+
| description | string | No | Any | Organization description |
|
|
485
|
+
| objectClass | array | Yes | Fixed | LDAP object classes |
|
|
486
|
+
|
|
487
|
+
### Distinguished Names (DN)
|
|
488
|
+
|
|
489
|
+
DNs uniquely identify LDAP entries and follow this format:
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
attribute=value,parent-dn
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**Examples:**
|
|
496
|
+
|
|
497
|
+
```
|
|
498
|
+
uid=john.doe,ou=users,dc=example,dc=com
|
|
499
|
+
cn=admins,ou=groups,dc=example,dc=com
|
|
500
|
+
ou=it,ou=organization,dc=example,dc=com
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**DN Components:**
|
|
504
|
+
|
|
505
|
+
- **RDN (Relative DN):** First component (`uid=john.doe`)
|
|
506
|
+
- **Base DN:** Remaining components (`ou=users,dc=example,dc=com`)
|
|
507
|
+
|
|
508
|
+
**DN Rules:**
|
|
509
|
+
|
|
510
|
+
1. Case-insensitive for attribute names
|
|
511
|
+
2. Case-sensitive for attribute values
|
|
512
|
+
3. Must be unique within the LDAP tree
|
|
513
|
+
4. Cannot contain certain special characters without escaping
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## URL Encoding
|
|
518
|
+
|
|
519
|
+
### When to Encode
|
|
520
|
+
|
|
521
|
+
Always URL-encode DNs and special characters when using them in URL paths or query parameters.
|
|
522
|
+
|
|
523
|
+
### Characters Requiring Encoding
|
|
524
|
+
|
|
525
|
+
| Character | Encoding | Usage |
|
|
526
|
+
| ----------------- | -------- | ------------------------- |
|
|
527
|
+
| Space | `%20` | Names with spaces |
|
|
528
|
+
| Comma `,` | `%2C` | DN separators |
|
|
529
|
+
| Equals `=` | `%3D` | DN attribute assignments |
|
|
530
|
+
| Plus `+` | `%2B` | Multi-valued RDNs |
|
|
531
|
+
| Forward slash `/` | `%2F` | Path separators |
|
|
532
|
+
| Colon `:` | `%3A` | Port separators |
|
|
533
|
+
| Question mark `?` | `%3F` | Query string start |
|
|
534
|
+
| Ampersand `&` | `%26` | Query parameter separator |
|
|
535
|
+
| Hash `#` | `%23` | Fragment identifier |
|
|
536
|
+
|
|
537
|
+
### Encoding Examples
|
|
538
|
+
|
|
539
|
+
#### Simple UID
|
|
540
|
+
|
|
541
|
+
```javascript
|
|
542
|
+
const uid = 'john.doe';
|
|
543
|
+
const encoded = encodeURIComponent(uid);
|
|
544
|
+
// Result: john.doe (no encoding needed)
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
#### Full DN
|
|
548
|
+
|
|
549
|
+
```javascript
|
|
550
|
+
const dn = 'uid=john.doe,ou=users,dc=example,dc=com';
|
|
551
|
+
const encoded = encodeURIComponent(dn);
|
|
552
|
+
// Result: uid%3Djohn.doe%2Cou%3Dusers%2Cdc%3Dexample%2Cdc%3Dcom
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
#### DN with Spaces
|
|
556
|
+
|
|
557
|
+
```javascript
|
|
558
|
+
const dn = 'cn=John Doe,ou=users,dc=example,dc=com';
|
|
559
|
+
const encoded = encodeURIComponent(dn);
|
|
560
|
+
// Result: cn%3DJohn%20Doe%2Cou%3Dusers%2Cdc%3Dexample%2Cdc%3Dcom
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Complete Request Examples
|
|
564
|
+
|
|
565
|
+
#### JavaScript
|
|
566
|
+
|
|
567
|
+
```javascript
|
|
568
|
+
// Get user by DN
|
|
569
|
+
const dn = 'uid=john.doe,ou=users,dc=example,dc=com';
|
|
570
|
+
const url = `http://localhost:8081/api/v1/ldap/users/${encodeURIComponent(dn)}`;
|
|
571
|
+
|
|
572
|
+
const response = await fetch(url, {
|
|
573
|
+
headers: {
|
|
574
|
+
Accept: 'application/json',
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const user = await response.json();
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
#### Python
|
|
582
|
+
|
|
583
|
+
```python
|
|
584
|
+
import urllib.parse
|
|
585
|
+
import requests
|
|
586
|
+
|
|
587
|
+
# Get user by DN
|
|
588
|
+
dn = "uid=john.doe,ou=users,dc=example,dc=com"
|
|
589
|
+
encoded_dn = urllib.parse.quote(dn, safe='')
|
|
590
|
+
url = f"http://localhost:8081/api/v1/ldap/users/{encoded_dn}"
|
|
591
|
+
|
|
592
|
+
response = requests.get(url, headers={'Accept': 'application/json'})
|
|
593
|
+
user = response.json()
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
#### Bash
|
|
597
|
+
|
|
598
|
+
```bash
|
|
599
|
+
# Get user by DN
|
|
600
|
+
DN="uid=john.doe,ou=users,dc=example,dc=com"
|
|
601
|
+
ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$DN', safe=''))")
|
|
602
|
+
|
|
603
|
+
curl -H "Accept: application/json" \
|
|
604
|
+
"http://localhost:8081/api/v1/ldap/users/$ENCODED"
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Authentication Methods
|
|
610
|
+
|
|
611
|
+
### Overview
|
|
612
|
+
|
|
613
|
+
| Method | Security | Use Case | Session | User Identification |
|
|
614
|
+
| -------------- | -------- | ---------------- | ------- | ------------------- |
|
|
615
|
+
| None | Low | Development only | No | None |
|
|
616
|
+
| Token | Medium | Services, APIs | No | Token index |
|
|
617
|
+
| OpenID Connect | High | Web applications | Yes | User claims |
|
|
618
|
+
| LemonLDAP::NG | High | Enterprise SSO | Yes | LDAP user |
|
|
619
|
+
|
|
620
|
+
### Configuration Comparison
|
|
621
|
+
|
|
622
|
+
#### No Authentication
|
|
623
|
+
|
|
624
|
+
```bash
|
|
625
|
+
npx ldap-rest \
|
|
626
|
+
--ldap-url ldap://localhost:389 \
|
|
627
|
+
--ldap-dn cn=admin,dc=example,dc=com \
|
|
628
|
+
--ldap-pwd admin \
|
|
629
|
+
--ldap-base dc=example,dc=com
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
**Pros:** Simple, fast setup
|
|
633
|
+
**Cons:** No security, development only
|
|
634
|
+
|
|
635
|
+
#### Token Authentication
|
|
636
|
+
|
|
637
|
+
```bash
|
|
638
|
+
npx ldap-rest \
|
|
639
|
+
--ldap-url ldap://localhost:389 \
|
|
640
|
+
--ldap-dn cn=admin,dc=example,dc=com \
|
|
641
|
+
--ldap-pwd admin \
|
|
642
|
+
--ldap-base dc=example,dc=com \
|
|
643
|
+
--plugin core/auth/token \
|
|
644
|
+
--auth-token "token-1" \
|
|
645
|
+
--auth-token "token-2"
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
**Pros:** Simple, stateless, good for services
|
|
649
|
+
**Cons:** Shared tokens, manual rotation
|
|
650
|
+
|
|
651
|
+
#### OpenID Connect
|
|
652
|
+
|
|
653
|
+
```bash
|
|
654
|
+
npx ldap-rest \
|
|
655
|
+
--ldap-url ldap://localhost:389 \
|
|
656
|
+
--ldap-dn cn=admin,dc=example,dc=com \
|
|
657
|
+
--ldap-pwd admin \
|
|
658
|
+
--ldap-base dc=example,dc=com \
|
|
659
|
+
--plugin core/auth/openidconnect \
|
|
660
|
+
--oidc-issuer https://auth.example.com \
|
|
661
|
+
--oidc-client-id ldap-rest \
|
|
662
|
+
--oidc-client-secret your-secret
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
**Pros:** Standards-based, user-specific tokens, automatic expiration
|
|
666
|
+
**Cons:** Requires OIDC provider setup
|
|
667
|
+
|
|
668
|
+
#### LemonLDAP::NG
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
npx ldap-rest \
|
|
672
|
+
--ldap-url ldap://localhost:389 \
|
|
673
|
+
--ldap-dn cn=admin,dc=example,dc=com \
|
|
674
|
+
--ldap-pwd admin \
|
|
675
|
+
--ldap-base dc=example,dc=com \
|
|
676
|
+
--plugin core/auth/llng \
|
|
677
|
+
--llng-ini /etc/lemonldap-ng/lemonldap-ng.ini
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
**Pros:** Enterprise SSO, centralized authentication
|
|
681
|
+
**Cons:** Requires LemonLDAP::NG infrastructure
|
|
682
|
+
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
## Troubleshooting
|
|
686
|
+
|
|
687
|
+
### CORS Issues
|
|
688
|
+
|
|
689
|
+
#### Problem: Browser Blocks API Requests
|
|
690
|
+
|
|
691
|
+
**Error in Browser Console:**
|
|
692
|
+
|
|
693
|
+
```
|
|
694
|
+
Access to fetch at 'http://localhost:8081/api/v1/config' from origin
|
|
695
|
+
'http://localhost:3000' has been blocked by CORS policy
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
**Solution 1: Allow All Origins (Development)**
|
|
699
|
+
|
|
700
|
+
```bash
|
|
701
|
+
--cors-origin "*"
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
**Solution 2: Restrict to Specific Origin (Production)**
|
|
705
|
+
|
|
706
|
+
```bash
|
|
707
|
+
--cors-origin "https://app.example.com"
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
**Solution 3: Multiple Origins**
|
|
711
|
+
|
|
712
|
+
Use a reverse proxy (nginx, Apache) to handle CORS headers.
|
|
713
|
+
|
|
714
|
+
#### Problem: Preflight OPTIONS Request Fails
|
|
715
|
+
|
|
716
|
+
**Error:**
|
|
717
|
+
|
|
718
|
+
```
|
|
719
|
+
OPTIONS request returns 403 Forbidden
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
**Solution:**
|
|
723
|
+
|
|
724
|
+
Ensure your authentication plugin allows OPTIONS requests without authentication:
|
|
725
|
+
|
|
726
|
+
```javascript
|
|
727
|
+
if (req.method === 'OPTIONS') {
|
|
728
|
+
return next();
|
|
729
|
+
}
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
### Authentication Issues
|
|
733
|
+
|
|
734
|
+
#### Problem: 401 Unauthorized
|
|
735
|
+
|
|
736
|
+
**Error:**
|
|
737
|
+
|
|
738
|
+
```json
|
|
739
|
+
{
|
|
740
|
+
"error": "Unauthorized"
|
|
741
|
+
}
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
**Checklist:**
|
|
745
|
+
|
|
746
|
+
1. **Check Authorization Header:**
|
|
747
|
+
|
|
748
|
+
```bash
|
|
749
|
+
curl -v -H "Authorization: Bearer your-token" \
|
|
750
|
+
http://localhost:8081/api/v1/config
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
2. **Verify Token Configuration:**
|
|
754
|
+
|
|
755
|
+
```bash
|
|
756
|
+
echo $DM_AUTH_TOKENS
|
|
757
|
+
# Should include your token
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
3. **Check Token Format:**
|
|
761
|
+
- Must start with "Bearer "
|
|
762
|
+
- Token must match exactly (case-sensitive)
|
|
763
|
+
|
|
764
|
+
4. **Test Without Authentication:**
|
|
765
|
+
```bash
|
|
766
|
+
# Temporarily disable auth plugin to verify API works
|
|
767
|
+
npx ldap-rest --ldap-url ldap://localhost:389 ...
|
|
768
|
+
# (without --plugin core/auth/token)
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Connection Issues
|
|
772
|
+
|
|
773
|
+
#### Problem: Cannot Connect to LDAP-Rest
|
|
774
|
+
|
|
775
|
+
**Error:**
|
|
776
|
+
|
|
777
|
+
```
|
|
778
|
+
Failed to fetch
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
**Checklist:**
|
|
782
|
+
|
|
783
|
+
1. **Verify Server is Running:**
|
|
784
|
+
|
|
785
|
+
```bash
|
|
786
|
+
curl http://localhost:8081/api/v1/config
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
2. **Check Port Configuration:**
|
|
790
|
+
|
|
791
|
+
```bash
|
|
792
|
+
--port 8081 # Default
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
3. **Check Firewall:**
|
|
796
|
+
|
|
797
|
+
```bash
|
|
798
|
+
sudo ufw allow 8081
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
4. **Check Server Logs:**
|
|
802
|
+
```bash
|
|
803
|
+
npx ldap-rest --log-level debug
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
#### Problem: LDAP Connection Failed
|
|
807
|
+
|
|
808
|
+
**Error:**
|
|
809
|
+
|
|
810
|
+
```json
|
|
811
|
+
{
|
|
812
|
+
"error": "LDAP bind error"
|
|
813
|
+
}
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
**Checklist:**
|
|
817
|
+
|
|
818
|
+
1. **Verify LDAP Server:**
|
|
819
|
+
|
|
820
|
+
```bash
|
|
821
|
+
ldapsearch -x -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w admin -b "dc=example,dc=com"
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
2. **Check LDAP Credentials:**
|
|
825
|
+
|
|
826
|
+
```bash
|
|
827
|
+
--ldap-dn "cn=admin,dc=example,dc=com" \
|
|
828
|
+
--ldap-pwd "admin"
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
3. **Check LDAP URL:**
|
|
832
|
+
|
|
833
|
+
```bash
|
|
834
|
+
--ldap-url "ldap://localhost:389" # Not ldaps:// if using plain LDAP
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
4. **Check Base DN:**
|
|
838
|
+
```bash
|
|
839
|
+
--ldap-base "dc=example,dc=com"
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
### Data Format Issues
|
|
843
|
+
|
|
844
|
+
#### Problem: Missing Required Field
|
|
845
|
+
|
|
846
|
+
**Error:**
|
|
847
|
+
|
|
848
|
+
```json
|
|
849
|
+
{
|
|
850
|
+
"error": "Attribute \"sn\" is required"
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
**Solution:**
|
|
855
|
+
|
|
856
|
+
Check schema via Configuration API:
|
|
857
|
+
|
|
858
|
+
```bash
|
|
859
|
+
curl http://localhost:8081/api/v1/config | jq '.features.ldapFlatGeneric.flatResources[0].schema.attributes'
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
Ensure all required fields are included:
|
|
863
|
+
|
|
864
|
+
```json
|
|
865
|
+
{
|
|
866
|
+
"uid": "john.doe",
|
|
867
|
+
"cn": "John Doe",
|
|
868
|
+
"sn": "Doe" // Required!
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
#### Problem: Invalid Attribute Format
|
|
873
|
+
|
|
874
|
+
**Error:**
|
|
875
|
+
|
|
876
|
+
```json
|
|
877
|
+
{
|
|
878
|
+
"error": "Invalid value for attribute \"mail\": must match ^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
|
|
879
|
+
}
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
**Solution:**
|
|
883
|
+
|
|
884
|
+
Follow the attribute format specified in the schema:
|
|
885
|
+
|
|
886
|
+
```json
|
|
887
|
+
{
|
|
888
|
+
"mail": "valid.email@example.com" // Not "invalid-email"
|
|
889
|
+
}
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
#### Problem: Cannot Modify Identifier
|
|
893
|
+
|
|
894
|
+
**Error:**
|
|
895
|
+
|
|
896
|
+
```json
|
|
897
|
+
{
|
|
898
|
+
"error": "Cannot modify identifier attribute"
|
|
899
|
+
}
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
**Solution:**
|
|
903
|
+
|
|
904
|
+
You cannot change the main identifier (uid, cn) using modify operations. Create a new entry instead.
|
|
905
|
+
|
|
906
|
+
### Debug Mode
|
|
907
|
+
|
|
908
|
+
Enable detailed logging:
|
|
909
|
+
|
|
910
|
+
```bash
|
|
911
|
+
npx ldap-rest \
|
|
912
|
+
--ldap-url ldap://localhost:389 \
|
|
913
|
+
--ldap-dn cn=admin,dc=example,dc=com \
|
|
914
|
+
--ldap-pwd admin \
|
|
915
|
+
--ldap-base dc=example,dc=com \
|
|
916
|
+
--log-level debug
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
**Log Levels:**
|
|
920
|
+
|
|
921
|
+
- `error` - Errors only
|
|
922
|
+
- `warn` - Warnings and errors
|
|
923
|
+
- `info` - General information (default)
|
|
924
|
+
- `debug` - Detailed debugging information
|
|
925
|
+
- `silly` - Everything including LDAP queries
|
|
926
|
+
|
|
927
|
+
**Example Debug Output:**
|
|
928
|
+
|
|
929
|
+
```
|
|
930
|
+
[2025-10-07 10:30:45] DEBUG: LDAP search: base=ou=users,dc=example,dc=com, filter=(uid=john.doe)
|
|
931
|
+
[2025-10-07 10:30:45] DEBUG: LDAP result: 1 entries found
|
|
932
|
+
[2025-10-07 10:30:45] INFO: User john.doe retrieved successfully
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
### Common Issues Summary
|
|
936
|
+
|
|
937
|
+
| Issue | Symptom | Solution |
|
|
938
|
+
| ---------------- | ----------------------- | ------------------------- |
|
|
939
|
+
| CORS blocked | Browser console error | Configure `--cors-origin` |
|
|
940
|
+
| 401 Unauthorized | Authentication failed | Check token/credentials |
|
|
941
|
+
| 404 Not Found | Entry doesn't exist | Verify DN is correct |
|
|
942
|
+
| 409 Conflict | Entry already exists | Use unique identifier |
|
|
943
|
+
| 500 Server Error | LDAP connection failed | Check LDAP server status |
|
|
944
|
+
| Invalid format | Validation error | Check schema requirements |
|
|
945
|
+
| Cannot modify DN | Identifier change error | Create new entry instead |
|
|
946
|
+
|
|
947
|
+
### Getting Help
|
|
948
|
+
|
|
949
|
+
1. **Check Logs:**
|
|
950
|
+
|
|
951
|
+
```bash
|
|
952
|
+
npx ldap-rest --log-level debug
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
2. **Test LDAP Connection:**
|
|
956
|
+
|
|
957
|
+
```bash
|
|
958
|
+
ldapsearch -x -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w admin
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
3. **Verify Configuration:**
|
|
962
|
+
|
|
963
|
+
```bash
|
|
964
|
+
curl http://localhost:8081/api/v1/config
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
4. **Check GitHub Issues:**
|
|
968
|
+
https://github.com/linagora/ldap-rest/issues
|
|
969
|
+
|
|
970
|
+
5. **Review Documentation:**
|
|
971
|
+
- [REST API Guide](./REST_API.md)
|
|
972
|
+
- [Browser Libraries](../browser/LIBRARIES.md)
|
|
973
|
+
- [Examples](../examples/EXAMPLES.md)
|
|
974
|
+
|
|
975
|
+
---
|
|
976
|
+
|
|
977
|
+
## Additional Resources
|
|
978
|
+
|
|
979
|
+
- **[REST API Guide](./REST_API.md)** - Complete API guide with examples
|
|
980
|
+
- **[Developer Guide](../DEVELOPER_GUIDE.md)** - Getting started guide
|
|
981
|
+
- **[Browser Libraries](../browser/LIBRARIES.md)** - JavaScript/TypeScript clients
|
|
982
|
+
- **[JSON Schemas](../schemas/SCHEMAS.md)** - Schema structure and validation
|
|
983
|
+
- **[Plugin Development](../plugins/DEVELOPMENT.md)** - Creating custom plugins
|