]> git.sur5r.net Git - openldap/blobdiff - doc/man/man5/slapo-rwm.5
cleanup
[openldap] / doc / man / man5 / slapo-rwm.5
index 64a0ff533a9ec7df0615001ce11e03294cdf7f11..b1d58b55297070625827803783e448737c9e391f 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-RWM 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation, All Rights Reserved.
+.\" Copyright 1998-2006 The OpenLDAP Foundation, All Rights Reserved.
 .\" Copying restrictions apply.  See the COPYRIGHT file.
 .\" Copyright 2004, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
 .\" $OpenLDAP$
@@ -22,6 +22,8 @@ either remotely, in conjunction with the proxy backend described in
 .BR slapd-ldap (5),
 or locally, in conjunction with the relay backend described in
 .BR slapd-relay (5).
+.LP
+This overlay is experimental.
 .SH MAPPING
 An important feature of the
 .B rwm
@@ -39,19 +41,36 @@ slapd's schema, some attribute names might be different but serve the
 same purpose, etc.
 If local or foreign name is `*', the name is preserved.
 If local name is omitted, the foreign name is removed.
-Unmapped names are preseved if both local and foreign name are `*',
+Unmapped names are preserved if both local and foreign name are `*',
 and removed if local name is omitted and foreign name is `*'.
 .LP
 The local 
 .I objectClasses 
 and 
 .I attributeTypes 
-must be defined in the local schema; the foreign ones do not have to.
+must be defined in the local schema; the foreign ones do not have to,
+but users are encouraged to explicitly define the remote attributeTypes
+and the objectClasses they intend to map.  All in all, when remapping
+a remote server via back-ldap (\fBslapd-ldap\fP(5)) 
+or back-meta (\fBslapd-meta\fP(5))
+their definition can be easily obtained by querying the \fIsubschemaSubentry\fP
+of the remote server; the problem should not exist when remapping a local 
+database.
 Note, however, that the decision whether to rewrite or not attributeTypes
 with 
 .IR "distinguishedName syntax" ,
 requires the knowledge of the attributeType syntax.
 See the REWRITING section for details.
+.LP
+Note that when mapping DN-valued attributes from local to remote,
+first the DN is rewritten, and then the attributeType is mapped;
+while mapping from remote to local, first the attributeType is mapped,
+and then the DN is rewritten.
+As such, it is important that the local attributeType is appropriately
+defined as using the distinguishedName syntax.
+Also, note that there are DN-related syntaxes (i.e. compound types with
+a portion that is DN-valued), like nameAndOptionalUID,
+whose values are currently not rewritten.
 .SH SUFFIX MASSAGING
 A basic feature of the
 .B rwm
@@ -60,15 +79,24 @@ and a real naming context by means of the
 .B rwm-suffixmassage
 directive.
 .TP
-.B rwm-suffixmassage "<virtual naming context>" "<real naming context>"
+.B rwm-suffixmassage "[<virtual naming context>]" "<real naming context>"
 Shortcut to implement naming context rewriting; the trailing part
 of the DN is rewritten from the virtual to the real naming context
-in the bindDN, searchBase, searchFilterAttrDN, compareDN, compareAttrDN,
+in the bindDN, searchDN, searchFilterAttrDN, compareDN, compareAttrDN,
 addDN, addAttrDN, modifyDN, modifyAttrDN, modrDN, newSuperiorDN,
 deleteDN, exopPasswdDN, and from the real to the virtual naming context
-in the searchResult, searchAttrDN and matchedDN rewrite contexts.
-By default no rewriting occurs for the searchFilter rewrite context.
-This directive implies setting the
+in the searchEntryDN, searchAttrDN and matchedDN rewrite contexts.
+By default no rewriting occurs for the searchFilter 
+and for the referralAttrDN and referralDN rewrite contexts.
+If no \fI<virtual naming context>\fP is given, the first suffix of the
+database is used; this requires the 
+.B rwm-suffixmassage
+directive be defined \fIafter\fP the database
+.B suffix
+directive.
+The
+.B rwm-suffixmassage
+directive automatically sets the
 .B rwm-rewriteEngine
 to
 .BR ON .
@@ -77,7 +105,7 @@ See the REWRITING section for details.
 .SH REWRITING
 A string is rewritten according to a set of rules, called a `rewrite
 context'.
-The rules are based on Regular Expressions (POSIX regex) with
+The rules are based on POSIX (''extended'') regular expressions with
 substring matching; basic variable substitution and map resolution 
 of substrings is allowed by specific mechanisms detailed in the following.
 The behavior of pattern matching/substitution can be altered by a set
@@ -94,7 +122,7 @@ The underlying concept is to build a lightweight rewrite module
 for the slapd server (initially dedicated to the LDAP backend):
 .LP
 .SH Passes
-An incoming string is matched agains a set of 
+An incoming string is matched against a set of
 .IR rewriteRules .
 Rules are made of a 
 .IR "regex match pattern" , 
@@ -123,7 +151,7 @@ alter the actions that are taken after substitution.
 honors case in matching (default is case insensitive)
 .TP
 .B `R'
