⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slapo-rwm.5

📁 ldap服务器源码
💻 5
📖 第 1 页 / 共 2 页
字号:
Substitution escaping has been delegated to the `$' symbol, which is used instead of `\e' in string substitution patternsbecause `\e' is already escaped by slapd's low level parsing routines;as a consequence, regex escaping requirestwo `\e' symbols, e.g. `\fB.*\e.foo\e.bar\fP' mustbe written as `\fB.*\e\e.foo\e\e.bar\fP'..\".\" The symbol can be altered at will by redefining the related macro in.\" "rewrite-int.h"..\".SH "Rewrite Context"A rewrite context is a set of rules which are applied in sequence.The basic idea is to have an application initialize a rewriteengine (think of Apache's mod_rewrite ...) with a set of rewritecontexts; when string rewriting is required, one invokes theappropriate rewrite context with the input string and obtains thenewly rewritten one if no errors occur..LPEach basic server operation is associated to a rewrite context;they are divided in two main groups: client \-> server andserver \-> client rewriting..LPclient -> server:.LP.RS.nf(default)            if defined and no specific context                      is availablebindDN               bindsearchDN             searchsearchFilter         searchsearchFilterAttrDN   searchcompareDN            comparecompareAttrDN        compare AVAaddDN                addaddAttrDN            add AVA (DN portion of "ref" excluded)modifyDN             modifymodifyAttrDN         modify AVA (DN portion of "ref" excluded)referralAttrDN       add/modify DN portion of referrals                     (default to none)modrDN               modrdnnewSuperiorDN        modrdndeleteDN             deleteexopPasswdDN         password modify extended operation DN.fi.RE.LPserver -> client:.LP.RS.nfsearchEntryDN        search (only if defined; no default;                     acts on DN of search entries)searchAttrDN         search AVA (only if defined; defaults                     to searchEntryDN; acts on DN-syntax                     attributes of search results)matchedDN            all ops (only if applicable; defaults                     to searchEntryDN)referralDN           all ops (only if applicable; defaults                     to none).fi.RE.LP.SH "Basic Configuration Syntax"All rewrite/remap directives start with the prefix.BR rwm- ;for backwards compatibility with the historical.BR slapd-ldap (5)and.BR slapd-meta (5)builtin rewrite/remap capabilities, the prefix may be omitted, but this practice is strongly discouraged..TP.B rwm-rewriteEngine { on | off }If `on', the requested rewriting is performed; if `off', norewriting takes place (an easy way to stop rewriting withoutaltering too much the configuration file)..TP.B rwm-rewriteContext <context name> "[ alias <aliased context name> ]"<Context name> is the name that identifies the context, i.e. the nameused by the application to refer to the set of rules it contains.It is used also to reference sub contexts in string rewriting.A context may alias another one.In this case the alias context contains no rule, and any reference toit will result in accessing the aliased one..TP.B rwm-rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"Determines how a string can be rewritten if a pattern is matched.Examples are reported below..SH "Additional Configuration Syntax".TP.B rwm-rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"Allows to define a map that transforms substring rewriting intosomething else.The map is referenced inside the substitution pattern of a rule..TP.B rwm-rewriteParam <param name> <param value>Sets a value with global scope, that can be dereferenced by thecommand `${$paramName}'..TP.B rwm-rewriteMaxPasses <number of passes> [<number of passes per rule>]Sets the maximum number of total rewriting passes that can beperformed in a single rewrite operation (to avoid loops).A safe default is set to 100; note that reaching this limit is stilltreated as a success; recursive invocation of rules is simply interrupted.The count applies to the rewriting operation as a whole, not to any single rule; an optional per-rule limit can be set.This limit is overridden by setting specific per-rule limitswith the `M{n}' flag..SH "REWRITE CONFIGURATION EXAMPLES".nf# set to `off' to disable rewritingrwm-rewriteEngine on# the rules the "suffixmassage" directive impliesrwm-rewriteEngine on# all dataflow from client to server referring to DNsrwm-rewriteContext defaultrwm-rewriteRule "(.+,)?<virtualnamingcontext>$" "$1<realnamingcontext>" ":"# empty filter rulerwm-rewriteContext searchFilter# all dataflow from server to clientrwm-rewriteContext searchEntryDNrwm-rewriteRule "(.+,)?<realnamingcontext>$" "$1<virtualnamingcontext>" ":"rwm-rewriteContext searchAttrDN alias searchEntryDNrwm-rewriteContext matchedDN alias searchEntryDN# misc empty rulesrwm-rewriteContext referralAttrDNrwm-rewriteContext referralDN# Everything defined here goes into the `default' context.# This rule changes the naming context of anything sent# to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'rwm-rewriteRule "(.+,)?dc=home,[ ]?dc=net$"            "$1dc=OpenLDAP, dc=org"  ":"# since a pretty/normalized DN does not include spaces# after rdn separators, e.g. `,', this rule suffices:rwm-rewriteRule "(.+,)?dc=home,dc=net$"            "$1dc=OpenLDAP,dc=org"  ":"# Start a new context (ends input of the previous one).# This rule adds blanks between DN parts if not present.rwm-rewriteContext  addBlanksrwm-rewriteRule     "(.*),([^ ].*)" "$1, $2"# This one eats blanksrwm-rewriteContext  eatBlanksrwm-rewriteRule     "(.*), (.*)" "$1,$2"# Here control goes back to the default rewrite# context; rules are appended to the existing ones.# anything that gets here is piped into rule `addBlanks'rwm-rewriteContext  defaultrwm-rewriteRule     ".*" "${>addBlanks($0)}" ":".\" # Anything with `uid=username' is looked up in.\" # /etc/passwd for gecos (I know it's nearly useless,.\" # but it is there just as a guideline to implementing.\" # custom maps)..\" # Note the `I' flag that leaves `uid=username' in place .\" # if `username' does not have a valid account, and the.\" # `:' that forces the rule to be processed exactly once..\" rwm-rewriteContext  uid2Gecos.\" rwm-rewriteRule     "(.*)uid=([a-z0-9]+),(.+)".\"                 "$1cn=$2{xpasswd},$3"      "I:".\" .\" # Finally, in a bind, if one uses a `uid=username' DN,.\" # it is rewritten in `cn=name surname' if possible..\" rwm-rewriteContext  bindDN.\" rwm-rewriteRule     ".*" "${>addBlanks(${>uid2Gecos($0)})}" ":".\" # Rewrite the search base according to `default' rules.rwm-rewriteContext  searchDN alias default# Search results with OpenLDAP DN are rewritten back with# `dc=home,dc=net' naming context, with spaces eaten.rwm-rewriteContext  searchEntryDNrwm-rewriteRule     "(.*[^ ],)?[ ]?dc=OpenLDAP,[ ]?dc=org$"                "${>eatBlanks($1)}dc=home,dc=net"    ":"# Bind with email instead of full DN: we first need# an ldap map that turns attributes into a DN (the# argument used when invoking the map is appended to # the URI and acts as the filter portion)rwm-rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"# Then we need to detect DN made up of a single email,# e.g. `mail=someone@example.com'; note that the rule# in case of match stops rewriting; in case of error,# it is ignored.  In case we are mapping virtual# to real naming contexts, we also need to rewrite# regular DNs, because the definition of a bindDN# rewrite context overrides the default definition.rwm-rewriteContext bindDNrwm-rewriteRule "^mail=[^,]+@[^,]+$" "${attr2dn($0)}" ":@I"# This is a rather sophisticated example. It massages a# search filter in case who performs the search has# administrative privileges.  First we need to keep# track of the bind DN of the incoming request, which is# stored in a variable called `binddn' with session scope,# and left in place to allow regular binding:rwm-rewriteContext  bindDNrwm-rewriteRule     ".+" "${&&binddn($0)}$0" ":"# A search filter containing `uid=' is rewritten only# if an appropriate DN is bound.# To do this, in the first rule the bound DN is# dereferenced, while the filter is decomposed in a# prefix, in the value of the `uid=<arg>' AVA, and # in a suffix. A tag `<>' is appended to the DN. # If the DN refers to an entry in the `ou=admin' subtree, # the filter is rewritten OR-ing the `uid=<arg>' with# `cn=<arg>'; otherwise it is left as is. This could be# useful, for instance, to allow apache's auth_ldap-1.4# module to authenticate users with both `uid' and# `cn', but only if the request comes from a possible# `cn=Web auth,ou=admin,dc=home,dc=net' user.rwm-rewriteContext searchFilterrwm-rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"  "${**binddn}<>${&prefix($1)}${&arg($2)}${&suffix($3)}"  ":I"rwm-rewriteRule "^[^,]+,ou=admin,dc=home,dc=net$"  "${*prefix}|(uid=${*arg})(cn=${*arg})${*suffix}" ":@I"rwm-rewriteRule ".*<>$" "${*prefix}uid=${*arg}${*suffix}" ":"# This example shows how to strip unwanted DN-valued# attribute values from a search result; the first rule# matches DN values below "ou=People,dc=example,dc=com";# in case of match the rewriting exits successfully.# The second rule matches everything else and causes# the value to be rejected.rwm-rewriteContext searchEntryDNrwm-rewriteRule ".+,ou=People,dc=example,dc=com$" "$0" ":@"rwm-rewriteRule ".*" "" "#".fi.SH "MAPPING EXAMPLES"The following directives map the object class `groupOfNames' tothe object class `groupOfUniqueNames' and the attribute type`member' to the attribute type `uniqueMember':.LP.RS.nfmap objectclass groupOfNames groupOfUniqueNamesmap attribute uniqueMember member.fi.RE.LPThis presents a limited attribute set from the foreignserver:.LP.RS.nfmap attribute cn *map attribute sn *map attribute manager *map attribute description *map attribute *.fi.RE.LPThese lines map cn, sn, manager, and description to themselves, and any other attribute gets "removed" from the object before it is sent to the client (or sent up to the LDAP server).  This is obviously a simplistic example, but you get the point..SH FILES.TPETCDIR/slapd.confdefault slapd configuration file.SH SEE ALSO.BR slapd.conf (5),.BR slapd\-ldap (5),.BR slapd\-meta (5),.BR slapd\-relay (5),.BR slapd (8),.BR regex (7),.BR re_format (7)..SH AUTHORPierangelo Masarati; based on back-ldap rewrite/remap featuresby Howard Chu, Pierangelo Masarati.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -