实施应用程序集成服务器

作者:mailstore,发布时间:2020-05-11 18:07:11

下面介绍了如何实现自己的Application Integration服务器来同步MailStore本身不支持的源中的用户。实际上,这可以是可以通过编程或脚本语言访问的任何用户数据库,例如SQL Server数据库或纯文本文件。使用应用集成服务器作为用于同步和授权目录服务中描述应用集成

可以用任何编程或脚本语言编写Application Integration服务器。它们必须提供自己的HTTP服务器接口,或者可以通过现有HTTP服务器进行访问。

 

同步用户

Application Integration Server必须通过HTTP POST请求接受以下参数以初始化同步。

名称 描述
命令 为了同步用户,必须将cmd参数设置为list。

返回的HTTP响应必须包含有效的JSON格式的数据。同步用户时,每个用户对象都需要以下数据结构。必须以JSON对象数组的形式返回多个用户。

名称 类型
用户名
专有名称 字符串(可选)
全名 字符串(可选)
电子邮件地址 数组(可选)

HTTP请求

POST /mailstore-integration/index.php HTTP/1.1
Authorization: Basic bWFpbHN0b3JlQGV4YW1wbGUudGVzdDpQYXNzdzByZA==
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: mail.example.test
Accept: */*
Content-Length: 8
Content-Type: application/x-www-form-urlencoded
 
cmd=list

HTTP响应

HTTP/1.1 200 OK
X-Powered-By: PHP/5.4.4-14+deb7u5
Content-Type: text/json; charset=utf8
Date: Fri, 13 Dec 2013 14:20:27 GMT
Server: lighttpd/1.4.31
Content-Length: 23812
Accept-Ranges: none
Connection: Keep-Alive

[
 {
 "userName": "john.doe",
 "distinguishedName": "UID=john.doe,DC=example,DC=com",
 "fullName": "john.doe",
 "emailAddresses": [
 "john.doe@example.com",
 "john@example.com"
 ]
 },
 {
 "userName": "jane.doe",
 "distinguishedName": "UID=jane.doe,DC=example,DC=com",
 "fullName": "jane.doe",
 "emailAddresses": [
 "jane.doe@example.com",
 "jane@example.com"
 ]
 }
]

 

验证用户

Application Integration服务器必须通过HTTP POST请求接受以下参数来对用户进行身份验证。

名称 描述
cmd 为了验证用户,必须将cmd参数设置为auth。
user 该用户参数中包含的用户名进行身份验证。
pass 该通参数包含密码进行验证。

返回的HTTP响应必须包含有效的JSON格式的数据。对用户进行身份验证时,需要以下数据结构。

名称 类型
succeeded boolean

例子

HTTP请求

POST /mailstore-integration/index.php HTTP/1.1
Authorization: Basic bWFpbHN0b3JlQGV4YW1wbGUudGVzdDpQYXNzdzByZA==
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: mail.example.test
Accept: */*
Content-Length: 8
Content-Type: application/x-www-form-urlencoded

cmd=auth&user=john.doe&pass=Passw0rd

HTTP响应-身份验证成功

HTTP/1.1 200 OK
X-Powered-By: PHP/5.4.4-14+deb7u5
Content-Type: text/json; charset=utf8
Date: Fri, 13 Dec 2013 14:20:27 GMT
Server: lighttpd/1.4.31
Content-Length: 21
Accept-Ranges: none
Connection: Keep-Alive

{
 succeeded: true
}

HTTP响应-身份验证失败

HTTP/1.1 200 OK
X-Powered-By: PHP/5.4.4-14+deb7u5
Content-Type: text/json; charset=utf8
Date: Fri, 13 Dec 2013 14:20:27 GMT
Server: lighttpd/1.4.31
Content-Length: 22
Accept-Ranges: none
Connection: Keep-Alive

{
 succeeded: false
}

示例服务器实现

重要提示:本网站上的Application Integration Server实现应视为示例实现。这些示例应帮助系统管理员和开发人员快速了解Application Integration Server的工作方式以及如何在自己的环境中使用它们。
请理解,除了本文档之外,没有提供对Application Integration Server示例的进一步支持。除非另有说明,否则这些示例均根据MIT许可的条款和条件发布。

Python

这里可以找到用Python编写的模块化Application Integration Server的实现。