-use POSIX Basic Regular Expressions (default is Extended)
+use POSIX ''basic'' regular expressions (default is ''extended'')
 .TP
 .B `M{n}'
 allow no more than
@@ -162,15 +190,15 @@ n
 as return code if the rule matches; the flag does not alter the recursive
 behavior of the rule, so, to have it performed only once, it must be used 
 in combination with `:', e.g.
-.B `:U{16}'
-returns the value `16' after exactly one execution of the rule, if the
-pattern matches.
+.B `:U{32}'
+returns the value `32' (indicating noSuchObject) after exactly 
+one execution of the rule, if the pattern matches.
 As a consequence, its behavior is equivalent to `@', with the return
 code set to
 .BR n ;
 or, in other words, `@' is equivalent to `U{0}'.
-By convention, the freely available codes are above 16 included;
-the others are reserved.
+Positive errors are allowed, indicating the related LDAP error codes
+as specified in \fIdraft-ietf-ldapbis-protocol\fP.
 .LP
 The ordering of the flags can be significant.
 For instance: `IG{2}' means ignore errors and jump two lines ahead
@@ -180,15 +208,19 @@ errors, but jump two lines ahead only in case of match.
 More flags (mainly Action Flags) will be added as needed.
 .SH "Pattern Matching"
 See
-.BR regex (7).
+.BR regex (7)
+and/or
+.BR re_format (7).
 .SH "Substitution Pattern Syntax"
 Everything starting with `$' requires substitution;
 .LP
-the only obvious exception is `$$', which is left as is;
+the only obvious exception is `$$', which is turned into a single `$';
 .LP
 the basic substitution is `$<d>', where `<d>' is a digit;
 0 means the whole string, while 1-9 is a submatch, as discussed in 
