3.7. Hozzáférés szabályozási példák:

A hozzáférési eszköztár, melyet az access direktíva szabályoz, elég erőteljes. Most bemutatunk néhány példát a használatára vonatkozóan. Először néhány egyszerű példa:

access to * by * read 

Ez a hozzáférési direktíva mindenkinek olvasási jogot biztosít.

A következő példa bemutatja a regexp használatát a DN alapján történő kereséshez két access direktívában, ahol a sorrend is fontos.

access to dn=".*, o=U of M, c=US" 
by * search 
access to dn=".*, c=US" 
by * read 

Ebben az esetben a hozzáférési jogosultságok így alakulnak: Keresési (search) jogosultsággal rendelkeznek az 'o=U of M, c=US' dn-ű felhasználók, míg a többi, c=US jelzetű felhasználó olvasási (read) - eggyel magasabb szintű - jogosultságot kap. Ha fordítva lenne a két access sor, a U of M-re vonatkozó korlátozások nem lépnének életbe, mivel a c=US körbe beletartoznak, és a szűkítés nem lépne életbe. (a hozzáférési listákat felűlről lefelé dolgozza fel a program.)

Another way to implement the same access controls is:

access to dn.children="dc=example,dc=com"
	by * search
	access to dn.children="dc=com"
	by * read

Read access is granted to entries under the dc=com subtree, except for those entries under the dc=example,dc=com subtree, to which search access is granted. No access is granted to dc=com as neither access directive matches this DN. If the order of these access directives was reversed, the trailing directive would never be reached, since all entries under dc=example,dc=com are also under dc=com entries.

Note: Also note that if no access to directive or no "by <who>" clause matches, access is denied. That is, every access to directive ends with an implicit by * none clause and every access list ends with an implicit access to * by * none directive.

A következő példa ismét jól mutatja a sorrend fontosságát. Mind a hozzáférési direktívák (access), mind pedig a "by <kicsoda>" cikkely esetében. Bemutatja továbbá az attribútum kapcsoló használatát, bizonyos attribútumok és többféle <who> kapcsoló hozzáférési jogainak beállításához.

access to dn.subtree="dc=example,dc=com" attr=homePhone
	by self write
	by dn.children=dc=example,dc=com" search
	by peername=IP:10\..+ read
access to dn.subtree="dc=example,dc=com"
	by self write
	by dn.children="dc=example,dc=com" search
	by anonymous auth

This example applies to entries in the "dc=example,dc=com" subtree. To all attributes except homePhone, an entry can write to itself, entries under example.com entries can search by them, anybody else has no access (implicit by * none) excepting for authentication/authorization (which is always done anonymously). The homePhone attribute is writable by the entry, searchable by entries under example.com, readable by clients connecting from network 10, and otherwise not readable (implicit by * none). All other access is denied by the implicit access to * by * none.

Sometimes it is useful to permit a particular DN to add or remove itself from an attribute. For example, if you would like to create a group and allow people to add and remove only their own DN from the member attribute, you could accomplish it with an access directive like this:

access to attr=member,entry 
	by dnattr=member selfwrite 

A dnattr <kicsoda> kapcsoló megmondja,hogy a hozzáférések a 'member' (tag) -jellemzőben felsorolt elemekre vonatkoznak. A 'selfwrite' hozzáférési kapcsoló pedig ezen tagoknak csak saját DN-jükben történő hozzáadásra és törlésre ad jogosultságot. A bejegyzés jellemző hozzáadása kötelező, mivel a bejegyzéshez való hozzáférés során szükségszerűen a bejegyzés jellemzőihez is hozzá kell férnünk.

A hozzáférés szabályozásról rengeteg példa található az OpenLDAP Adminisztrátorok Kézikönyvében. Kattints a linkre: Hozzáférés szabályozás további információkért.