验证一个项目中的LDAP配置
为指定项目验证 LDAP 配置。要使用此资源,请求的服务帐户或 API 密钥必须具有“项目所有者”角色。
路径参数
-
用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。
注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。
格式应符合以下模式:
^([a-f0-9]{24})$
。
查询参数
-
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint
body
必需
要验证的指定项目的 LDAP 配置。
-
MongoDB Cloud 应用轻型目录访问协议 (LDAP) 查询模板来创建 LDAP 查询,以返回与经过身份验证的 MongoDB 用户关联的 LDAP 组。MongoDB Cloud 仅使用此参数进行用户授权。
使用统一资源定位符
{USER}
(URL) 中的 占位符来替换经过身份验证的用户名。该查询与主机名指定的托管相关。根据 RFC4515 和 RFC4516 格式化此查询。默认值为
{USER}?memberOf?base
。 -
MongoDB Cloud 用于验证 bindUsername 的密码。
-
MongoDB Cloud 用于连接到 LDAP 主机的轻型目录访问协议 (LDAP) 用户的完整可分辨名称 (DN)。LDAP 可分辨名称的格式必须符合 RFC 2253。
格式应符合以下模式:
^(?:(?<cn>CN=(?<name>[^,]*)),)?(?:(?<path>(?:(?:CN|OU)=[^,]+,?)+),)?(?<domain>(?:DC=[^,]+,?)+)$
。RFC 2253 -
MongoDB Cloud 用于验证轻量级目录访问协议 (LDAP) 主机身份的证书颁发机构 (CA) 证书。MongoDB Cloud 允许自签名证书。要删除分配的值,请传递空字符串:
"caCertificate": ""
。 -
用户可读的标签,用于标识轻量级目录访问协议 (LDAP) 主机的主机名或 Internet 协议 (IP) 地址。此主机必须能够访问 Internet 或具有与集群的 Virtual Private Cloud (VPC) 对等连接连接。
格式应符合以下模式:
^([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-f]{1,4}:){7}([0-9a-f]{1,4})|(([a-z0-9]+\.){1,10}[a-z]+)?$
。 -
轻量级目录访问协议 (LDAP) 主机侦听客户端连接的 IANA 端口。
默认值为
636
。
atlas api ldapConfiguration verifyGroupUserSecurityLdap --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20230101001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.VerifyGroupUserSecurityLdapApiParams{}
sdkResp, httpResp, err := client.LDAPConfigurationApi.
VerifyGroupUserSecurityLdapWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2023-01-01+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/userSecurity/ldap/verify" \
-d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2023-01-01+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/userSecurity/ldap/verify" \
-d '{ <Payload> }'
{
"authzQueryTemplate": "{USER}?memberOf?base",
"bindPassword": "string",
"bindUsername": "CN=BindUser,CN=Users,DC=myldapserver,DC=mycompany,DC=com",
"caCertificate": "string",
"hostname": "string",
"port": 636
}
{
"groupId": "32b6e34b3d91647abb20e7b8",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"request": {
"bindUsername": "CN=BindUser,CN=Users,DC=myldapserver,DC=mycompany,DC=com",
"caCertificate": "string",
"hostname": "string",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"port": 636
},
"requestId": "32b6e34b3d91647abb20e7b8",
"status": "FAIL",
"validations": [
{
"status": "FAIL",
"validationType": "AUTHENTICATE"
}
]
}
{
"error": 400,
"detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
"reason": "Bad Request",
"errorCode": "VALIDATION_ERROR"
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}