📄 slapdconf2.sdf
字号:
The DN specifier behaves much like <what> clause DN specifiers.Other control factors are also supported. For example, a {{EX:<who>}}can be restricted by an entry listed in a DN-valued attribute inthe entry to which the access applies:> dnattr=<dn-valued attribute name>The dnattr specification is used to give access to an entrywhose DN is listed in an attribute of the entry (e.g., giveaccess to a group entry to whoever is listed as the owner ofthe group entry).Some factors may not be appropriate in all environments (or any).For example, the domain factor relies on IP to domain name lookups.As these can easily spoofed, the domain factor should not be avoided.H3: The access to grantThe kind of <access> granted can be one of the following:!block table; colaligns="LRL"; coltags="EX,EX,N"; align=Center; \ title="Table 5.4: Access Levels"Level Privileges Descriptionnone =0 no accessauth =x needed to bindcompare =cx needed to comparesearch =scx needed to apply search filtersread =rscx needed to read search resultswrite =wrscx needed to modify/rename!endblockEach level implies all lower levels of access. So, forexample, granting someone {{EX:write}} access to an entry alsogrants them {{EX:read}}, {{EX:search}}, {{EX:compare}}, and {{EX:auth}} access. However, one may use the privileges specifierto grant specific permissions.H3: Access Control EvaluationWhen evaluating whether some requester should be given access toan entry and/or attribute, slapd compares the entry and/or attributeto the {{EX:<what>}} selectors given in the configuration.For each entry, access controls provided in the database which holdsthe entry (or the first database if not held in any database) applyfirst, followed by the global access directives (which are held inthe {{EX:frontend}} database definition). Within thispriority, access directives are examined in the order in which theyappear in the configuration attribute. Slapd stops with the first {{EX:<what>}}selector that matches the entry and/or attribute. The correspondingaccess directive is the one slapd will use to evaluate access.Next, slapd compares the entity requesting access to the {{EX:<who>}}selectors within the access directive selected above in the orderin which they appear. It stops with the first {{EX:<who>}} selectorthat matches the requester. This determines the access the entityrequesting access has to the entry and/or attribute.Finally, slapd compares the access granted in the selected{{EX:<access>}} clause to the access requested by the client. Ifit allows greater or equal access, access is granted. Otherwise,access is denied.The order of evaluation of access directives makes their placementin the configuration file important. If one access directive ismore specific than another in terms of the entries it selects, itshould appear first in the configuration. Similarly, if one {{EX:<who>}}selector is more specific than another it should come first in theaccess directive. The access control examples given below shouldhelp make this clear.H3: Access Control ExamplesThe access control facility described above is quite powerful. Thissection shows some examples of its use for descriptive purposes.A simple example:> olcAccess: to * by * readThis access directive grants read access to everyone.> olcAccess: to *> by self write> by anonymous auth> by * readThis directive allows the user to modify their entry, allows anonymousto authenticate against these entries, and allows all others toread these entries. Note that only the first {{EX:by <who>}} clausewhich matches applies. Hence, the anonymous users are granted{{EX:auth}}, not {{EX:read}}. The last clause could just as wellhave been "{{EX:by users read}}".It is often desirable to restrict operations based upon the levelof protection in place. The following shows how security strengthfactors (SSF) can be used.> olcAccess: to *> by ssf=128 self write> by ssf=64 anonymous auth> by ssf=64 users readThis directive allows users to modify their own entries if securityprotections of strength 128 or better have been established,allows authentication access to anonymous users, and read accesswhen strength 64 or better security protections have been established. Ifthe client has not establish sufficient security protections, theimplicit {{EX:by * none}} clause would be applied.The following example shows the use of style specifiers to selectthe entries by DN in two access directives where ordering issignificant.> olcAccess: to dn.children="dc=example,dc=com"> by * search> olcAccess: to dn.children="dc=com"> by * readRead access is granted to entries under the {{EX:dc=com}} subtree,except for those entries under the {{EX:dc=example,dc=com}} subtree,to which search access is granted. No access is granted to{{EX:dc=com}} as neither access directive matches this DN. If theorder of these access directives was reversed, the trailing directivewould never be reached, since all entries under {{EX:dc=example,dc=com}}are also under {{EX:dc=com}} entries.Also note that if no {{EX:olcAccess: to}} directive matches or no {{EX:by<who>}} clause, {{B:access is denied}}. That is, every {{EX:olcAccess:to}} directive ends with an implicit {{EX:by * none}} clause andevery access list ends with an implicit {{EX:olcAccess: to * by * none}}directive.The next example again shows the importance of ordering, both ofthe access directives and the {{EX:by <who>}} clauses. It alsoshows the use of an attribute selector to grant access to a specificattribute and various {{EX:<who>}} selectors.> olcAccess: to dn.subtree="dc=example,dc=com" attrs=homePhone> by self write> by dn.children=dc=example,dc=com" search> by peername.regex=IP:10\..+ read> olcAccess: to dn.subtree="dc=example,dc=com"> by self write> by dn.children="dc=example,dc=com" search> by anonymous authThis example applies to entries in the "{{EX:dc=example,dc=com}}"subtree. To all attributes except {{EX:homePhone}}, an entry canwrite to itself, entries under {{EX:example.com}} entries can searchby them, anybody else has no access (implicit {{EX:by * none}})excepting for authentication/authorization (which is always doneanonymously). The {{EX:homePhone}} attribute is writable by theentry, searchable by entries under {{EX:example.com}}, readable byclients connecting from network 10, and otherwise not readable(implicit {{EX:by * none}}). All other access is denied by theimplicit {{EX:access to * by * none}}.Sometimes it is useful to permit a particular DN to add orremove itself from an attribute. For example, if you would like tocreate a group and allow people to add and remove onlytheir own DN from the member attribute, you could accomplishit with an access directive like this:> olcAccess: to attrs=member,entry> by dnattr=member selfwriteThe dnattr {{EX:<who>}} selector says that the access applies toentries listed in the {{EX:member}} attribute. The {{EX:selfwrite}} accessselector says that such members can only add or delete theirown DN from the attribute, not other values. The addition ofthe entry attribute is required because access to the entry isrequired to access any of the entry's attributes.H3: Access Control OrderingSince the ordering of {{EX:olcAccess}} directives is essential to theirproper evaluation, but LDAP attributes normally do not preserve theordering of their values, OpenLDAP uses a custom schema extension tomaintain a fixed ordering of these values. This ordering is maintainedby prepending a {{EX:"{X}"}} numeric index to each value, similarly tothe approach used for ordering the configuration entries. These indextags are maintained automatically by slapd and do not need to be specifiedwhen originally defining the values. For example, when you create thesettings> olcAccess: to attrs=member,entry> by dnattr=member selfwrite> olcAccess: to dn.children="dc=example,dc=com"> by * search> olcAccess: to dn.children="dc=com"> by * readwhen you read them back using slapcat or ldapsearch they will contain> olcAccess: {0}to attrs=member,entry> by dnattr=member selfwrite> olcAccess: {1}to dn.children="dc=example,dc=com"> by * search> olcAccess: {2}to dn.children="dc=com"> by * readThe numeric index may be used to specify a particular value to changewhen using ldapmodify to edit the access rules. This index can be usedinstead of (or in addition to) the actual access value. Using this numeric index is very helpful when multiple access rules are being managed.For example, if we needed to change the second rule above to grantwrite access instead of search, we could try this LDIF:> changetype: modify> delete: olcAccess> olcAccess: to dn.children="dc=example,dc=com" by * search> -> add: olcAccess> olcAccess: to dn.children="dc=example,dc=com" by * write> -But this example {{B:will not}} guarantee that the existing values remain intheir original order, so it will most likely yield a broken securityconfiguration. Instead, the numeric index should be used:> changetype: modify> delete: olcAccess> olcAccess: {1}> -> add: olcAccess> olcAccess: {1}to dn.children="dc=example,dc=com" by * write> -This example deletes whatever rule is in value #1 of the {{EX:olcAccess}}attribute (regardless of its value) and adds a new value that isexplicitly inserted as value #1. The result will be> olcAccess: {0}to attrs=member,entry> by dnattr=member selfwrite> olcAccess: {1}to dn.children="dc=example,dc=com"> by * write> olcAccess: {2}to dn.children="dc=com"> by * readwhich is exactly what was intended.!if 0For more details on how to use the {{EX:access}} directive,consult the {{Advanced Access Control}} chapter.!endifH2: Configuration ExampleThe following is an example configuration, interspersedwith explanatory text. It defines two databases to handledifferent parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}}database instances. The line numbers shown are provided forreference only and are not included in the actual file. First, theglobal configuration section:E: 1. # example config file - global configuration entryE: 2. dn: cn=configE: 3. objectClass: olcGlobalE: 4. cn: configE: 5. olcReferral: ldap://root.openldap.orgE: 6. Line 1 is a comment. Lines 2-4 identify this as the globalconfiguration entry.The {{EX:olcReferral:}} directive on line 5means that queries not local to one of the databases definedbelow will be referred to the LDAP server running on thestandard port (389) at the host {{EX:root.openldap.org}}.Line 6 is a blank line, indicating the end of this entry.E: 7. # internal schemaE: 8. dn: cn=schema,cn=configE: 9. objectClass: olcSchemaConfigE: 10. cn: schemaE: 11. Line 7 is a comment. Lines 8-10 identify this as the root ofthe schema subtree. The actual schema definitions in this entryare hardcoded into slapd so no additional attributes are specified here.Line 11 is a blank line, indicating the end of this entry.E: 12. # include the core schemaE: 13. include: file:///usr/local/etc/openldap/schema/core.ldifE: 14. Line 12 is a comment. Line 13 is an LDIF include directive whichaccesses the {{core}} schema definitions in LDIF format. Line 14is a blank line.Next comes the database definitions. The first database is thespecial {{EX:frontend}} database whose settings are applied globallyto all the other databases.E: 15. # global database parametersE: 16. dn: olcDatabase=frontend,cn=configE: 17. objectClass: olcDatabaseConfigE: 18. olcDatabase: frontendE: 19. olcAccess: to * by * readE: 20. Line 15 is a comment. Lines 16-18 identify this entry as the globaldatabase entry. Line 19 is a global access control. It applies to allentries (after any applicable database-specific access controls).The next entry defines a BDB backend that will handle queries for thingsin the "dc=example,dc=com" portion of the tree. Indices are to be maintainedfor several attributes, and the {{EX:userPassword}} attribute is to beprotected from unauthorized access.E: 21. # BDB definition for example.comE: 22. dn: olcDatabase=bdb,cn=configE: 23. objectClass: olcDatabaseConfigE: 24. objectClass: olcBdbConfigE: 25. olcDatabase: bdbE: 26. olcSuffix: "dc=example,dc=com"E: 27. olcDbDirectory: /usr/local/var/openldap-dataE: 28. olcRootDN: "cn=Manager,dc=example,dc=com"E: 29. olcRootPW: secretE: 30. olcDbIndex: uid pres,eqE: 31. olcDbIndex: cn,sn,uid pres,eq,approx,subE: 32. olcDbIndex: objectClass eqE: 33. olcAccess: to attrs=userPasswordE: 34. by self writeE: 35. by anonymous authE: 36. by dn.base="cn=Admin,dc=example,dc=com" writeE: 37. by * noneE: 38. olcAccess: to *E: 39. by self writeE: 40. by dn.base="cn=Admin,dc=example,dc=com" writeE: 41. by * readE: 42. Line 21 is a comment. Lines 22-25 identify this entry as a BDB databaseconfiguration entry. Line 26 specifies the DN suffixfor queries to pass to this database. Line 27 specifies the directoryin which the database files will live.Lines 28 and 29 identify the database {{super-user}} entry and associatedpassword. This entry is not subject to access control or size ortime limit restrictions.Lines 30 through 32 indicate the indices to maintain for variousattributes.Lines 33 through 41 specify access control for entries in thisdatabase. As this is the first database, the controls also applyto entries not held in any database (such as the Root DSE). Forall applicable entries, the {{EX:userPassword}} attribute is writableby the entry itself and by the "admin" entry. It may be used forauthentication/authorization purposes, but is otherwise not readable.All other attributes are writable by the entry and the "admin"entry, but may be read by all users (authenticated or not).Line 42 is a blank line, indicating the end of this entry.The next section of the example configuration file defines anotherBDB database. This one handles queries involving the{{EX:dc=example,dc=net}} subtree but is managed by the same entityas the first database. Note that without line 51, the read accesswould be allowed due to the global access rule at line 19.E: 42. # BDB definition for example.netE: 43. dn: olcDatabase=bdb,cn=configE: 44. objectClass: olcDatabaseConfigE: 45. objectClass: olcBdbConfigE: 46. olcDatabase: bdbE: 47. olcSuffix: "dc=example,dc=net"E: 48. olcDbDirectory: /usr/local/var/openldap-data-netE: 49. olcRootDN: "cn=Manager,dc=example,dc=com"E: 50. olcDbIndex: objectClass eqE: 51. olcAccess: to * by users read
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -