Add LDAP Server

POST/zstack/v1/ldap/servers

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "miao",
    "description": "miao desc",
    "url": "ldap://localhost:1888",
    "base": "dc=example,dc=com",
    "username": "",
    "password": "",
    "encryption": "None",
    "serverType": "WindowsAD",
    "usernameProperty": "cn",
    "filter": "(cn=Micha Kops)",
    "syncCreatedAccountStrategy": "CreateAccount",
    "syncDeletedAccountStrategy": "StaleAccount"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding example, the systemTags and userTags fields are optional. They are listed here to show that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"miao","description":"miao desc","url":"ldap://localhost:1888","base":"dc=example,dc=com","username":"","password":"","encryption":"None","serverType":"WindowsAD","usernameProperty":"cn","filter":"(cn=Micha Kops)","syncCreatedAccountStrategy":"CreateAccount","syncDeletedAccountStrategy":"StaleAccount"}}' \
http://localhost:8080/zstack/v1/ldap/servers

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

name

String

body (enclosed in the params structure)

Resource name

 

4.3.0

description (Optional)

String

body (enclosed in the params structure)

Detailed description of the resource

 

4.3.0

url

String

body (enclosed in the params structure)

LDAP server access URL

 

4.3.0

base

String

body (enclosed in the params structure)

LDAP server query BaseDN

 

4.3.0

username

String

body (enclosed in the params structure)

Username for accessing the LDAP server

 

4.3.0

password

String

body (enclosed in the params structure)

Password

 

4.3.0

encryption

String

body (enclosed in the params structure)

Encryption method

  • None
  • TLS

4.3.0

systemTags (Optional)

List

body

System tags

 

4.3.0

userTags (Optional)

List

body

User tags

 

4.3.0

serverType (Optional)

String

body (enclosed in the params structure)

LDAP server type

  • OpenLdap
  • WindowsAD
  • Unknown

4.3.0

usernameProperty (Optional)

String

body (enclosed in the params structure)

The field used as the username when a user logs in to the virtualization platform

 

4.3.0

filter (Optional)

String

body (enclosed in the params structure)

The filter used when syncing from the LDAP server, which determines which users need to be synced

 

4.3.0

syncCreatedAccountStrategy (Optional)

String

body (enclosed in the params structure)

The strategy for handling newly created users on the LDAP server during synchronization: create a corresponding account or take no action

  • NoAction
  • CreateDisabledAccount
  • CreateAccount

4.3.0

syncDeletedAccountStrategy (Optional)

String

body (enclosed in the params structure)

The strategy for handling deleted users on the LDAP server during synchronization: delete the corresponding account, mark as stale, or take no action

  • NoAction
  • StaleAccount
  • DeleteAccount

4.3.0

API Response

Response Example

{
  "inventory": {
    "uuid": "01b489793e3d31728ccbbc4fdfd99ed0",
    "name": "miao",
    "description": "miao desc",
    "url": "ldap://localhost:1888",
    "base": "dc=example,dc=com",
    "username": "",
    "password": "",
    "encryption": "None"
  }
}
NameTypeDescriptionStarting Version
successboolean 4.3.0
errorErrorCodeError code. If not null, the operation has failed. This field is null when the operation succeeds. For details, see error4.3.0
inventoryLdapServerInventoryFor details, see inventory4.3.0

error

NameTypeDescriptionStarting Version
codeStringError code number. The globally unique identifier of the error, for example, SYS.1000 or HOST.1001.0.6
descriptionStringBrief description of the error0.6
detailsStringDetailed information about the error0.6
elaborationStringReserved field. Default is null.0.6
opaqueLinkedHashMapReserved field. Default is null.0.6
causeErrorCodeRoot error. The source error that caused the current error. This field is null if no root error exists.0.6

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource.4.3.0
nameStringResource name4.3.0
typeStringUser source type, typically ldap4.3.0
descriptionStringDetailed description of the resource4.3.0
urlString 4.3.0
baseStringLDAP server access URL4.3.0
usernameStringUsername for accessing the LDAP server4.3.0
passwordStringPassword4.3.0
encryptionStringEncryption method4.3.0
serverTypeStringServer type. Possible values are OpenLdap or WindowsAD. Returns Unknown if the type cannot be determined.4.3.0
createDateTimestampCreation time4.3.0
lastOpDateTimestampLast modification time4.3.0

SDK Examples

Java SDK

AddLdapServerAction action = new AddLdapServerAction();
action.name = "miao";
action.description = "miao desc";
action.url = "ldap://localhost:1888";
action.base = "dc=example,dc=com";
action.username = "";
action.password = "";
action.encryption = "None";
action.serverType = "WindowsAD";
action.usernameProperty = "cn";
action.filter = "(cn=Micha Kops)";
action.syncCreatedAccountStrategy = "CreateAccount";
action.syncDeletedAccountStrategy = "StaleAccount";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLdapServerAction.Result res = action.call();

Python SDK

AddLdapServerAction action = AddLdapServerAction()
action.name = "miao"
action.description = "miao desc"
action.url = "ldap://localhost:1888"
action.base = "dc=example,dc=com"
action.username = ""
action.password = ""
action.encryption = "None"
action.serverType = "WindowsAD"
action.usernameProperty = "cn"
action.filter = "(cn=Micha Kops)"
action.syncCreatedAccountStrategy = "CreateAccount"
action.syncDeletedAccountStrategy = "StaleAccount"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddLdapServerAction.Result res = action.call()