linux 通过nslcd ldap协议集成 windows AD

方案一

1.nslcd配置

uri: windows AD的ip,389为ldap协议的端口
base: 指定根ou或者cn

cat /etc/nslcd.conf 
# /etc/nslcd.conf
# nslcd configuration file. See nslcd.conf(5)
# for details.

# The user and group nslcd should run as.
uid nslcd
gid nslcd

# The location at which the LDAP server(s) should be reachable.
uri ldap://172.16.0.151:389          
# The search base that will be used for all queries.
base dc=slq,dc=com

# The LDAP protocol version to use.
#ldap_version 3

# The DN to bind with for normal lookups.
binddn readonly@slq.com         
bindpw readonly

# The DN used for password modifications by root.
#rootpwmoddn cn=admin,dc=example,dc=com

# SSL options
ssl off
#tls_reqcert never
tls_cacertfile /etc/ssl/certs/ca-certificates.crt

# The search scope.

2.为windows AD用户及组增加posix属性

直接在windows AD上手动增加的用户及组并不能通过nslcd ldap协议在Linux上查询到,需要为其增加必要的属性

在windows AD域管理窗口,查看->勾选高级选项,新增用户及组后,在其属性中为其增加如下属性。


* gidNumber: 1500                 # 组gid

* objectClass: posixGroup         # 每个组固定添加

* cn: slq                         # 组名

用户


* objectClass: posixAccount   # 每个用户固定添加

* objectClass: shadowAccount  # 每个用户固定添加

* cn: slq              # 用户名

* uid: slq             # 用户uid,需要唯一  

* uidNumber: 1500             # 用户uid,需要唯一,不能重复  一般大于等于1000

* homeDirectory: "/home/users/slq"   # 用户家目录,如果不设置,会su - 用户时报错

* gidNumber: 1500             # 用户加入的组gid   

增加成功之后即可正常的查询用户,及认证登录了,也可以设置增加到sudo组中

方案二

nslcd mapping方式

sudo apt-get install libnss-ldapd libpam-ldapd 

编辑/etc/nsswitch.conf文件

修改/etc/nslcd.conf文件,objectSid为windows AD域的objectId属性

参考: https://social.technet.microsoft.com/wiki/contents/articles/20590.management-of-sids-in-active-directory.aspx#:~:text=Each Active Directory domain has a unique identifier,and an RID (Relative Identifier) as a suffix%3A

posted @ 2022-09-05 09:39  你若安好便是晴天1208  阅读(748)  评论(0编辑  收藏  举报