-.BR regex (7);
+.BR regex (7)
+and/or
+.BR re_format (7).
 .LP
 a `$' followed by a `{' invokes an advanced substitution.
 The pattern is:
@@ -226,7 +258,7 @@ operation structure which can be dereferenced later; operator
 assigns a variable in the rewrite context scope; operator
 .B &&
 assigns a variable that scopes the entire session, e.g. its value
-can be derefenced later by other rewrite contexts
+can be dereferenced later by other rewrite contexts
 .TP
 .B *
 variable dereferencing; <name> must refer to a variable that is
@@ -254,9 +286,8 @@ directive.
 Substitution escaping has been delegated to the `$' symbol, 
 which is used instead of `\e' in string substitution patterns
 because `\e' is already escaped by slapd's low level parsing routines;
-as a consequence, 
-.BR regex (7)
-escaping requires two `\e' symbols, e.g. `\fB.*\e.foo\e.bar\fP' must
+as a consequence, regex escaping requires
+two `\e' symbols, e.g. `\fB.*\e.foo\e.bar\fP' must
 be written as `\fB.*\e\e.foo\e\e.bar\fP'.
 .\"
 .\" The symbol can be altered at will by redefining the related macro in
@@ -281,19 +312,21 @@ client -> server:
 (default)            if defined and no specific context 
                      is available
 bindDN               bind
-searchBase           search
+searchDN             search
 searchFilter         search
 searchFilterAttrDN   search
 compareDN            compare
 compareAttrDN        compare AVA
 addDN                add
-addAttrDN            add AVA
+addAttrDN            add AVA (DN portion of "ref" excluded)
 modifyDN             modify
-modifyAttrDN         modify AVA
+modifyAttrDN         modify AVA (DN portion of "ref" excluded)
+referralAttrDN       add/modify DN portion of referrals
+                     (default to none)
 modrDN               modrdn
 newSuperiorDN        modrdn
 deleteDN             delete
-exopPasswdDN         passwd exop DN if proxy
+exopPasswdDN         password modify extended operation DN
 .fi
 .RE
 .LP
@@ -301,11 +334,15 @@ server -> client:
 .LP
 .RS
 .nf
-searchResult         search (only if defined; no default;
-                     acts on DN and DN-syntax attributes 
-                     of search results)
-searchAttrDN         search AVA
-matchedDN            all ops (only if applicable)
+searchEntryDN        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
@@ -328,7 +365,7 @@ altering too much the configuration file).
 <Context name> is the name that identifies the context, i.e. the name
 used 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 aliase another one.
+A context may alias another one.
 In this case the alias context contains no rule, and any reference to
 it will result in accessing the aliased one.
 .TP
@@ -356,7 +393,7 @@ 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 limits
 with the `M{n}' flag.
-.SH "Configuration Examples"
+.SH "REWRITE CONFIGURATION EXAMPLES"
 .nf
 # set to `off' to disable rewriting
 rwm-rewriteEngine on
@@ -365,26 +402,29 @@ rwm-rewriteEngine on
 rwm-rewriteEngine on
 # all dataflow from client to server referring to DNs
 rwm-rewriteContext default
-rwm-rewriteRule "(.*)<virtualnamingcontext>$" "$1<realnamingcontext>" ":"
+rwm-rewriteRule "(.+,)?<virtualnamingcontext>$" "$1<realnamingcontext>" ":"
 # empty filter rule
 rwm-rewriteContext searchFilter
 # all dataflow from server to client
-rwm-rewriteContext searchResult
-rwm-rewriteRule "(.*)<realnamingcontext>$" "$1<virtualnamingcontext>" ":"
-rwm-rewriteContext searchAttrDN alias searchResult
-rwm-rewriteContext matchedDN alias searchResult
+rwm-rewriteContext searchEntryDN
+rwm-rewriteRule "(.+,)?<realnamingcontext>$" "$1<virtualnamingcontext>" ":"
+rwm-rewriteContext searchAttrDN alias searchEntryDN
+rwm-rewriteContext matchedDN alias searchEntryDN
+# misc empty rules
+rwm-rewriteContext referralAttrDN
+rwm-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$"
+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$"
+rwm-rewriteRule "(.+,)?dc=home,dc=net$"
             "$1dc=OpenLDAP,dc=org"  ":"
 
 # Start a new context (ends input of the previous one).
@@ -394,7 +434,7 @@ rwm-rewriteRule     "(.*),([^ ].*)" "$1, $2"
 
 # This one eats blanks
 rwm-rewriteContext  eatBlanks
-rwm-rewriteRule     "(.*),[ ](.*)" "$1,$2"
+rwm-rewriteRule     "(.*), (.*)" "$1,$2"
 
 # Here control goes back to the default rewrite
 # context; rules are appended to the existing ones.
@@ -419,11 +459,11 @@ rwm-rewriteRule     ".*" "${>addBlanks($0)}" ":"
 .\" rwm-rewriteRule     ".*" "${>addBlanks(${>uid2Gecos($0)})}" ":"
 .\" 
 # Rewrite the search base according to `default' rules.
-rwm-rewriteContext  searchBase alias default
+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  searchResult
+rwm-rewriteContext  searchEntryDN
 rwm-rewriteRule     "(.*[^ ],)?[ ]?dc=OpenLDAP,[ ]?dc=org$"
                 "${>eatBlanks($1)}dc=home,dc=net"    ":"
 
@@ -438,7 +478,7 @@ rwm-rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
 # 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
+# regular DNs, because the definition of a bindDN
 # rewrite context overrides the default definition.
 rwm-rewriteContext bindDN
 rwm-rewriteRule "^mail=[^,]+@[^,]+$" "${attr2dn($0)}" ":@I"
@@ -479,10 +519,39 @@ rwm-rewriteRule ".*<>$" "${*prefix}uid=${*arg}${*suffix}" ":"
 # in case of match the rewriting exits successfully.
 # The second rule matches everything else and causes
 # the value to be rejected.
-rwm-rewriteContext searchResult
-rwm-rewriteRule ".*,ou=People,dc=example,dc=com$" "$0" ":@"
+rwm-rewriteContext searchEntryDN
+rwm-rewriteRule ".+,ou=People,dc=example,dc=com$" "$0" ":@"
 rwm-rewriteRule ".*" "" "#"
 .fi
+.SH "MAPPING EXAMPLES"
+The following directives map the object class `groupOfNames' to
+the object class `groupOfUniqueNames' and the attribute type
+`member' to the attribute type `uniqueMember':
+.LP
+.RS
+.nf
+map objectclass groupOfNames groupOfUniqueNames
+map attribute uniqueMember member
+.fi
+.RE
+.LP
+This presents a limited attribute set from the foreign
+server:
+.LP
+.RS
+.nf
+map attribute cn *
+map attribute sn *
+map attribute manager *
+map attribute description *
+map attribute *
+.fi
+.RE
+.LP
+These 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
 .TP
 ETCDIR/slapd.conf
@@ -493,7 +562,8 @@ default slapd configuration file
 .BR slapd\-meta (5),
 .BR slapd\-relay (5),
 .BR slapd (8),
-.BR regex (7).
+.BR regex (7),
+.BR re_format (7).
 .SH AUTHOR
 Pierangelo Masarati; based on back-ldap rewrite/remap features
 by Howard Chu, Pierangelo Masarati.