如何保护LDAP

不知道这是属于更多的serverfault或不…

背景:

我正在使用openldap和pam / nss / ldap在我的服务器上进行身份validation(networking邮件等)。

我的文件,工作正常:

/etc/openldap/slapd.conf:

include /etc/openldap/schema/core.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/nis.schema allow bind_v2 pidfile /var/run/slapd/slapd.pid argsfile /var/run/slapd.args loglevel 0 access to attrs=userPassword,shadowLastChange by dn="cn=Admin,dc=MYDOMAIN,dc=com" write by anonymous auth by self write by * none access to * by dn="cn=Admin,dc=MYDOMAIN,dc=com" write by * read database bdb suffix dc=MYDOMAIN,dc=com rootdn cn=Manager,dc=MYDOMAIN,dc=com directory /var/lib/ldap index objectClass eq,pres index ou,cn,mail,surname,givenname eq,pres,sub index uidNumber,gidNumber,loginShell eq,pres index uid,memberUid eq,pres,sub index nisMapName,nisMapEntry eq,pres,sub 

但是,当我将访问权限更改为:

 access to * by self write by users read by anonymous auth access to attrs=userPassword by self write by anonymous auth by * none 

我不能再login了。 我怎么写这个,以便我仍然可以login,但世界上的每个人都没有读取写入?

我想如果你这样做:

 access to attrs=userPassword,shadowLastChange by dn="cn=Admin,dc=MYDOMAIN,dc=com" write by anonymous auth by self write by * none access to * by dn="cn=Admin,dc=MYDOMAIN,dc=com" write by self write by anonymous auth by users read by * none 

你会有你想要的。

我已经发现,至less在debian上的samba,你必须给读login帐户的几个属性:

 access to attrs=userPassword by anonymous auth by * none access to dn.subtree="ou=People,dc=MYDOMAIN,dc=com" attrs=dc,cn,uid,gecos,entry by * read access to * by dn="cn=admin,dc=MYDOMAIN,dc=com" write by peername.ip=127.0.0.1 read by * none 

dn.subtree =“ou = …”增加了额外的安全性,所以你只能暴露匿名真正不可避免的。 这意味着匿名无法search/浏览这个子树BTW,他/她只能猜测正确的dc,cn,无论您的应用程序/服务需要。

通过peername.ip = 127 …应该是可以避免的,如果你使所有的应用程序/服务使用pipe理员帐户login或如果你想只读访问您的应用程序,你可以做一个特殊的DN,你可以然后跳过peername.ip节。

你的问题可能是命令。 看起来好像你把这个条目放在顶端,而不是它所在的底部。

此外,如果您对安全感兴趣,则需要使用TLS或SSL来保护通信渠道。