openldap ldapsearchの属性を制限します。

openldap ldapsearchの属性を制限します。

私のディレクトリには次のクエリがあります。

ldapsearch -x -H ldaps://example.com -D "cn=gitlab,ou=Service Accounts,dc=example,dc=com" -w foobar -b "ou=Persons,dc=example,dc=com"

次のolcAccessを使用すると、次のような結果が得られます。

dn: olcDatabase={1}mdb,cn=config
olcAccess: {0}to dn.subtree="ou=Persons,dc=example,dc=com" by dn="cn=gitlab,ou=Service Accounts,dc=example,dc=com" read
olcAccess: {1}to attrs=userPassword,shadowLastChange by self =xw by anonymous auth
olcAccess: {2}to * by self read by * none

(ルール1が先に来なければならず、そうしても良いのですが確実にするために今は下ろします)

結果:

# Persons, example.com
dn: ou=Persons,dc=example,dc=com
objectClass: organizationalUnit
objectClass: top
ou: Persons

# Hans Wurst, Persons, example.com
dn: cn=Hans Wurst,ou=Persons,dc=example,dc=com
givenName: Hans
sn: Wurst
cn: Hans Wurst
uid: hwurst
userPassword:: <PASSWORDHASH>
uidNumber: 1001
gidNumber: 500
homeDirectory: /home/hwurst
loginShell: /bin/bash
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top

# Carla Kaese, Persons, example.com
dn: cn=Carla Kaese,ou=Persons,dc=example,dc=com
gidNumber: 500
givenName: Carla
homeDirectory: /home/ckaese
loginShell: /bin/bash
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
sn: Kaese
uid: ckaese
uidNumber: 1000
cn: Carla Kaese
userPassword:: <PASSWORDHASH>

私の目標は特定の属性のみに読み取りアクセスを制限します。だから私は次のようにaclを変更しました:

dn: olcDatabase={1}mdb,cn=config
olcAccess: {0}to dn.subtree="ou=Persons,dc=example,dc=com" attrs="entry,uid,cn" by dn="cn=gitlab,ou=Service Accounts,dc=example,dc=com" read
olcAccess: {1}to attrs=userPassword,shadowLastChange by self =xw by anonymous auth
olcAccess: {2}to * by self read by * none

追加しましたattrs="entry,uid,cn"

ただし、同じ検索は次のように返されます。

# search result
search: 2
result: 0 Success

私は何が間違っていましたか?私は何を見逃していますか?どのように動作しますか?

ベストアンサー1

ACL は認証フェーズにも影響します。

単純バインディング(DNとパスワードを使用)を使用する場合は、次のようにする必要があります。承認する財産権入り口そしてユーザーパスワード確認する項目にあります。

ただし、AFAICSの最後のACLは、擬似属性への認証されたアクセスを効果的にブロックします。入り口。最後のACL(テストされていない)を試してみましょう。

olcAccess: {2}to * by self read by * auth

おすすめ記事