大网数据广告活动
服务器运维问答

Try LDAP Authentication before local authentication

· 52CE 我爱测

I've setup a LDAP system in my local network (CentOS7) and it seems to work as expected. Now I've created a user in LDAP whose username is exact the same as the username of an already existing local user on one of my LDAP clients…

问题原文

原帖链接 · Tim Gräber · CC BY-SA 4.0

I've setup a LDAP system in my local network (CentOS7) and it seems to work as expected. Now I've created a user in LDAP whose username is exact the same as the username of an already existing local user on one of my LDAP clients. When I check for them on the client with like:

getent passwd | grep anakin

I get:

anakin:x:1000:1000:Anakin Skywalker:/home/anakin:/bin/bash
anakin:*:2000:1000:Anakin Skywalker:/home/anakin:/bin/bash

so I know both of them really exist. So when I login to that machine as anakin and check for my ID, it tells me:

uid=1000(anakin) gid=1000(Jedi) [...]

For me that looks like I've been logged in as the local user rather than the LDAP user. Maybe this is setup like this by default, so this is fine, but how do I change this, so I get logged in as the LDAP user before the machine checks for local users with the same username? I suppose this has something to do with pam, but actually all files in /etc/pam.d/ begin with:

# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.

I've tried to solve my problem by using authconfig --disableshadow but haven't made any progress.

Another thing is, if I have different passwords for both users with the same name, I can login with both passwords but always end up as the local user even if I used the LDAP user's password. I don't know if the authentication is really supposed to work like this.

已采纳解答

原帖链接 · oxr463 · CC BY-SA 4.0

This has nothing to do with the configuration files in /etc/pam.d, or even PAM at all.

The service you are referring to is known as Name Service Switch, (NSS); it's purpose is to query information from the different databases available, e.g., passwd, group, shadow, etc.

The order of the entries in /etc/nsswitch.conf are the order that each database will be queried.

As mdpc stated, due to network-related issues, querying users via LDAP may sometimes result in failure. However, this is where something like nscd can help.

Nscd is used to cache these database entries; which can improve performance, but may also be the cause of further confusion, i.e., if the cached user's password changes in the directory, it may take some time before it is updated locally.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-06-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。