You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenLDAP中包含schema、host、port的URI参数相关问题咨询

OpenLDAP URI参数常见问题解答

1. 包含schema、host、port字段的OpenLDAP URI参数是什么

OpenLDAP遵循标准LDAP URI规范,仅包含schema、host、port三个字段的URI基础格式为:
{schema}://{host}:{port}
各字段说明:

  • schema:协议标识,常用取值为ldap(明文LDAP协议,默认端口389)、ldaps(SSL/TLS加密LDAP协议,默认端口636)、ldapi(Unix域套接字通信协议,多用于本地管理)
  • host:LDAP服务端的域名或IP地址,本地访问可填写localhost
  • port:LDAP服务端监听的端口,省略时会自动使用对应schema的默认端口

合法示例:
ldap://10.0.0.5:389、ldaps://ldap.myorg.com


2. 官方表述的具体含义

官方原句引用:

the uri parameter may be a comma- or whitespace-separated list of URIs containing only the schema, the host, and the port fields

这句话的中文含义为:uri参数可以是由逗号或空格分隔的URI列表,每个URI仅需包含协议(schema)、主机(host)和端口(port)字段,具体可以拆解为两个使用规则:

  • 传入的URI不需要携带查询条件、绑定DN、属性过滤等额外内容,仅保留三个核心字段即可被OpenLDAP客户端识别
  • 支持同时传入多个服务端URI,多个URI之间用逗号或者空格分隔即可,OpenLDAP客户端会按顺序尝试连接列表中的服务端,前一个连接失败时自动切换到下一个,可实现服务高可用配置

C语言开发示例(ldap_initialize接口传入多URI):

#include <stdio.h>
#include <ldap.h>

int main() {
    LDAP *ldap_handle;
    // 传入空格分隔的两个LDAP服务URI
    int ret = ldap_initialize(&ldap_handle, "ldap://ldap1.myorg.com ldaps://ldap2.myorg.com:1636");
    if (ret != LDAP_SUCCESS) {
        ldap_perror(ldap_handle, "初始化LDAP连接失败");
        return -1;
    }
    // 后续绑定、增删改查操作逻辑
    ldap_unbind_ext_s(ldap_handle, NULL, NULL);
    return 0;
}

内容的提问来源于stack exchange,提问作者Logan Cadman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 23:15:07