添加LDAP服务器

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": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例

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

参数列表

名字

类型

位置

描述

可选值

起始版本

name

String

body(包含在params结构中)

资源名称

 

4.3.0

description (可选)

String

body(包含在params结构中)

资源的详细描述

 

4.3.0

url

String

body(包含在params结构中)

LDAP服务器访问地址

 

4.3.0

base

String

body(包含在params结构中)

LDAP服务查询BaseDN

 

4.3.0

username

String

body(包含在params结构中)

访问LDAP服务器使用的用户名

 

4.3.0

password

String

body(包含在params结构中)

密码

 

4.3.0

encryption

String

body(包含在params结构中)

加密方式

  • None
  • TLS

4.3.0

systemTags (可选)

List

body

系统标签

 

4.3.0

userTags (可选)

List

body

用户标签

 

4.3.0

serverType (可选)

String

body(包含在params结构中)

LDAP服务器类型

  • OpenLdap
  • WindowsAD
  • Unknown

4.3.0

usernameProperty (可选)

String

body(包含在params结构中)

用户登录该虚拟化平台时使用哪个字段用作用户名

 

4.3.0

filter (可选)

String

body(包含在params结构中)

从LDAP服务器同步时,使用的过滤器,确定哪些用户是需要同步的

 

4.3.0

syncCreatedAccountStrategy (可选)

String

body(包含在params结构中)

从LDAP服务器同步时,对于LDAP服务器中新创建的用户,该虚拟化平台的处理策略,是创建对应的account还是无动作

  • NoAction
  • CreateDisabledAccount
  • CreateAccount

4.3.0

syncDeletedAccountStrategy (可选)

String

body(包含在params结构中)

从LDAP服务器同步时,对于LDAP服务器中已删除的用户,该虚拟化平台的处理策略,是删除对应的account、标记已删除还是无动作

  • NoAction
  • StaleAccount
  • DeleteAccount

4.3.0

API返回

返回示例

{
  "inventory": {
    "uuid": "01b489793e3d31728ccbbc4fdfd99ed0",
    "name": "miao",
    "description": "miao desc",
    "url": "ldap://localhost:1888",
    "base": "dc=example,dc=com",
    "username": "",
    "password": "",
    "encryption": "None"
  }
}
名字类型描述起始版本
successboolean 4.3.0
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error4.3.0
inventoryLdapServerInventory详情参考inventory4.3.0

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

inventory

名字类型描述起始版本
uuidString资源的UUID,唯一标示该资源4.3.0
nameString资源名称4.3.0
typeString用户源类型,一般是ldap4.3.0
descriptionString资源的详细描述4.3.0
urlString 4.3.0
baseStringLDAP服务器访问地址4.3.0
usernameString用于访问LDAP服务器的用户名4.3.0
passwordString密码4.3.0
encryptionString加密方式4.3.0
serverTypeString服务器类型,可能是OpenLdap或WindowsAD,如果不确定会返回Unknown4.3.0
createDateTimestamp创建时间4.3.0
lastOpDateTimestamp最后一次修改时间4.3.0

SDK示例

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()