ldap的视频——B站

openldap介绍和使用

1. 理论介绍

1.1. ldap 协议

ldap的视频——B站
openldap介绍和使用
更多还是直接 读 英文的 文档. 本文中 更多都可直接阅读 原版英文文档. 他就是个协议而已.
ldap_is_protocol.png
X.500 和 LDAP : 目录服务的标准. LDAP 是 X.500 的一个简化版本.
difference_between_LADP_and_X.500.png
X.500 是一个协议族.
单独的 LDAP 守护程序 openldap(slapd) 可以被看作是一个轻量级的 X.500 目录服务器. slapd 实现的仅仅是 X.500 模型的一个子集.

缩写 解释
dc domain Component
uid user id
ou organization Unit
cn common Name
sn surname
dn distinguished Name, 唯一辨别名. ,
rdn relative distinguished name
c country
o organization

LDIF的client示例.pngdn的两种设置.png
跨平台, 静态数据快速查询, 在更新数据上不擅长. 基于 pull ,push 复制信息技术. LDAP V3支持 SASL,SSL,TLS,
C/S 架构, server端 存储树, Client 提供操作工具,
LDAP 支持 TCP/IP , 分布式部署.
DIT Directory Information Tree —-数据库
Entry ——表的记录 (dn 的机构. 是 属性-值 的集合. )
LDIF 格式 是用于 LDAP 数据导入, 导出的格式, LDIF 是 LDAP 数据库信息的一种格式 (Light Director Interchange Format. 需要按照 LDAP 中架构的(schema) 格式组织. 如下图所示 LDIF文件示例.pngLDIF文件格式_openLDAP2.3_true.pngLDAP_how_it_works.png

1.2. 重要的配置模式:

  • 1 目录查询
  • 2 目录查询代理 (转发)
  • 3 主从同步

    1.2.1. 目录查询

    LDAP工作模式.png

    1.2.2. 目录查询代理 (转发)

    LDAP代理模式.pngLDAP代理模式——2.png

    1.2.3. 主从同步

    需要他们做擅长的事: 搭建一个最简单, 最实用的模式就行

  • AWK 处理列

  • sed 处理行
  • grep 过滤

主从模式.png

对比mysql 的主从同步来看(mysql 主写从读)
mysql主从同步.png

inotify 服务监控master 数据文件变化, 只要变化就调用 rsync 命令推送数据到 slave. (因为 更新少) , 定时任务( 守护脚本)
ldap同步服务.png
分布式介绍
尽量不跨机房, 是因为 隧道的连接不稳定.
ldap分布式示例1.pngldap分布式示例2.png
openldap 是 ldap 的 open source.

2. 搭建实践

3. docker install

OpenLdap编译安装
安装教程
它主要包括下述4个部分:

  • slapd - 独立LDAP守护服务
  • slurpd - 独立的LDAP更新复制守护服务
  • 实现LDAP协议的库
  • 工具软件和示例客户端

使用docker 安装 openldap https://github.com/osixia/docker-openldap
使用docker 安装 PHPLdapAdmin https://github.com/osixia/docker-phpLDAPadmin
ldap_admin details
ldap_admin official website

  1. docker pull osixia/openldap
  2. docker rm myopenldap;docker run -p 389:389 --name myopenldap --net=host --env LDAP_ORGANISATION="mylitboy" --env LDAP_DOMAIN="mylitboy.com" --env LDAP_ADMIN_PASSWORD="ldap123" --detach osixia/openldap
  3. docker run -d --privileged -p 10004:80 --name myphpldapadmin --env PHPLDAPADMIN_HTTPS=false --env PHPLDAPADMIN_LDAP_HOSTS=192.168.116.130 --detach osixia/phpldapadmin
  4. # echo "Go to: https://$192.168.116.130"
  5. Go to: https://.168.116.130
  6. # echo "Login DN: cn=admin,dn=hpc,dc=com"
  7. Login DN: cn=admin,dn=hpc,dc=com
  8. # echo "Password: test"
  9. Password: test

http://192.168.116.130:10004/
Login DN: cn=admin,dc=mylitboy,dc=com
Password: ldap123

4 连接数调优

openldap—应用场景
从零开始的Devops-统一身份认证
单个服务连接数的限制因素也是 和系统一样的。
max concurrent connectionsLDAPCEO_mails
openldap连接数过多的解决与性能优化
Linux OpenLAP 修改max open files
LDAP-user-group—command
our_company_used_LDAP_details
latest_tutorial 2018年
LDAP答疑解惑
门户中如何实现单点登录和统一身份认证?
《Liferay与CAS及LDAP》
统一身份认证服务

5 libuser , nslcd

libuser

The “libuser” concept is apparently still in progress, but may be completely deployed someday luseradd is equivalent to useradd
libuser_man
libuser_overview
authconfig(8) - Linux man page
nss-pam-ldapd—nslcd

nslcd

The NSS library allows distributing account, group, host and other configuration information from a central LDAP server. Because LDAP is a hierarchical directory service, information can be organised in a manner which reflects an organisational structure. This contrasts with the flat, single domain policy of NIS. LDAP has many of the advantages of NIS+ (security and scalability) without the complexity. The system will work alongside your existing NIS, NIS+, DNS and flat file name services.
名称解析服务
nsswitch:网络服务转换开关

nss-pam-ldapd—nslcd
nss—-Name Service Switch configuration file
nss—-overview

The name service switch is a file named nsswitch.conf(4). It controls how a client machine or application obtains network information. It is used by client applications that call any of the getXbyY() interfaces such as the following.
gethostbyname()
getpwuid()
getpwnam()
getipnodebyname()
The PAM library (module) can be used to perform authentication based on information inside the LDAP directory.
认证服务也是由库文件完成,库文件在/lib/security或者/lib64/security下 配置文件在/etc/pam.d下以login举例,可以看到如下内容
Both libraries consist of a thin NSS or PAM part that proxies the requests to a local daemon (nslcd) that handles the LDAP lookups. This simplifies the software architecture and fixes some scalability and locking problems in the original design of nss_ldap.

nss-pam-ldapd-zhihu-details
pam 模块支持用 LDAP 里的 shadow 密码验证用户