]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Thu, 20 Jan 2005 19:03:41 +0000 (19:03 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 20 Jan 2005 19:03:41 +0000 (19:03 +0000)
809 files changed:
CHANGES
COPYRIGHT
INSTALL
Makefile.in
README
acconfig.h
acinclude.m4
aclocal.m4
build/config.guess
build/config.sub
build/crupdate
build/dir.mk
build/info.mk
build/lib-shared.mk
build/lib-static.mk
build/lib.mk
build/ltmain.sh
build/man.mk
build/mkdep
build/mkdep.aix
build/mkrelease
build/mkvers.bat
build/mkversion
build/mod.mk
build/openldap.m4
build/rules.mk
build/srv.mk
build/top.mk
build/version.h
build/version.sh
build/version.var
clients/Makefile.in
clients/tools/Makefile.in
clients/tools/common.c
clients/tools/common.h
clients/tools/ldapcompare.c
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldappasswd.c
clients/tools/ldapsearch.c
clients/tools/ldapwhoami.c
configure
configure.in
contrib/ldapc++/COPYRIGHT
contrib/ldapc++/src/ac/time.h
contrib/slapd-modules/comp_match/Makefile
contrib/slapd-modules/dsaschema/README
contrib/slapd-modules/dsaschema/dsaschema.c
contrib/slapd-modules/passwd/README
contrib/slapd-modules/passwd/kerberos.c
contrib/slapd-modules/passwd/netscape.c
contrib/slapd-modules/smbk5pwd/README
contrib/slapd-modules/smbk5pwd/smbk5pwd.c
contrib/slapd-tools/README
contrib/slapi-plugins/addrdnvalues/README
doc/Makefile.in
doc/man/Makefile.in
doc/man/man1/Makefile.in
doc/man/man1/ldapcompare.1
doc/man/man1/ldapdelete.1
doc/man/man1/ldapmodify.1
doc/man/man1/ldapmodrdn.1
doc/man/man1/ldappasswd.1
doc/man/man1/ldapsearch.1
doc/man/man1/ldapwhoami.1
doc/man/man3/Makefile.in
doc/man/man3/lber-decode.3
doc/man/man3/lber-encode.3
doc/man/man3/lber-memory.3
doc/man/man3/lber-types.3
doc/man/man3/ldap.3
doc/man/man3/ldap_abandon.3
doc/man/man3/ldap_add.3
doc/man/man3/ldap_bind.3
doc/man/man3/ldap_compare.3
doc/man/man3/ldap_delete.3
doc/man/man3/ldap_error.3
doc/man/man3/ldap_first_attribute.3
doc/man/man3/ldap_first_entry.3
doc/man/man3/ldap_first_message.3
doc/man/man3/ldap_first_reference.3
doc/man/man3/ldap_get_dn.3
doc/man/man3/ldap_get_values.3
doc/man/man3/ldap_modify.3
doc/man/man3/ldap_modrdn.3
doc/man/man3/ldap_open.3
doc/man/man3/ldap_parse_reference.3
doc/man/man3/ldap_parse_result.3
doc/man/man3/ldap_result.3
doc/man/man3/ldap_schema.3
doc/man/man3/ldap_search.3
doc/man/man3/ldap_sort.3
doc/man/man3/ldap_url.3
doc/man/man5/Makefile.in
doc/man/man5/ldap.conf.5
doc/man/man5/ldif.5
doc/man/man5/slapd-bdb.5
doc/man/man5/slapd-dnssrv.5
doc/man/man5/slapd-ldap.5
doc/man/man5/slapd-ldbm.5
doc/man/man5/slapd-meta.5
doc/man/man5/slapd-monitor.5
doc/man/man5/slapd-passwd.5
doc/man/man5/slapd-shell.5
doc/man/man5/slapd-sql.5
doc/man/man5/slapd.access.5
doc/man/man5/slapd.conf.5
doc/man/man5/slapd.plugin.5
doc/man/man5/slapd.replog.5
doc/man/man5/slapo-chain.5
doc/man/man5/slapo-glue.5
doc/man/man5/slapo-lastmod.5
doc/man/man5/slapo-pcache.5
doc/man/man5/slapo-ppolicy.5
doc/man/man5/slapo-refint.5
doc/man/man5/slapo-rwm.5
doc/man/man5/slapo-syncprov.5
doc/man/man5/slapo-unique.5
doc/man/man8/Makefile.in
doc/man/man8/slapacl.8
doc/man/man8/slapadd.8
doc/man/man8/slapauth.8
doc/man/man8/slapcat.8
doc/man/man8/slapd.8
doc/man/man8/slapdn.8
doc/man/man8/slapindex.8
doc/man/man8/slappasswd.8
doc/man/man8/slaptest.8
doc/man/man8/slurpd.8
include/Makefile.in
include/ac/alloca.h
include/ac/assert.h
include/ac/bytes.h
include/ac/crypt.h
include/ac/ctype.h
include/ac/dirent.h
include/ac/errno.h
include/ac/fdset.h
include/ac/krb.h
include/ac/krb5.h
include/ac/localize.h
include/ac/param.h
include/ac/regex.h
include/ac/setproctitle.h
include/ac/signal.h
include/ac/socket.h
include/ac/stdarg.h
include/ac/stdlib.h
include/ac/string.h
include/ac/sysexits.h
include/ac/syslog.h
include/ac/termios.h
include/ac/time.h
include/ac/unistd.h
include/ac/wait.h
include/avl.h
include/getopt-compat.h
include/lber.h
include/lber_pvt.h
include/lber_types.h.in
include/ldap.h
include/ldap_cdefs.h
include/ldap_config.h.in
include/ldap_defaults.h
include/ldap_features.h.in
include/ldap_int_thread.h
include/ldap_log.h
include/ldap_pvt.h
include/ldap_pvt_thread.h
include/ldap_pvt_uc.h
include/ldap_queue.h
include/ldap_rq.h
include/ldap_schema.h
include/ldap_utf8.h
include/ldif.h
include/lutil.h
include/lutil_hash.h
include/lutil_ldap.h
include/lutil_lockf.h
include/lutil_md5.h
include/lutil_sha1.h
include/portable.h.in
include/rewrite.h
include/slapi-plugin.h
include/sysexits-compat.h
libraries/Makefile.in
libraries/liblber/Makefile.in
libraries/liblber/assert.c
libraries/liblber/bprint.c
libraries/liblber/debug.c
libraries/liblber/decode.c
libraries/liblber/dtest.c
libraries/liblber/encode.c
libraries/liblber/etest.c
libraries/liblber/idtest.c
libraries/liblber/io.c
libraries/liblber/lber-int.h
libraries/liblber/memory.c
libraries/liblber/nt_err.c
libraries/liblber/options.c
libraries/liblber/sockbuf.c
libraries/liblber/stdio.c
libraries/libldap/Makefile.in
libraries/libldap/abandon.c
libraries/libldap/add.c
libraries/libldap/addentry.c
libraries/libldap/apitest.c
libraries/libldap/bind.c
libraries/libldap/cancel.c
libraries/libldap/charray.c
libraries/libldap/compare.c
libraries/libldap/controls.c
libraries/libldap/cyrus.c
libraries/libldap/delete.c
libraries/libldap/dnssrv.c
libraries/libldap/dntest.c
libraries/libldap/error.c
libraries/libldap/extended.c
libraries/libldap/filter.c
libraries/libldap/free.c
libraries/libldap/ftest.c
libraries/libldap/getattr.c
libraries/libldap/getdn.c
libraries/libldap/getentry.c
libraries/libldap/getvalues.c
libraries/libldap/groupings.c
libraries/libldap/init.c
libraries/libldap/kbind.c
libraries/libldap/ldap-int.h
libraries/libldap/messages.c
libraries/libldap/modify.c
libraries/libldap/modrdn.c
libraries/libldap/open.c
libraries/libldap/options.c
libraries/libldap/os-ip.c
libraries/libldap/os-local.c
libraries/libldap/passwd.c
libraries/libldap/ppolicy.c
libraries/libldap/print.c
libraries/libldap/references.c
libraries/libldap/request.c
libraries/libldap/result.c
libraries/libldap/sasl.c
libraries/libldap/sbind.c
libraries/libldap/schema.c
libraries/libldap/search.c
libraries/libldap/sort.c
libraries/libldap/sortctrl.c
libraries/libldap/string.c
libraries/libldap/t61.c
libraries/libldap/test.c
libraries/libldap/tls.c
libraries/libldap/txn.c
libraries/libldap/unbind.c
libraries/libldap/url.c
libraries/libldap/utf-8-conv.c
libraries/libldap/utf-8.c
libraries/libldap/util-int.c
libraries/libldap/vlvctrl.c
libraries/libldap/whoami.c
libraries/libldap_r/Makefile.in
libraries/libldap_r/rdwr.c
libraries/libldap_r/rq.c
libraries/libldap_r/thr_cthreads.c
libraries/libldap_r/thr_lwp.c
libraries/libldap_r/thr_nt.c
libraries/libldap_r/thr_posix.c
libraries/libldap_r/thr_pth.c
libraries/libldap_r/thr_stub.c
libraries/libldap_r/thr_thr.c
libraries/libldap_r/threads.c
libraries/libldap_r/tpool.c
libraries/liblunicode/Makefile.in
libraries/liblunicode/ucdata/ucdata.c
libraries/liblunicode/ucdata/ucdata.h
libraries/liblunicode/ucdata/ucgendat.c
libraries/liblunicode/ucdata/ucpgba.c
libraries/liblunicode/ucdata/ucpgba.h
libraries/liblunicode/ucstr.c
libraries/liblunicode/ure/ure.c
libraries/liblunicode/ure/ure.h
libraries/liblunicode/ure/urestubs.c
libraries/liblunicode/utbm/utbm.c
libraries/liblunicode/utbm/utbm.h
libraries/liblunicode/utbm/utbmstub.c
libraries/liblutil/Makefile.in
libraries/liblutil/avl.c
libraries/liblutil/base64.c
libraries/liblutil/csn.c
libraries/liblutil/detach.c
libraries/liblutil/entropy.c
libraries/liblutil/fetch.c
libraries/liblutil/getopt.c
libraries/liblutil/getpass.c
libraries/liblutil/getpeereid.c
libraries/liblutil/hash.c
libraries/liblutil/ldif.c
libraries/liblutil/lockf.c
libraries/liblutil/md5.c
libraries/liblutil/memcmp.c
libraries/liblutil/ntservice.c
libraries/liblutil/passfile.c
libraries/liblutil/passwd.c
libraries/liblutil/ptest.c
libraries/liblutil/sasl.c
libraries/liblutil/setproctitle.c
libraries/liblutil/sha1.c
libraries/liblutil/signal.c
libraries/liblutil/sockpair.c
libraries/liblutil/testavl.c
libraries/liblutil/utils.c
libraries/liblutil/uuid.c
libraries/librewrite/Makefile.in
libraries/librewrite/config.c
libraries/librewrite/context.c
libraries/librewrite/info.c
libraries/librewrite/ldapmap.c
libraries/librewrite/map.c
libraries/librewrite/params.c
libraries/librewrite/parse.c
libraries/librewrite/rewrite-int.h
libraries/librewrite/rewrite-map.h
libraries/librewrite/rewrite.c
libraries/librewrite/rule.c
libraries/librewrite/session.c
libraries/librewrite/subst.c
libraries/librewrite/var.c
libraries/librewrite/xmap.c
servers/Makefile.in
servers/slapd/Makefile.in
servers/slapd/abandon.c
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/ad.c
servers/slapd/add.c
servers/slapd/at.c
servers/slapd/attr.c
servers/slapd/ava.c
servers/slapd/back-bdb/Makefile.in
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/bind.c
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/compare.c
servers/slapd/back-bdb/config.c
servers/slapd/back-bdb/ctxcsn.c [deleted file]
servers/slapd/back-bdb/dbcache.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/dn2entry.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/error.c
servers/slapd/back-bdb/extended.c
servers/slapd/back-bdb/filterindex.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/idl.c
servers/slapd/back-bdb/idl.h
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/key.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/nextid.c
servers/slapd/back-bdb/operational.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/referral.c
servers/slapd/back-bdb/search.c
servers/slapd/back-bdb/tools.c
servers/slapd/back-bdb/trans.c
servers/slapd/back-dnssrv/Makefile.in
servers/slapd/back-dnssrv/bind.c
servers/slapd/back-dnssrv/compare.c
servers/slapd/back-dnssrv/config.c
servers/slapd/back-dnssrv/init.c
servers/slapd/back-dnssrv/proto-dnssrv.h
servers/slapd/back-dnssrv/referral.c
servers/slapd/back-dnssrv/search.c
servers/slapd/back-hdb/Makefile.in
servers/slapd/back-hdb/back-bdb.h
servers/slapd/back-ldap/Makefile.in
servers/slapd/back-ldap/add.c
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/bind.c
servers/slapd/back-ldap/chain.c [new file with mode: 0644]
servers/slapd/back-ldap/compare.c
servers/slapd/back-ldap/config.c
servers/slapd/back-ldap/delete.c
servers/slapd/back-ldap/extended.c
servers/slapd/back-ldap/init.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/modrdn.c
servers/slapd/back-ldap/proto-ldap.h
servers/slapd/back-ldap/search.c
servers/slapd/back-ldap/unbind.c
servers/slapd/back-ldbm/Makefile.in
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/alias.c
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/bind.c
servers/slapd/back-ldbm/cache.c
servers/slapd/back-ldbm/close.c
servers/slapd/back-ldbm/compare.c
servers/slapd/back-ldbm/config.c
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/entry.c
servers/slapd/back-ldbm/extended.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/id2children.c
servers/slapd/back-ldbm/id2entry.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/key.c
servers/slapd/back-ldbm/ldbm.c
servers/slapd/back-ldbm/ldbm.h
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/nextid.c
servers/slapd/back-ldbm/operational.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/referral.c
servers/slapd/back-ldbm/search.c
servers/slapd/back-ldbm/tools.c
servers/slapd/back-meta/Makefile.in
servers/slapd/back-meta/add.c
servers/slapd/back-meta/attribute.c
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/candidates.c
servers/slapd/back-meta/compare.c
servers/slapd/back-meta/config.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/delete.c
servers/slapd/back-meta/dncache.c
servers/slapd/back-meta/group.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/map.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/modrdn.c
servers/slapd/back-meta/proto-meta.h
servers/slapd/back-meta/search.c
servers/slapd/back-meta/suffixmassage.c
servers/slapd/back-meta/unbind.c
servers/slapd/back-monitor/Makefile.in
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/backend.c
servers/slapd/back-monitor/bind.c
servers/slapd/back-monitor/cache.c
servers/slapd/back-monitor/compare.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/entry.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/listener.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/modify.c
servers/slapd/back-monitor/operation.c
servers/slapd/back-monitor/operational.c
servers/slapd/back-monitor/overlay.c
servers/slapd/back-monitor/proto-back-monitor.h
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/search.c
servers/slapd/back-monitor/sent.c
servers/slapd/back-monitor/thread.c
servers/slapd/back-monitor/time.c
servers/slapd/back-null/Makefile.in
servers/slapd/back-null/null.c
servers/slapd/back-passwd/Makefile.in
servers/slapd/back-passwd/back-passwd.h
servers/slapd/back-passwd/config.c
servers/slapd/back-passwd/init.c
servers/slapd/back-passwd/proto-passwd.h
servers/slapd/back-passwd/search.c
servers/slapd/back-perl/Makefile.in
servers/slapd/back-perl/SampleLDAP.pm
servers/slapd/back-perl/add.c
servers/slapd/back-perl/asperl_undefs.h
servers/slapd/back-perl/bind.c
servers/slapd/back-perl/close.c
servers/slapd/back-perl/compare.c
servers/slapd/back-perl/config.c
servers/slapd/back-perl/delete.c
servers/slapd/back-perl/init.c
servers/slapd/back-perl/modify.c
servers/slapd/back-perl/modrdn.c
servers/slapd/back-perl/perl_back.h
servers/slapd/back-perl/proto-perl.h
servers/slapd/back-perl/search.c
servers/slapd/back-relay/Makefile.in
servers/slapd/back-relay/back-relay.h
servers/slapd/back-relay/config.c
servers/slapd/back-relay/init.c
servers/slapd/back-relay/op.c
servers/slapd/back-relay/proto-back-relay.h
servers/slapd/back-shell/Makefile.in
servers/slapd/back-shell/add.c
servers/slapd/back-shell/bind.c
servers/slapd/back-shell/compare.c
servers/slapd/back-shell/config.c
servers/slapd/back-shell/delete.c
servers/slapd/back-shell/fork.c
servers/slapd/back-shell/init.c
servers/slapd/back-shell/modify.c
servers/slapd/back-shell/modrdn.c
servers/slapd/back-shell/proto-shell.h
servers/slapd/back-shell/result.c
servers/slapd/back-shell/search.c
servers/slapd/back-shell/searchexample.conf
servers/slapd/back-shell/searchexample.sh
servers/slapd/back-shell/shell.h
servers/slapd/back-shell/unbind.c
servers/slapd/back-sql/Makefile.in
servers/slapd/back-sql/add.c
servers/slapd/back-sql/api.c
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/bind.c
servers/slapd/back-sql/compare.c
servers/slapd/back-sql/config.c
servers/slapd/back-sql/delete.c
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/init.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/modrdn.c
servers/slapd/back-sql/operational.c
servers/slapd/back-sql/proto-sql.h
servers/slapd/back-sql/rdbms_depend/ibmdb2/backsql_create.sql
servers/slapd/back-sql/rdbms_depend/ibmdb2/slapd.conf
servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_create.sql
servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_data.sql
servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/mysql/backsql_create.sql
servers/slapd/back-sql/rdbms_depend/mysql/slapd.conf
servers/slapd/back-sql/rdbms_depend/mysql/testdb_create.sql
servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql
servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/oracle/slapd.conf
servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/pgsql/backsql_create.sql
servers/slapd/back-sql/rdbms_depend/pgsql/slapd.conf
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/timesten/dnreverse/Makefile
servers/slapd/back-sql/rdbms_depend/timesten/dnreverse/dnreverse.cpp
servers/slapd/back-sql/rdbms_depend/timesten/slapd.conf
servers/slapd/back-sql/rdbms_depend/timesten/testdb_metadata.sql
servers/slapd/back-sql/schema-map.c
servers/slapd/back-sql/schema-map.h [deleted file]
servers/slapd/back-sql/search.c
servers/slapd/back-sql/sql-types.h [deleted file]
servers/slapd/back-sql/sql-wrap.c
servers/slapd/back-sql/util.c
servers/slapd/backend.c
servers/slapd/backover.c
servers/slapd/bind.c
servers/slapd/cancel.c
servers/slapd/ch_malloc.c
servers/slapd/compare.c
servers/slapd/component.c
servers/slapd/component.h
servers/slapd/config.c
servers/slapd/config.h
servers/slapd/connection.c
servers/slapd/controls.c
servers/slapd/cr.c
servers/slapd/ctxcsn.c
servers/slapd/daemon.c
servers/slapd/delete.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/extended.c
servers/slapd/filter.c
servers/slapd/filterentry.c
servers/slapd/frontend.c
servers/slapd/globals.c
servers/slapd/index.c
servers/slapd/init.c
servers/slapd/kerberos.c
servers/slapd/ldapsync.c
servers/slapd/limits.c
servers/slapd/lock.c
servers/slapd/main.c
servers/slapd/matchedValues.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/mods.c
servers/slapd/module.c
servers/slapd/mr.c
servers/slapd/mra.c
servers/slapd/nt_svc.c
servers/slapd/oc.c
servers/slapd/oidm.c
servers/slapd/operation.c
servers/slapd/operational.c
servers/slapd/overlays/Makefile.in
servers/slapd/overlays/chain.c [deleted file]
servers/slapd/overlays/collect.c
servers/slapd/overlays/denyop.c
servers/slapd/overlays/dyngroup.c
servers/slapd/overlays/glue.c
servers/slapd/overlays/lastmod.c
servers/slapd/overlays/overlays.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/ppolicy.c
servers/slapd/overlays/refint.c
servers/slapd/overlays/rwm.c
servers/slapd/overlays/rwm.h
servers/slapd/overlays/rwmconf.c
servers/slapd/overlays/rwmdn.c
servers/slapd/overlays/rwmmap.c
servers/slapd/overlays/seqmod.c
servers/slapd/overlays/syncprov.c
servers/slapd/overlays/unique.c
servers/slapd/passwd.c
servers/slapd/phonetic.c
servers/slapd/proto-slap.h
servers/slapd/referral.c
servers/slapd/repl.c
servers/slapd/result.c
servers/slapd/root_dse.c
servers/slapd/sasl.c
servers/slapd/saslauthz.c
servers/slapd/schema.c
servers/slapd/schema/README
servers/slapd/schema/collective.schema [deleted file]
servers/slapd/schema/corba.schema
servers/slapd/schema/core.schema
servers/slapd/schema/cosine.schema
servers/slapd/schema/duaconf.schema [deleted file]
servers/slapd/schema/dyngroup.schema
servers/slapd/schema/inetorgperson.schema
servers/slapd/schema/java.schema
servers/slapd/schema/misc.schema
servers/slapd/schema/nis.schema
servers/slapd/schema/openldap.schema
servers/slapd/schema/ppolicy.schema
servers/slapd/schema_check.c
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/schemaparse.c
servers/slapd/search.c
servers/slapd/sessionlog.c [deleted file]
servers/slapd/sets.c
servers/slapd/sets.h
servers/slapd/shell-backends/Makefile.in
servers/slapd/shell-backends/passwd-shell.c
servers/slapd/shell-backends/shellutil.c
servers/slapd/shell-backends/shellutil.h
servers/slapd/sl_malloc.c
servers/slapd/slap.h
servers/slapd/slapacl.c
servers/slapd/slapadd.c
servers/slapd/slapauth.c
servers/slapd/slapcat.c
servers/slapd/slapcommon.c
servers/slapd/slapcommon.h
servers/slapd/slapdn.c
servers/slapd/slapi/Makefile.in
servers/slapd/slapi/ibm_pblock_params.h
servers/slapd/slapi/plugin.c
servers/slapd/slapi/printmsg.c
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi.h
servers/slapd/slapi/slapi_ext.c
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_pblock.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/slapindex.c
servers/slapd/slappasswd.c
servers/slapd/slaptest.c
servers/slapd/starttls.c
servers/slapd/str2filter.c
servers/slapd/syncrepl.c
servers/slapd/syntax.c
servers/slapd/unbind.c
servers/slapd/user.c
servers/slapd/value.c
servers/slapd/zn_malloc.c
servers/slurpd/Makefile.in
servers/slurpd/admin.c
servers/slurpd/args.c
servers/slurpd/ch_malloc.c
servers/slurpd/config.c
servers/slurpd/fm.c
servers/slurpd/globals.c
servers/slurpd/globals.h
servers/slurpd/ldap_op.c
servers/slurpd/lock.c
servers/slurpd/main.c
servers/slurpd/nt_svc.c
servers/slurpd/proto-slurp.h
servers/slurpd/re.c
servers/slurpd/reject.c
servers/slurpd/replica.c
servers/slurpd/replog.c
servers/slurpd/ri.c
servers/slurpd/rq.c
servers/slurpd/sanity.c
servers/slurpd/slurp.h
servers/slurpd/st.c
tests/Makefile.in
tests/data/acl.out.master
tests/data/chain.out [new file with mode: 0644]
tests/data/chainmod.out [new file with mode: 0644]
tests/data/ditcontentrules.conf
tests/data/relay.out
tests/data/slapd-acl.conf
tests/data/slapd-cache-master.conf
tests/data/slapd-chain1.conf [new file with mode: 0644]
tests/data/slapd-chain2.conf [new file with mode: 0644]
tests/data/slapd-component.conf
tests/data/slapd-dn.conf
tests/data/slapd-dnssrv.conf
tests/data/slapd-emptydn.conf
tests/data/slapd-glue.conf
tests/data/slapd-idassert.conf
tests/data/slapd-ldapglue.conf
tests/data/slapd-ldapgluegroups.conf
tests/data/slapd-ldapgluepeople.conf
tests/data/slapd-limits.conf
tests/data/slapd-master.conf
tests/data/slapd-nis-master.conf
tests/data/slapd-passwd.conf
tests/data/slapd-ppolicy.conf
tests/data/slapd-proxycache.conf
tests/data/slapd-pw.conf
tests/data/slapd-ref-slave.conf
tests/data/slapd-referrals.conf
tests/data/slapd-refint.conf
tests/data/slapd-relay.conf
tests/data/slapd-repl-master.conf
tests/data/slapd-repl-slave.conf
tests/data/slapd-schema.conf
tests/data/slapd-sql.conf
tests/data/slapd-syncrepl-master.conf
tests/data/slapd-syncrepl-slave-persist1.conf
tests/data/slapd-syncrepl-slave-persist2.conf
tests/data/slapd-syncrepl-slave-persist3.conf
tests/data/slapd-syncrepl-slave-refresh1.conf
tests/data/slapd-syncrepl-slave-refresh2.conf
tests/data/slapd-unique.conf
tests/data/slapd-whoami.conf
tests/data/slapd.conf
tests/data/slapd2.conf
tests/data/sql-read.out
tests/data/sql-write.out
tests/data/test-chain1.ldif [new file with mode: 0644]
tests/data/test-chain2.ldif [new file with mode: 0644]
tests/data/test.schema
tests/progs/Makefile.in
tests/progs/slapd-addel.c
tests/progs/slapd-modify.c
tests/progs/slapd-modrdn.c
tests/progs/slapd-read.c
tests/progs/slapd-search.c
tests/progs/slapd-tester.c
tests/run.in
tests/scripts/acfilter.sh
tests/scripts/all
tests/scripts/conf.sh
tests/scripts/defines.sh
tests/scripts/passwd-search
tests/scripts/relay
tests/scripts/sql-all
tests/scripts/sql-test000-read
tests/scripts/sql-test900-write
tests/scripts/start-server
tests/scripts/start-server-nolog
tests/scripts/start-server2
tests/scripts/start-server2-nolog
tests/scripts/startup_nis_ldap_server.sh
tests/scripts/test000-rootdse
tests/scripts/test001-slapadd
tests/scripts/test002-populate
tests/scripts/test003-search
tests/scripts/test004-modify
tests/scripts/test005-modrdn
tests/scripts/test006-acls
tests/scripts/test007-replication
tests/scripts/test008-concurrency
tests/scripts/test009-referral
tests/scripts/test010-passwd
tests/scripts/test011-glue-slapadd
tests/scripts/test012-glue-populate
tests/scripts/test013-language
tests/scripts/test014-whoami
tests/scripts/test015-xsearch
tests/scripts/test016-subref
tests/scripts/test017-syncreplication-refresh
tests/scripts/test018-syncreplication-persist
tests/scripts/test019-syncreplication-cascade
tests/scripts/test020-proxycache
tests/scripts/test021-certificate
tests/scripts/test022-ppolicy
tests/scripts/test023-refint
tests/scripts/test024-unique
tests/scripts/test025-limits
tests/scripts/test026-dn
tests/scripts/test027-emptydn
tests/scripts/test028-idassert
tests/scripts/test029-ldapglue
tests/scripts/test030-relay
tests/scripts/test031-component-filter
tests/scripts/test032-chain [new file with mode: 0755]

diff --git a/CHANGES b/CHANGES
index cafb2dd8246cdc06022b20d964b1c337ec1f13cd..94d9d133ba74759d7d9dc4931be07e8d6c0ecd4a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,5 @@
 OpenLDAP 2.3 Change Log
 
-OpenLDAP 2.3.0alpha Release
-       Alpha release
+OpenLDAP 2.3.1alpha Release
+       Changes not tracked
 
index 62b39c310c70b2c0ccc01c9be93d9cb0c4408950..5550e3abe11f6d76e401ff57942166f1d1dca005 100644 (file)
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,4 +1,4 @@
-Copyright 1998-2004 The OpenLDAP Foundation
+Copyright 1998-2005 The OpenLDAP Foundation
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/INSTALL b/INSTALL
index a6cbf4288625e0017a8a880ac4ee0dffc6068890..042bc9ac5b72345bdb851e8b306309851182fce3 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -107,7 +107,7 @@ $OpenLDAP: pkg/openldap-guide/release/install.sdf,v 1.16 2002/02/18
 
 This work is part of OpenLDAP Software <http://www.openldap.org/>.
 
-Copyright 1998-2004 The OpenLDAP Foundation.
+Copyright 1998-2005 The OpenLDAP Foundation.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
index de7956753eeaf3ec2ee8179a487b1243fb701b2c..4255ebb46e59a3111345a2304c65661729259276 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
diff --git a/README b/README
index ea464e1f867849f14320929a840e03b75e0a0b96..13ccd465e38517614054273eeac2be4d1bdbdf63 100644 (file)
--- a/README
+++ b/README
@@ -80,7 +80,8 @@ $OpenLDAP$
 
 This work is part of OpenLDAP Software <http://www.openldap.org/>.
 
-Copyright 1998-2004 The OpenLDAP Foundation.  All rights reserved.
+Copyright 1998-2005 The OpenLDAP Foundation.
+All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
index f6f86c05c9c1d3d2449c33d5dbb28a3d9f418275..865c099294891c7694a0adfb8f6c2b322e834ae5 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation
+ * Copyright 1998-2005 The OpenLDAP Foundation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index eab0d993a396910b02a39ee8bb2df8800fe83b79..0fa0825cca794742e6cee5d752435eb26a51ed31 100644 (file)
@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros
 dnl $OpenLDAP$
 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
 dnl
-dnl Copyright 1998-2004 The OpenLDAP Foundation.
+dnl Copyright 1998-2005 The OpenLDAP Foundation.
 dnl All rights reserved.
 dnl
 dnl Redistribution and use in source and binary forms, with or without
index 6127720d026009a9d7c11c2c57dca925c8790155..72c05bfe23843e7f930c049b926b799e16ee8103 100644 (file)
@@ -10,7 +10,7 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 dnl PARTICULAR PURPOSE.
 
-dnl Copyright 1998-2004 The OpenLDAP Foundation.
+dnl Copyright 1998-2005 The OpenLDAP Foundation.
 dnl All rights reserved.
 dnl
 dnl Redistribution and use in source and binary forms, with or without
index b9228c00ed248b89baba50ac0b2d5b5730e24a4f..92dfff05c85645b5232a51b960dd115619d938da 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1998-2004 The OpenLDAP Foundation.
+#   Copyright 1998-2005 The OpenLDAP Foundation.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002 Free Software Foundation, Inc.
 
@@ -30,7 +30,7 @@ timestamp='2002-10-21-OpenLDAP'
 # configuration script generated by Autoconf, and is distributable
 # under the same distributions terms as OpenLDAP inself.
 
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 8178cd540f7f51392299e8d2187072de4e7d2197..90348ce971e1fe965471730f5e14aca8a3dc39aa 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1998-2004 The OpenLDAP Foundation.
+#   Copyright 1998-2005 The OpenLDAP Foundation.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002 Free Software Foundation, Inc.
 
@@ -35,7 +35,7 @@ timestamp='2002-09-05 (OpenLDAP)'
 # configuration script generated by Autoconf, and is distributable
 # under the same distributions terms as OpenLDAP inself.
 
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index a4725f3ab3619bdbb46b47c51b56e1692ac0f78d..d70ca114d2e9399ca1eeec1641d1513a80269a00 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -18,5 +18,5 @@
 
 set -e                 # exit immediately if any errors occur
 
-find . -type f -not -name 'LICENSE*' -print -exec perl -pi -e 's/Copyright ([0-9]{4})([,\-][0-9]{2,4})*,? The OpenLDAP Foundation/Copyright $1-2004 The OpenLDAP Foundation/g;' {} \;
+find . -type f -not -name 'LICENSE*' -print -exec perl -pi -e 's/Copyright ([0-9]{4})([,\-][0-9]{2,4})*,? The OpenLDAP Foundation/Copyright $1-2005 The OpenLDAP Foundation/g;' {} \;
 
index d05989335b3b9e085d4df7587e817b465a399317..8f7b434a5d9397ac97e7145c8e895021759b6b95 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f6ab841626a4bcbae583edb08e29deb749954437..2857d4431addf3deb15e02af4442c4016daa4c56 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 9e8d23bafa02ed1c3785d1f03515933ed07242b0..a77a64ab0742adba5a97bce29ee660005a64a157 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 0698732b8f156ba105d556e117b5006ee9d74a54..3111f75d25b6cadc143db5099dee57fc179b5f85 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 787891df9ae76ce3c2a543193a551ab69025ecb8..f467ae3f3762bd28644cb85b764e2987508ad4d3 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index c654e165a5aecbc4adc6e994887ef5ec33e7982a..cc95125f0275f3dfefd6f267110cb8f5174ed3e7 100755 (executable)
@@ -28,7 +28,7 @@
 # configuration script generated by Autoconf, and is distributable
 # under the same distributions terms as OpenLDAP inself.
 
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 1ed076db806338dda6bf145974493c10a72e8a3b..0e113f634a5555f337a3e9780758787222adea8e 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 20b4079680256a243c814454b26f3381a2fc36c4..0e8ce3d8574e05f4164140c842f672dfd7794ae8 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index c06c21a3beb68b80c8c661cdd3fb4f42f3050144..2e68dec52c590079722dabfd3503f1e2c6d7aaf3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index ee866c850d39d242debd28101466afc38a74ce56..dcd32b2105816a51410da6327a5a0968fa5a639d 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,7 @@ echo Release: $RELNAME
 echo CVS Tag: $CVSTAG
 echo Modules: $*
 
-cvs -q export -r $CVSTAG -d $RELNAME $*
+cvs -q export -kkv -r $CVSTAG -d $RELNAME $*
 
 if test ! -d $RELNAME ; then
        echo "error: $RELNAME doesn't exists"
@@ -53,10 +53,13 @@ fi
 
 if test ! -e $RELNAME/build/version.sh ; then
        echo "No build version"
-       exit 1
+       OL_STRING="something"
+else
+       eval `$RELNAME/build/version.sh`
 fi
 
-eval `$RELNAME/build/version.sh`
+echo "Rolling up $OL_STRING ..."
+
 
 tar cf $RELNAME.tar $RELNAME
 gzip -9 -c $RELNAME.tar > $RELNAME.tgz
index fb7df6c7ac98909a870756ef57f6354ca8506b4a..6dbf2d241e23f546ec1f016d48ff03dd9fb21a09 100755 (executable)
@@ -1,7 +1,7 @@
 :: $OpenLDAP$
 :: This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ::
-:: Copyright 1998-2004 The OpenLDAP Foundation.
+:: Copyright 1998-2005 The OpenLDAP Foundation.
 :: All rights reserved.
 ::
 :: Redistribution and use in source and binary forms, with or without
index af6022238d7f742cfef1a3850a2f706413fb017c..41dd81e17559b71d7ee4652746c81938b15610ca 100755 (executable)
@@ -3,7 +3,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,7 @@ WHOWHERE="$USER@`uname -n`:`pwd`"
 cat << __EOF__
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ cat << __EOF__
  */
 
 static const char copyright[] =
-"Copyright 1998-2004 The OpenLDAP Foundation.  All rights reserved.\n"
+"Copyright 1998-2005 The OpenLDAP Foundation.  All rights reserved.\n"
 "COPYING RESTRICTIONS APPLY\n";
 
 $static $const char $SYMBOL[] =
index c5bc3fb69fddb52f91c578952ea5c30f85859129..9ee55b3c010c51626367a69f8971f551641ae23e 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e22dd29d62195d70ad8b4c96fdc6d581a7666942..1cf676e44214131fa40205ea96b8a31ab45dac1e 100644 (file)
@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros
 dnl $OpenLDAP$
 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
 dnl
-dnl Copyright 1998-2004 The OpenLDAP Foundation.
+dnl Copyright 1998-2005 The OpenLDAP Foundation.
 dnl All rights reserved.
 dnl
 dnl Redistribution and use in source and binary forms, with or without
index b8bc8d85e85ab5b97cd55bbd837099d1dc6ba214..3e411c5bc064e1eb96c3f5c80180f1b3b7215c36 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 7337172c06e20bae0be7c3fd4eb673188ee21f6e..b735c374fc72adf75fd3a31da143b54347c11fe5 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 3806dcf42d511d02e0254f8fa49471458b7135dc..58b250d924133e86250a21cb5f4e00185e93059d 100644 (file)
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 836f74e91459ae1233f0e111751d6e9b3614e532..79b2ea90a40a04e90d32f4a1291a1d30dc470b96 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  */
 
 static const char copyright[] =
-"Copyright 1998-2004 The OpenLDAP Foundation.  All rights reserved.\n"
+"Copyright 1998-2005 The OpenLDAP Foundation.  All rights reserved.\n"
 "COPYING RESTRICTIONS APPLY.\n";
 
index b6d003ce18782c38f48c4fd5302df9af41b3f7b6..f409278951a7f2d078c3aa2c70f7a08922db073f 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index ade064c3d4aaa1feee514a58db5f0dd60517fead..bdd1988ae9b63d67ef856ac6be3cfd268dfd8bae 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 453e8107fb56d27a5d1e685b0332765d6cd1a2e1..87df1e4553b47e979e9e0898fbd817dffbdf01f1 100644 (file)
@@ -1,6 +1,6 @@
 # Clients Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 84cb82a40bd3f53295a19e2eb7bd15dce7d5bbc3..2776e673f1b57f6a693c8c9cd43b6028a0bf625c 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for LDAP tools
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -103,5 +103,5 @@ install-local:      FORCE
            done                                                        \
        )
        $(RM) $(DESTDIR)$(bindir)/ldapadd$(EXEEXT)
-       $(LN) $(DESTDIR)$(bindir)/ldapmodify$(EXEEXT) $(DESTDIR)$(bindir)/ldapadd$(EXEEXT)
+       $(LN_S) $(DESTDIR)$(bindir)/ldapmodify$(EXEEXT) $(DESTDIR)$(bindir)/ldapadd$(EXEEXT)
 
index 21a818106107f17705d236ec1007764f2d2bd68c..415be46b9dc7bcfd6b1180a90a5d8e1d9cf6445c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
index 2675a8751cff925a603046a5796f551e7bef189a..3022721d5bc99518b54ebc76ab2f7e0935324d07 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 056b47ac777db2eef31869dd44f8417998daf0d0..7023e9b63d1d6f9eefca3c16896dc34a1efcb6b4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * All rights reserved.
index 74402e999078137386562b36fc2952fe9a42ad21..4617aa502525876b7cf3319b4f29fd4696a2f332 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index e0c230edbbb96a9cfab700bea3e06a58f68c97fb..646f50d778a05a4ab853fd7e63014b0ce69e102e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * Portions Copyright 2001-2003 IBM Corporation.
index 75dc7a00195e3b378ac29486c65c078dbd5e5859..827a372d251377e78bdd1420c66d64a3c99fcd00 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * Portions Copyright 2001-2003 IBM Corporation.
index e09d022fd3dfb87ab4af519ff5ae8bf35fe74184..145b87fde35c1c28266412dca0275b9e68a68dfb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * Portions Copyright 2001-2003 IBM Corporation.
index a7df2dbd90940865186402b74613f5fbebedaee0..e2f99449591a1261bba2f79a951a703758e750cc 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * Portions Copyright 2001-2003 IBM Corporation.
index 1eba2b60a6795d4e23a9b1f09b206d74d66f5dae..1aca0400964ef2745d9ddff864372fc2dd61e948 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * Portions Copyright 2001-2003 IBM Corporation.
index 026811eda88bf723a2a49312ff90774990ffd7a7..78fcb210e8fcc6f82716b6cf9efa857236a5725c 100755 (executable)
--- a/configure
+++ b/configure
@@ -4,7 +4,7 @@
 
 # This work is part of OpenLDAP Software <http://www.openldap.org/>.
 #
-# Copyright 1998-2004 The OpenLDAP Foundation.
+# Copyright 1998-2005 The OpenLDAP Foundation.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
 # top-level directory of the distribution or, alternatively, at
 # <http://www.OpenLDAP.org/license.html>.
 
-echo "Copyright 1998-2004 The OpenLDAP Foundation. All rights reserved."
+echo "Copyright 1998-2005 The OpenLDAP Foundation. All rights reserved."
 echo " Restrictions apply, see COPYRIGHT and LICENSE files."
 
 # Guess values for system-dependent variables and create Makefiles.
@@ -25282,60 +25282,6 @@ else
        PLAT=UNIX
 fi
 
-if test -z "$SLAPD_STATIC_BACKENDS"; then
-       SLAPD_NO_STATIC='#'
-else
-       SLAPD_NO_STATIC=
-fi
-
-BACKEND_HEADER=servers/slapd/backend.h
-cat > $BACKEND_HEADER << EOF
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* This file is automatically generated by configure; please do not edit.
- */
-
-EOF
-
-for b in $SLAPD_STATIC_BACKENDS; do
-       bb=`echo "$b" | sed -e 's;back-;;'`
-       
-       cat >> $BACKEND_HEADER << EOF
-extern BI_init ${bb}_back_initialize;
-EOF
-done
-
-cat >> $BACKEND_HEADER << EOF
-
-static BackendInfo binfo[] = {
-EOF
-
-for b in $SLAPD_STATIC_BACKENDS; do
-       bb=`echo "$b" | sed -e 's;back-;;'`
-       
-       cat >> $BACKEND_HEADER << EOF
-       { "$bb", ${bb}_back_initialize },
-EOF
-done
-
-cat >> $BACKEND_HEADER << EOF
-       { NULL, NULL }
-};
-
-/* end of generated file */
-EOF
-
 
 
 
@@ -25910,12 +25856,64 @@ fi; done
 
 EOF
 cat >> $CONFIG_STATUS <<EOF
-
+STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 
 chmod +x tests/run
 date > stamp-h
+BACKENDSC="servers/slapd/backends.c"
+echo "Making $BACKENDSC"
+rm -f $BACKENDSC
+cat > $BACKENDSC << ENDX
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* This file is automatically generated by configure; please do not edit. */
+
+#include "portable.h"
+#include "slap.h"
+
+ENDX
+if test "${STATIC_BACKENDS}"; then
+       for b in ${STATIC_BACKENDS}; do
+               bb=`echo "${b}" | sed -e 's/back-//'`
+               cat >> $BACKENDSC << ENDX
+extern BI_init ${bb}_back_initialize;
+ENDX
+       done
+
+       cat >> $BACKENDSC << ENDX
+
+BackendInfo slap_binfo[] = {
+ENDX
+
+       for b in ${STATIC_BACKENDS}; do
+               bb=`echo "${b}" | sed -e 's/back-//'`
+               echo "    Add ${bb} ..."
+               cat >> $BACKENDSC << ENDX
+       { "${bb}", ${bb}_back_initialize },
+ENDX
+       done
+
+       cat >> $BACKENDSC << ENDX
+       { NULL, NULL },
+};
+
+/* end of generated file */
+ENDX
+fi
+
 echo Please run \"make depend\" to build dependencies
 
 exit 0
index 26e9108ef4dc62dc919fe3f29b751df721875469..6bf73baa507358262acf2311c1e7672740639a8c 100644 (file)
@@ -1,7 +1,7 @@
 dnl $OpenLDAP$
 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
 dnl
-dnl Copyright 1998-2004 The OpenLDAP Foundation.
+dnl Copyright 1998-2005 The OpenLDAP Foundation.
 dnl All rights reserved.
 dnl
 dnl Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@ define([AC_INIT_BINSH],
 
 # This work is part of OpenLDAP Software <http://www.openldap.org/>.
 #
-# Copyright 1998-2004 The OpenLDAP Foundation.
+# Copyright 1998-2005 The OpenLDAP Foundation.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -34,7 +34,7 @@ define([AC_INIT_BINSH],
 # top-level directory of the distribution or, alternatively, at
 # <http://www.OpenLDAP.org/license.html>.
 
-echo "Copyright 1998-2004 The OpenLDAP Foundation. All rights reserved."
+echo "Copyright 1998-2005 The OpenLDAP Foundation. All rights reserved."
 echo " Restrictions apply, see COPYRIGHT and LICENSE files."
 ])dnl
 dnl ----------------------------------------------------------------
@@ -2924,62 +2924,6 @@ else
        PLAT=UNIX
 fi
 
-if test -z "$SLAPD_STATIC_BACKENDS"; then
-       SLAPD_NO_STATIC='#'
-else
-       SLAPD_NO_STATIC=
-fi
-
-dnl Generate static backend header file
-BACKEND_HEADER=servers/slapd/backend.h
-cat > $BACKEND_HEADER << EOF
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* This file is automatically generated by configure; please do not edit.
- */
-
-EOF
-
-for b in $SLAPD_STATIC_BACKENDS; do
-       bb=`echo "$b" | sed -e 's;back-;;'`
-       
-       cat >> $BACKEND_HEADER << EOF
-extern BI_init ${bb}_back_initialize;
-EOF
-done
-
-cat >> $BACKEND_HEADER << EOF
-
-static BackendInfo binfo[[]] = {
-EOF
-
-for b in $SLAPD_STATIC_BACKENDS; do
-       bb=`echo "$b" | sed -e 's;back-;;'`
-       
-       cat >> $BACKEND_HEADER << EOF
-       { "$bb", ${bb}_back_initialize },
-EOF
-done
-
-cat >> $BACKEND_HEADER << EOF
-       { NULL, NULL }
-};
-
-/* end of generated file */
-EOF
-dnl done generating static backend header file
-
 AC_SUBST(LIBSRCS)
 AC_SUBST(PLAT)
 AC_SUBST(WITH_SASL)
@@ -3108,5 +3052,57 @@ tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
 ,[
 chmod +x tests/run
 date > stamp-h
+BACKENDSC="servers/slapd/backends.c"
+echo "Making $BACKENDSC"
+rm -f $BACKENDSC
+cat > $BACKENDSC << ENDX
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* This file is automatically generated by configure; please do not edit. */
+
+#include "portable.h"
+#include "slap.h"
+
+ENDX
+if test "${STATIC_BACKENDS}"; then
+       for b in ${STATIC_BACKENDS}; do
+               bb=`echo "${b}" | sed -e 's/back-//'`
+               cat >> $BACKENDSC << ENDX
+extern BI_init ${bb}_back_initialize;
+ENDX
+       done
+
+       cat >> $BACKENDSC << ENDX
+
+BackendInfo slap_binfo[[]] = {
+ENDX
+
+       for b in ${STATIC_BACKENDS}; do
+               bb=`echo "${b}" | sed -e 's/back-//'`
+               echo "    Add ${bb} ..."
+               cat >> $BACKENDSC << ENDX
+       { "${bb}", ${bb}_back_initialize },
+ENDX
+       done
+
+       cat >> $BACKENDSC << ENDX
+       { NULL, NULL },
+};
+
+/* end of generated file */
+ENDX
+fi
+
 echo Please run \"make depend\" to build dependencies
-])
+],[STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"])
index 63b3f1034da32c910b3879b7962a52b541eee3ef..9cbaaf46bda665f52cdb5be8583f6414dad75f53 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 1998-2004 The OpenLDAP Foundation
+Copyright 1998-2005 The OpenLDAP Foundation
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
index e8359633c5023d61299b9373f1bb9dc3ea50e7ca..6ad69e953955cd8c5fc85fa2a8c69ceb8b2759b6 100644 (file)
@@ -1,7 +1,7 @@
 /* Generic time.h */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2004 The OpenLDAP Foundation, Redwood City, California, USA
+ * Copyright 1998-2005 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted only
index 0302666ea34dbd01164dfcec3e939fa5680440c4..05801d815822efdf4145ac2a952369d5408984fe 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 # This work is part of OpenLDAP Software <http://www.openldap.org/>.
 #
-# Copyright 2003-2004 The OpenLDAP Foundation.
+# Copyright 2003-2005 The OpenLDAP Foundation.
 # Portions Copyright 2004 by IBM Corporation.
 # All rights reserved.
 
index 3db5f96d31336f1c6f5df9487c72fdfe9728ac85..0dc3f36aad583ccdf5d0b252d2ba301cc2832b22 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2004 The OpenLDAP Foundation. All rights reserved.
+Copyright 2004-2005 The OpenLDAP Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
index 906cbee34cc05441d5eb9b84ea87cac154645e12..50e1501ef9d549e924fa189046c66546aa3205bb 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 55198ff561c550eb58654297a2e57695aace2ace..9731223e275a18c4541db98afee53008dc6b5f71 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2004 The OpenLDAP Foundation. All rights reserved.
+Copyright 2004-2005 The OpenLDAP Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
index 0d0dbe16008fd2721c90886f75838c63bd6cf45a..fed0aa2fbdd5b94c16eccdc5d102e2bbe19be081 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9e309bab5053d839afcf843226970c5c1043a29d..b880d520c5c1bdf8c9004a82916ab74697926c5d 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1e134ef91b27281c37adaef1984164df1c007f89..ec599bedbf9a5377efef2614a8cebf1dbdd876b4 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2004 Howard Chu, Symas Corp. All rights reserved.
+Copyright 2004-2005 Howard Chu, Symas Corp. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
@@ -15,7 +15,12 @@ password hashes for an LDAP user.
 The Kerberos support is written for Heimdal using its hdb-ldap backend.
 If a PasswordModify is performed on an entry that has the krb5KDCEntry
 objectclass, then the krb5Key and krb5KeyVersionNumber will be updated
-using the new password in the PasswordModify request.
+using the new password in the PasswordModify request. Additionally, a
+new "{K5KEY}" password hash mechanism is provided. krb5KDCEntries that
+have this hash specifier in their userPassword attribute, Simple Binds
+will be checked against the Kerberos keys of the Entry. No data is
+needed after the "{K5KEY}" hash specifier in the userPassword, it is
+looked up from the Entry directly.
 
 The Samba support is written using the Samba 3.0 LDAP schema. If a
 PasswordModify is performed on an entry that has the sambaSamAccount
index 1a515980094d8b6565b426514af358e787b6f72e..e82a73e445a4fab9134c1d67469df29ed8f07c0a 100644 (file)
@@ -1,7 +1,7 @@
 /* smbk5pwd.c - Overlay for managing Samba and Heimdal passwords */
 /* $OpenLDAP$ */
 /*
- * Copyright 2004 by Howard Chu, Symas Corp.
+ * Copyright 2004-2005 by Howard Chu, Symas Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <ac/errno.h>
 
 #ifdef DO_KRB5
+#include <ac/string.h>
+#include <lber.h>
+#include <lber_pvt.h>
+#include <lutil.h>
+
 /* make ASN1_MALLOC_ENCODE use our allocator */
 #define malloc ch_malloc
 
@@ -155,7 +160,130 @@ static void nthash(
 }
 #endif /* DO_SAMBA */
 
-int smbk5pwd_exop_passwd(
+#ifdef DO_KRB5
+
+static int smbk5pwd_op_cleanup(
+       Operation *op,
+       SlapReply *rs )
+{
+       slap_callback *cb;
+
+       /* clear out the current key */
+       ldap_pvt_thread_pool_setkey( op->o_threadctx, smbk5pwd_op_cleanup,
+               NULL, NULL );
+
+       /* free the callback */
+       cb = op->o_callback;
+       op->o_callback = cb->sc_next;
+       op->o_tmpfree( cb, op->o_tmpmemctx );
+       return 0;
+}
+
+static int smbk5pwd_op_bind(
+       Operation *op,
+       SlapReply *rs )
+{
+       /* If this is a simple Bind, stash the Op pointer so our chk
+        * function can find it. Set a cleanup callback to clear it
+        * out when the Bind completes.
+        */
+       if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE ) {
+               slap_callback *cb;
+               ldap_pvt_thread_pool_setkey( op->o_threadctx, smbk5pwd_op_cleanup, op,
+                       NULL );
+               cb = op->o_tmpcalloc( 1, sizeof(slap_callback), op->o_tmpmemctx );
+               cb->sc_cleanup = smbk5pwd_op_cleanup;
+               cb->sc_next = op->o_callback;
+               op->o_callback = cb;
+       }
+       return SLAP_CB_CONTINUE;
+}
+
+static LUTIL_PASSWD_CHK_FUNC chk_k5key;
+static const struct berval scheme = BER_BVC("{K5KEY}");
+
+/* This password scheme stores no data in the userPassword attribute
+ * other than the scheme name. It assumes the invoking entry is a
+ * krb5KDCentry and compares the passed-in credentials against the
+ * krb5Key attribute. The krb5Key may be multi-valued, but they are
+ * simply multiple keytypes generated from the same input string, so
+ * only the first value needs to be compared here.
+ *
+ * Since the lutil_passwd API doesn't pass the Entry object in, we
+ * have to fetch it ourselves in order to get access to the other
+ * attributes. We accomplish this with the help of the overlay's Bind
+ * function, which stores the current Operation pointer in thread-specific
+ * storage so we can retrieve it here. The Operation provides all
+ * the necessary context for us to get Entry from the database.
+ */
+static int chk_k5key(
+       const struct berval *sc,
+       const struct berval *passwd,
+       const struct berval *cred,
+       const char **text )
+{
+       void *ctx;
+       Operation *op;
+       int rc;
+       Entry *e;
+       Attribute *a;
+    krb5_error_code ret;
+    krb5_keyblock key;
+    krb5_salt salt;
+       hdb_entry ent;
+
+       /* Find our thread context, find our Operation */
+       ctx = ldap_pvt_thread_pool_context();
+
+       if ( ldap_pvt_thread_pool_getkey( ctx, smbk5pwd_op_cleanup, (void **)&op, NULL ) ||
+               !op )
+               return LUTIL_PASSWD_ERR;
+
+       rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
+       if ( rc != LDAP_SUCCESS ) return LUTIL_PASSWD_ERR;
+
+       rc = LUTIL_PASSWD_ERR;
+       do {
+               size_t l;
+               Key ekey = {0};
+
+               a = attr_find( e->e_attrs, ad_krb5PrincipalName );
+               if (!a ) break;
+
+               memset( &ent, 0, sizeof(ent) );
+               ret = krb5_parse_name(context, a->a_vals[0].bv_val, &ent.principal);
+               if ( ret ) break;
+               krb5_get_pw_salt( context, ent.principal, &salt );
+               krb5_free_principal( context, ent.principal );
+
+               a = attr_find( e->e_attrs, ad_krb5Key );
+               if ( !a ) break;
+
+               ent.keys.len = 1;
+               ent.keys.val = &ekey;
+               decode_Key((unsigned char *) a->a_vals[0].bv_val,
+                       (size_t) a->a_vals[0].bv_len, &ent.keys.val[0], &l);
+               if ( db->master_key_set )
+                       hdb_unseal_keys( context, db, &ent );
+
+               krb5_string_to_key_salt( context, ekey.key.keytype, cred->bv_val,
+                       salt, &key );
+
+               krb5_free_salt( context, salt );
+
+               if ( memcmp( ekey.key.keyvalue.data, key.keyvalue.data,
+                       key.keyvalue.length ) == 0 ) rc = LUTIL_PASSWD_OK;
+
+               krb5_free_keyblock_contents( context, &key );
+               krb5_free_keyblock_contents( context, &ekey.key );
+
+       } while(0);
+       be_entry_release_r( op, e );
+       return rc;
+}
+#endif /* DO_KRB5 */
+
+static int smbk5pwd_exop_passwd(
        Operation *op,
        SlapReply *rs )
 {
@@ -220,6 +348,8 @@ int smbk5pwd_exop_passwd(
                keys[i].bv_val = NULL;
                keys[i].bv_len = 0;
 
+               _kadm5_free_keys(kadm_context, ent.keys.len, ent.keys.val);
+
                if ( i != ent.keys.len ) {
                        ber_bvarray_free( keys );
                        break;
@@ -389,6 +519,12 @@ int smbk5pwd_init() {
        smbk5pwd.on_bi.bi_type = "smbk5pwd";
        smbk5pwd.on_bi.bi_extended = smbk5pwd_exop_passwd;
 
+#ifdef DO_KRB5
+       smbk5pwd.on_bi.bi_op_bind = smbk5pwd_op_bind;
+
+       lutil_passwd_add( (struct berval *)&scheme, chk_k5key, NULL );
+#endif
+
        return overlay_register( &smbk5pwd );
 }
 
index c061f2e1b41b2b4aef05bd4242e4ec72887698d0..80bf61f7c90616c69dd9666c39baf1482ff5c47a 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2004 The OpenLDAP Foundation. All rights reserved.
+Copyright 2004-2005 The OpenLDAP Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
index 415b0ef9a51a7fba55d8a76d5e86b698f7e52ef5..970fad4c46b8b28aa0b5c21886039e4fbac4c9a7 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2003-2004 The OpenLDAP Foundation. All rights reserved.
+Copyright 2003-2005 The OpenLDAP Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted only as authorized by the OpenLDAP
index 0aad380363c3ff3a151daa85ddebcf051a62c02a..cc57b151a76c6f353fb2b26b03fb56a144d84e0f 100644 (file)
@@ -1,6 +1,6 @@
 ## doc Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 649a94c0bc8873d509e26d7f6a8d6f7f4e0d37bf..cd8110b7280062fa80fcf458600583592ec427bf 100644 (file)
@@ -1,6 +1,6 @@
 # man Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index d0605db3c40897e657d92cc437cd26aa6f9efab7..ec72d43eea19ab3132f75730761db55b90b5bded 100644 (file)
@@ -1,6 +1,6 @@
 # man1 Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 409e267e4ecbf80c36c7cb9523d4cd58eccc6a02..8ad047c5a426234e685c86f2c410c947ff5b3904 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPCOMPARE 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapcompare \- LDAP compare tool
index 5c2187d5b0433c9c0906792d9caef40126ef64ec..d7063687ad73503c2a0a31b932be4cff0fb03444 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPDELETE 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapdelete \- LDAP delete entry tool
index 2118feb2888c2679ce7f3a34e13679d951002d7f..5f36dbe79eef75591956276a765f48edce1d9b9b 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPMODIFY 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
index 3ccf57c6299c2b20638141e21a1da0fdfae8952f..b00d6da60c6247da91f350b362232b038051e854 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPMODRDN 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapmodrdn \- LDAP rename entry tool
index dbcfbca10481b54943adf6788fecdd7e53b60ce0..c770a01caba6bdc0992fdbb7b5e3236d694e6a68 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPPASSWD 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldappasswd \- change the password of an LDAP entry
index 3f44bc3fdb0d4688a2b0ebb77994f1df8db8dc99..f6bcb26bd003f87e7388ad225af175b6a2101a84 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapsearch \- LDAP search tool
index ec95cadd5c05f6c13e0efd5a06a89da9ae14354a..89c3d9d41239160bad354f92c727787768b8e992 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAPWHOAMI 1 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldapwhoami \- LDAP who am i? tool
index 5214a91d780425a8612b41d956fd25f6e59b7552..af516dc0e25dcc6f57a6ff2ec45f337a8e20f119 100644 (file)
@@ -1,6 +1,6 @@
 # man3 Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f3f732929be7fbb161d1f7ffefacf82e90314f24..ada95df9e11675fd4f1586bde22d58766a6dd513 100644 (file)
@@ -1,6 +1,6 @@
 .TH LBER_DECODE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ber_get_next, ber_skip_tag, ber_peek_tag, ber_scanf, ber_get_int,
index d596c7f775f70cfecdb9c241da7b8b5a8dbbf34f..13ddc1b1d522bde905169af3c3f15c507928c4ab 100644 (file)
@@ -1,6 +1,6 @@
 .TH LBER_ENCODE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ber_alloc_t, ber_flush, ber_printf, ber_put_int, ber_put_enum, ber_put_ostring, ber_put_string, ber_put_null, ber_put_boolean, ber_put_bitstring, ber_start_seq, ber_start_set, ber_put_seq, ber_put_set \- LBER simplified Basic Encoding Rules library routines for encoding
index b2fed65133033437cecb7b5a5367257246a02de1..b6ec49e27ad52a31da615e6a974cde8c3f25914d 100644 (file)
@@ -1,6 +1,6 @@
 .TH LBER_MEMORY 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ber_memalloc, ber_memcalloc, ber_memrealloc, ber_memfree, ber_memvfree \- LBER memory allocators
index fbe566c262f8c6508116bdef7a33bcee23efa069..7ea74dd9c7ee574d33c8cbad3ebb8895cfea544e 100644 (file)
@@ -1,6 +1,6 @@
 .TH LBER_TYPES 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ber_int_t, ber_uint_t, ber_len_t, ber_slen_t, ber_tag_t,
index 9c1bccdbb148c5228fdb7e80e2b7bbf9b386dcc3..fae4ee2bf7daa372a20cfa8991a8e88bcb5441c3 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap - OpenLDAP Lightweight Directory Access Protocol API
index cbba63f439e9d1224005091d083d687358432ac1..10ed5c812e06ea438b53ecf5adf191029b0090c3 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_ABANDON 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_abandon, ldap_abandon_ext \- Abandon an LDAP operation in progress
index 94aa428c239c76bdd563b7432fb077dd337070ee..a0faad17ca0067705c49dbcec5c74e7623a65e22 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_ADD 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_add, ldap_add_s, ldap_add_ext, ldap_add_ext_s \- Perform an LDAP add operation
index a669e72cc95172aef90521114d657942c4bb3d06..7f8b94bc8a111e477b52d362482f415354d8af67 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_BIND 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_bind, ldap_bind_s, ldap_simple_bind, ldap_simple_bind_s, ldap_kerberos_bind_s, ldap_kerberos_bind1, ldap_kerberos_bind1_s, ldap_kerberos_bind2, ldap_kerberos_bind2_s, ldap_sasl_bind, ldap_sasl_bind_s, ldap_sasl_interactive_bind_s, ldap_parse_sasl_bind_result, ldap_unbind, ldap_unbind_s \- LDAP bind routines
index 3d1dbbb94ef508efa3dc677f0b41aab2bf1d9d3a..224f863328b103cd2f29d38b921a5d38af51757a 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_COMPARE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_compare, ldap_compare_s \- Perform an LDAP compare operation
index b7669ea48580813de6389e03e1267bee68e98fe1..754f8bbb7ffe7363cd522ef9e6a401f6d5c480a9 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_DELETE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_delete, ldap_delete_s \- Perform an LDAP delete operation
index 5b940d7b55ae0329ad904ea7c9c302df6219961a..7a77fa1115192d0287092d761385f913a3a4da80 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_ERROR 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_perror, ld_errno, ldap_result2error, ldap_errlist, ldap_err2string \- LDAP protocol error handling routines
index f8b9f2b9387523e30aa7bfadf49fcd193e711d21..ede0f79075ebab9b8270098ab350ad94b7540856 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_FIRST_ATTRIBUTE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_first_attribute, ldap_next_attribute \- step through LDAP entry attributes
index b1648c10c16b322986e738cb2b16b2b8c7aa2018..1e16ca5ae9c7eb0b9afc9c7258a4ff5a61d29a7c 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_FIRST_ENTRY 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_first_entry, ldap_next_entry, ldap_count_entries \- LDAP result entry parsing and counting routines
index c032dcea08768eab90e168c699961e326e4e0c5c..85e325338bafd86b0c0526329a28a28a9a1c0820 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_FIRST_MESSAGE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_first_message, ldap_next_message, ldap_count_messages \- Stepping
index a98e610a96d22a0a00017f07ff4fb6c7131c88cd..004c9638b1d660ffdd600c7e887c3fb31d562e51 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_FIRST_REFERENCE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_first_reference, ldap_next_reference, ldap_count_references \- Stepping
index b6394b71dd39b88ccd0e100184dc42c6606c197e..c1757770decd0299b9ad51529a8f6487647bcb66 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_GET_DN 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_get_dn, ldap_explode_dn, ldap_explode_rdn, ldap_dn2ufn \- LDAP DN handling routines
index 580965da063fdb18157037b4a294b7138d644b1e..3cee384e47f5cf1661a8ee6a6e26827c07ca20c9 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_GET_VALUES 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_get_values, ldap_get_values_len, ldap_count_values \- LDAP attribute value handling routines
index 39da48bcce20711ee375f1912ca3257841bf0639..64a04913489a76d9863d108c7dc3ecd0fcf929d4 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_MODIFY 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_modify, ldap_modify_s \- Perform an LDAP modify operation
index 13945377e04c211e2f585be756330b0db4446e6a..d45c5ea5eec983590e2aa453dc210f763ff30628 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_MODRDN 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_modrdn, ldap_modrdn_s, ldap_modrdn2, ldap_modrdn2_s \- Perform an LDAP modify RDN operation
index 293fbbff7ae05564aff0b2cc234c734609ebcab9..5e9d8fb49b2676731c39f7fc09b0777758b13476 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_OPEN 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_init, ldap_open \- Initialize the LDAP library and open a connection to an LDAP server
index 3a0a34d14eb812fed9692eaa529bf483b63e02f9..a0991d7c7b4adf9c6c540fba55a6bd75a10f4db1 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_PARSE_REFERENCE 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_parse_reference \- Extract referrals and controls from a reference message
index fa2374230a5af6755960e6fc2add93d7a002a987..e652256cbedf6b0330bdd7115e6f6e020f02fef6 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_PARSE_RESULT 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_parse_result \- Parsing results
index 6afee4973de4d1f5addf775ae389e532ee6e0aba..64552a55afc3b3991ccd7231a5b257ed9bcdf68b 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_RESULT 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_result \- Wait for the result of an LDAP operation
index 6e3ddc75e23b9ea578e2ea2b18fd0ef63813e89f..d72e308928ecfccbcadd2b5393de06f45039d26e 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_SCHEMA 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 2000-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2000-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_str2syntax, ldap_syntax2str, ldap_syntax2name, ldap_syntax_free,
index a0489a48351e067309e46e5e45bc349a4be7134e..dcdd07ad84fb8ca78b230b1669ac084e119711fd 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_SEARCH 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_search, ldap_search_s, ldap_search_st \- Perform an LDAP search operation
index 2f8b356b73b312e5dc87be03b99033a50b6117e3..ebca400cf164732195b0af8a6e2dd75a440c158e 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_SORT 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_sort_entries, ldap_sort_values, ldap_sort_strcasecmp \- LDAP sorting routines
index 24998f57593b8f004fcd746dd31da510cf8c176e..5ed6ee9a9b4b2562c8a6705427a598e4ba9ae16e 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP_URL 3 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldap_is_ldap_url,
index 81ed991ad4bbd5308e5c60f41742ab78d5c2a8c4..f51c6a178bd543575473119a022b93af00dee109 100644 (file)
@@ -1,6 +1,6 @@
 # man5 Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 07148ae31c4fc1d1c9d88229124626aa50088965..a2a3141494dbc78b0fd2d749e16fe5d8a1a062e8 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDAP.CONF 5 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .UC 6
 .SH NAME
index 2ba94843795f658cef8d84c4dddc07faa195b991..d5abe38c83f4d193503a719c3ffbbfaa5571baa2 100644 (file)
@@ -1,6 +1,6 @@
 .TH LDIF 5 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 ldif \- LDAP Data Interchange Format
index a6206d2497510fb719d43505956cf47174404b61..50716b7c7e0f65b888753cb80a1957e965acb76b 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-BDB 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
@@ -92,7 +92,11 @@ Some attributes only support a subset of indexes.
 If only an <attr> is given, the indices specified for \fBdefault\fR
 are maintained.
 Note that setting a default does not imply that all attributes will be
-indexed.
+indexed. Also, for best performance, an
+.B eq
+index should always be configured for the
+.B objectClass
+attribute.
 
 A number of special index parameters may be specified.
 The index type
index f2ea3f4798ab3af5df9730b44ce16c172a298d09..c4afb8590878520bc6f316f7baad8be7c0bbda7e 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-DNSSRV 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index 7380682d3dcb26400e1d513378a4746ab3998d53..e345281e53b1568be76dff541dddb919a88363e2 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-LDAP 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index 9296443cb2c20e6185d6667a1efaabf62f272fba..f62d2e6cdcfa2b002cab8f8245156110464c9739 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-LDBM 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
@@ -93,7 +93,11 @@ Some attributes only support a subset of indexes.
 If only an <attr> is given, the indices specified for \fBdefault\fR
 are maintained.
 Note that setting a default does not imply that all attributes will be
-indexed.
+indexed. Also, for best performance, an
+.B eq
+index should always be configured for the
+.B objectClass
+attribute.
 
 A number of special index parameters may be specified.
 The index type
index f9ef4fc3c8bc3798b7f1f58a4bffdd946c5771c9..c063ab22479176a002127858486c240649229402 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation, All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation, All Rights Reserved.
 .\" Copying restrictions apply.  See the COPYRIGHT file.
 .\" Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
 .\" $OpenLDAP$
index 80344166ed1fe98867c36083cf11e0cdde67ee59..7ecc06a282cbad2a8440ee9eed360a136764d097 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-MONITOR 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index 2bc28cd9e6b50c3d3ac2eadf5ac84e9e4653ddb6..25eb2c9faec9bf62cadb2c0007f4ce5ff1e390a2 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-PASSWD 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index 24d217b2143bb908be38724a81dd2c665339f6ba..c265616dc21ed182914f9ccfc80c905f610fc941 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD-SHELL 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index e49b7c75f90e14d15f55041374a21cb0edd01b3a..03d31c381f08efa9c4a45f0f5a38e17944bbfe00 100644 (file)
@@ -41,90 +41,185 @@ for SQL dialects RDBMSes may use, so it may be used for integration
 and distribution of data on different RDBMSes, OSes, hosts etc., in
 other words, in highly heterogeneous environment.
 .LP
-This backend is experimental.
+This backend is \fIexperimental\fP.
 .SH CONFIGURATION
 These
 .B slapd.conf
-options apply to the SQL backend database.
-That is, they must follow a "database sql" line and come before any
+options apply to the SQL backend database, which means that 
+they must follow a "database sql" line and come before any
 subsequent "backend" or "database" lines.
-Other database options are described in the
+Other database options not specific to this backend are described 
+in the
 .BR slapd.conf (5)
 manual page.
+.SH DATA SOURCE CONFIGURATION
+
 .TP
 .B dbname <datasource name>
 The name of the ODBC datasource to use.
 .LP
 .B dbhost <hostname>
 .br
-.B dbuser <username>
-.br
 .B dbpasswd <password>
+.br
+.B dbuser <username>
 .RS
-These three options are generally unneeded, because this information is already
-taken from the datasource.
-Use them if you need to override datasource settings.
+The three above options are generally unneeded, because this information
+is taken from the datasource specified by the
+.B dbname
+directive.
+They allow to override datasource settings.
 Also, several RDBMS' drivers tend to require explicit passing of user/password,
 even if those are given in datasource (Note:
 .B dbhost
 is currently ignored).
 .RE
+.SH SCOPING CONFIGURATION
+These options specify SQL query templates for scoping searches.
+
 .TP
 .B subtree_cond <SQL expression>
 Specifies a where-clause template used to form a subtree search condition
-(dn=".*<dn>").
+(dn="(.+,)?<dn>$").
 It may differ from one SQL dialect to another (see samples).
+By default, it is constructed based on the knowledge about
+how to normalize DN values (e.g.
+\fB"<upper_func>(ldap_entries.dn) LIKE CONCAT('%',?)"\fP);
+see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
+and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
+
 .TP
 .B children_cond <SQL expression>
 Specifies a where-clause template used to form a children search condition
-(dn="\.+,<dn>").
+(dn=".+,<dn>$").
 It may differ from one SQL dialect to another (see samples).
+By default, it is constructed based on the knowledge about
+how to normalize DN values (e.g.
+\fB"<upper_func>(ldap_entries.dn) LIKE CONCAT('%,',?)"\fP);
+see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
+and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
+
+.TP
+.B use_subtree_shortcut { NO | yes }
+Do not use the subtree condition when the searchBase is the database
+suffix, and the scope is subtree; rather collect all entries.
+
+.RE
+.SH STAMEMENT CONFIGURATION
+These options specify SQL query templates for loading schema mapping
+metainformation, adding and deleting entries to ldap_entries, etc.
+All these and subtree_cond should have the given default values.
+For the current value it is recommended to look at the sources,
+or in the log output when slapd starts with "-d 5" or greater.
+Note that the parameter number and order must not be changed.
+
 .TP
 .B oc_query <SQL expression>
+The query that is used to collect the objectClass mapping data
+from table \fIldap_oc_mappings\fP; see "METAINFORMATION USED" for details.
 The default is
-.B "SELECT id, name, keytbl, keycol, create_proc, delete_proc, expect_return FROM ldap_oc_mappings"
+\fB"SELECT id, name, keytbl, keycol, create_proc, delete_proc, expect_return
+FROM ldap_oc_mappings"\fP.
+
 .TP
 .B at_query <SQL expression>
+The query that is used to collect the attributeType mapping data
+from table \fIldap_attr_mappings\fP; see "METAINFORMATION USED" for details.
 The default is
-.B "SELECT name, sel_expr, from_tbls, join_where, add_proc, delete_proc, param_order, expect_return FROM ldap_attr_mappings WHERE oc_map_id=?"
+\fB"SELECT name, sel_expr, from_tbls, join_where, add_proc, delete_proc,
+param_order, expect_return FROM ldap_attr_mappings WHERE oc_map_id=?"\fP.
+
 .TP
-.B insentry_query <SQL expression>
+.B id_query <SQL expression>
+The query that is used to map a DN to an entry
+in table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
 The default is
-.B "INSERT INTO ldap_entries (dn, oc_map_id, parent, keyval) VALUES (?, ?, ?, ?)"
+\fB"SELECT id,keyval,oc_map_id,dn FROM ldap_entries WHERE <DN match expr>"\fP,
+where \fB<DN match expr>\fP is constructed based on the knowledge about
+how to normalize DN values (e.g. \fB"dn=?"\fP if no means to uppercase
+strings are available; typically, \fB"<upper_func>(dn)=?"\fP is used);
+see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
+and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
+
 .TP
-.B delentry_query <SQL expression>
+.B insentry_stmt <SQL expression>
+The statement that is used to insert a new entry
+in table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
 The default is
-.B "DELETE FROM ldap_entries WHERE id=?"
+\fB"INSERT INTO ldap_entries (dn, oc_map_id, parent, keyval) VALUES
+(?, ?, ?, ?)"\fP.
+
+.TP
+.B delentry_stmt <SQL expression>
+The statement that is used to delete an existing entry
+from table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
+The default is
+\fB"DELETE FROM ldap_entries WHERE id=?"\fP.
+
+.TP
+.B delobjclasses_stmt <SQL expression>
+The statement that is used to delete an existing entry's ID
+from table \fIldap_objclasses\fP; see "METAINFORMATION USED" for details.
+The default is
+\fB""DELETE FROM ldap_entry_objclasses WHERE entry_id=?"\fP.
+
+.RE
+.SH HELPER CONFIGURATION
+These statements are used to modify the default behavior of the backend
+according to issues of the dialect of the RDBMS.
+The first options essentially refer to string and DN normalization
+when building filters.
+LDAP normalization is more than upper- (or lower-)casing everything;
+however, as a reasonable trade-off, for case-sensitive RDBMSes the backend
+can be instructed to uppercase strings and DNs by providing
+the \fBupper_func\fP directive.
+Some RDBMSes, to use functions on arbitrary data types, e.g. string
+constants, requires a cast, which is triggered
+by the \fBupper_needs_cast\fP directive.
+If required, a string cast function can be provided as well,
+by using the \fBstrcast_func\fP directive.
+Finally, a custom string concatenation pattern may be required;
+it is provided by the \fBconcat_pattern\fP directive.
 
-These four options specify SQL query templates for loading schema mapping
-metainformation, adding and deleting entries to ldap_entries, etc.
-All these and subtree_cond should have the given default values.
-For the current value it is recommended to look at the sources,
-or in the log output when slapd starts with "-d 5" or greater.
-Note that the parameter number and order must not be changed.
 .TP
 .B upper_func <SQL function name>
 Specifies the name of a function that converts a given value to uppercase.
-This is used for CIS matching when the RDBMS is case sensitive.
+This is used for case insensitive matching when the RDBMS is case sensitive.
+It may differ from one SQL dialect to another (e.g. \fBUCASE\fP, \fBUPPER\fP
+or whatever; see samples).  By default, none is used, i.e. strings are not
+uppercased, so matches may be case sensitive.
+
 .TP
-.B upper_needs_cast { NO | yes}
+.B upper_needs_cast { NO | yes }
 Set this directive to 
 .B yes
 if 
 .B upper_func
-needs an explicit cast when applied to literal strings.  The form
+needs an explicit cast when applied to literal strings.
+A cast in the form
 .B CAST (<arg> AS VARCHAR(<max DN length>))
 is used, where
 .B <max DN length>
-is builtin.
-This is
-.B experimental 
-and may change in future releases.
+is builtin in back-sql; see macro
+.B BACKSQL_MAX_DN_LEN
+(currently 255; note that slapd's builtin limit, in macro
+.BR SLAP_LDAPDN_MAXLEN ,
+is set to 8192).
+This is \fIexperimental\fP and may change in future releases.
+
+.TP
 .TP
+.B strcast_func <SQL function name>
+Specifies the name of a function that converts a given value to a string
+for appropriate ordering.  This is used in "SELECT DISTINCT" statements
+for strongly typed RDBMSes with little implicit casting (like PostgreSQL),
+when a literal string is specified.
+This is \fIexperimental\fP and may change in future releases.
+
 .B concat_pattern <pattern>
 This statement defines the
 .B pattern 
-to be used to concatenate strings.  The
+that is used to concatenate strings.  The
 .B pattern
 MUST contain two question marks, '?', that will be replaced 
 by the two strings that must be concatenated.  The default value is
@@ -135,40 +230,26 @@ but an explicit cast may be required when operating on literal strings:
 .BR "CAST(?||? AS VARCHAR(<length>))".
 On some RDBMSes (IBM db2, MSSQL) the form
 .B "?+?"
-is known to work.
+is known to work as well.
 Carefully check the documentation of your RDBMS or stay with the examples
 for supported ones.
-This is
-.B experimental 
-and may change in future releases.
-.TP
-.B strcast_func <SQL function name>
-Specifies the name of a function that converts a given value to a string
-for appropriate ordering.  This is used in "SELECT DISTINCT" statements
-for strongly typed RDBMSes with little implicit casting (like PostgreSQL),
-when a literal string is specified.
-This is
-.B experimental 
-and may change in future releases.
+This is \fIexperimental\fP and may change in future releases.
+
 .TP
 .B has_ldapinfo_dn_ru { NO | yes }
-Explicitly inform the backend whether the SQL schema has dn_ru column
-(dn in reverse uppercased form) or not.
-Overrides automatic check (required by PostgreSQL/unixODBC).
-This is
-.B experimental 
-and may change in future releases.
+Explicitly inform the backend whether the dn_ru column
+(DN in reverse uppercased form) is present in table \fIldap_entries\fP.
+Overrides automatic check (this is required, ofr instance,
+by PostgreSQL/unixODBC).
+This is \fIexperimental\fP and may change in future releases.
 
 .TP
 .B fail_if_no_mapping { NO | yes }
 When set to
 .B yes
-it forces
-.I attribute 
-write operations to fail if no appropriate mapping between LDAP attributes 
-and SQL data is available.
-The default behavior is to ignore those changes that cannot be mapped 
-correctly.
+it forces \fIattribute\fP write operations to fail if no appropriate
+mapping between LDAP attributes and SQL data is available.
+The default behavior is to ignore those changes that cannot be mapped.
 It has no impact on objectClass mapping, i.e. if the
 .I structuralObjectClass
 of an entry cannot be mapped to SQL by looking up its name 
@@ -177,9 +258,7 @@ in ldap_oc_mappings, an
 operation will fail regardless of the
 .B fail_if_no_mapping
 switch; see section "METAINFORMATION USED" for details.
-This is
-.B experimental 
-and may change in future releases.
+This is \fIexperimental\fP and may change in future releases.
 
 .TP
 .B allow_orphans { NO | yes }
@@ -191,26 +270,53 @@ in conjunction with some special rule on the RDBMS side that
 dynamically creates the missing parent.
 
 .TP
-.B baseObject [filename]
+.B baseObject [ <filename> ]
 Instructs the database to create and manage an in-memory baseObject
 entry instead of looking for one in the RDBMS.
 If the (optional) 
-.B filename
-argument is given, the entry is read from file
-.B filename
-in
+.B <filename>
+argument is given, the entry is read from that file in
 .BR LDIF (5)
-form.
-This is particularly useful when
-.B ldap_entries 
+format; otherwise, an entry with objectClass \fBextensibleObject\fP
+is created based on the contents of the RDN of the \fIbaseObject\fP.
+This is particularly useful when \fIldap_entries\fP
 information is stored in a view rather than in a table, and 
 .B union
 is not supported for views, so that the view can only specify
 one rule to compute the entry structure for one objectClass.
 This topic is discussed further in section "METAINFORMATION USED".
-This is
-.B experimental 
-and may change in future releases.
+This is \fIexperimental\fP and may change in future releases.
+
+.TP
+.B create_needs_select { NO | yes }
+Instructs the database whether or not entry creation
+in table \fIldap_entries\fP needs a subsequent select to collect 
+the automatically assigned ID, instead of being returned 
+by a stored procedure.
+
+.LP
+.B fetch_attrs <attrlist>
+.br
+.B fetch_all_attrs { NO | yes }
+.RS
+The first statement allows to provide a list of attributes that
+must always be fetched in addition to those requested by any specific
+operation, because they are required for the proper usage of the
+backend.  For instance, all attributes used in ACLs should be listed
+here.  The second statement is a shortcut to require all attributes 
+to be always loaded.  Note that the dynamically generated attributes,
+e.g. \fIhasSubordinates\fP, \fIentryDN\fP and other implementation
+dependent attributes are \fBNOT\fP generated at this point, for
+consistency with the rest of slapd.  This may change in the future.
+.RE
+
+.TP
+.B sqllayer <name> [...]
+Loads the layer \fB<name>\fP onto a stack of helpers that are used 
+to map DNs from LDAP to SQL representation and vice-versa.
+Subsequent args are passed to the layer configuration routine.
+This is \fIhighly experimental\fP and should be used with extreme care.
+The API of the layers is not frozen yet, so it is unpublished.
 
 .SH METAINFORMATION USED
 .LP
@@ -280,7 +386,7 @@ for telephoneNumber we can use:
 .LP
 .nf
   SELECT phones.phone AS telephoneNumber FROM persons,phones
-   WHERE persons.id=phones.pers_id AND persons.id=?
+      WHERE persons.id=phones.pers_id AND persons.id=?
 .fi
 .LP
 If we wanted to service LDAP requests with filters like
@@ -288,11 +394,15 @@ If we wanted to service LDAP requests with filters like
 .LP
 .nf
   SELECT ... FROM persons,phones
-   WHERE persons.id=phones.pers_id
-     AND persons.id=?
-     AND phones.phone like '123%'
+      WHERE persons.id=phones.pers_id
+          AND persons.id=?
+          AND phones.phone like '%1%2%3%'
 .fi
 .LP
+(note how the telephoneNumber match is expanded in multiple wildcards
+to account for interspersed ininfluential chars like spaces, dashes
+and so; this occurs by design because telephoneNumber is defined after 
+a specially recognized syntax).
 So, if we had information about what tables contain values for each
 attribute, how to join these tables and arrange these values, we could
 try to automatically generate such statements, and translate search
@@ -402,13 +512,15 @@ like this (by Robin Elfrink):
   CREATE VIEW ldap_entries (id, dn, oc_map_id, parent, keyval)
       AS
           SELECT 0, UPPER('o=MyCompany,c=NL'),
-  3, 0, 'baseObject' FROM unixusers WHERE userid='root' UNION
+              3, 0, 'baseObject' FROM unixusers WHERE userid='root'
+      UNION
           SELECT (1000000000+userid),
-  UPPER(CONCAT(CONCAT('cn=',gecos),',o=MyCompany,c=NL')),
-  1, 0, userid FROM unixusers UNION
+              UPPER(CONCAT(CONCAT('cn=',gecos),',o=MyCompany,c=NL')),
+              1, 0, userid FROM unixusers
+      UNION
           SELECT (2000000000+groupnummer),
-  UPPER(CONCAT(CONCAT('cn=',groupnaam),',o=MyCompany,c=NL')),
-  2, 0, groupnummer FROM groups;
+              UPPER(CONCAT(CONCAT('cn=',groupnaam),',o=MyCompany,c=NL')),
+              2, 0, groupnummer FROM groups;
 .fi
 
 .LP
@@ -439,7 +551,7 @@ query generated (which loads candidate IDs)
      AND ldap_entries.objclass=?
      AND ldap_entries.parent=?
      AND phones.pers_id=persons.id
-     AND (phones.phone LIKE '123%')
+     AND (phones.phone LIKE '%1%2%3%')
 .fi
 .LP
 (for ONELEVEL search)
@@ -465,24 +577,23 @@ ADD, DELETE, MODIFY and MODRDN operations are also performed on per-attribute
 metainformation (add_proc etc.).
 In those fields one can specify an SQL statement or stored procedure
 call which can add, or delete given values of a given attribute, using
-the given entry keyval (see examples -- mostly ORACLE and MSSQL - since
-there're no stored procs in mySQL).
+the given entry keyval (see examples -- mostly PostgreSQL, ORACLE and MSSQL 
+- since as of this writing there are no stored procs in MySQL).
 .LP
-We just add more columns to oc_mappings and attr_mappings, holding
+We just add more columns to ldap_oc_mappings and ldap_attr_mappings, holding
 statements to execute (like create_proc, add_proc, del_proc etc.), and
 flags governing the order of parameters passed to those statements.
 Please see samples to find out what are the parameters passed, and other
 information on this matter - they are self-explanatory for those familiar
-with concept expressed above.
+with the concepts expressed above.
 .LP
 .SH Common techniques (referrals, multiclassing etc.)
 First of all, let's remember that among other major differences to the
 complete LDAP data model, the concept above does not directly support
 such things as multiple objectclasses per entry, and referrals.
 Fortunately, they are easy to adopt in this scheme.
-The SQL backend suggests two more tables being added to the schema -
-ldap_entry_objectclasses(entry_id,oc_name), and
-ldap_referrals(entry_id,url).
+The SQL backend suggests one more table being added to the schema:
+ldap_entry_objectclasses(entry_id,oc_name).
 .LP
 The first contains any number of objectclass names that corresponding
 entries will be found by, in addition to that mentioned in
@@ -492,29 +603,43 @@ attribute to each objectclass mapping that loads values from this table.
 So, you may, for instance, have a mapping for inetOrgPerson, and use it
 for queries for "person" objectclass...
 .LP
-The second table contains any number of referrals associated with a given entry.
-The SQL backend automatically adds attribute mapping for "ref" attribute
-to each objectclass mapping that loads values from this table.
-So, if you add objectclass "referral" to this entry, and make one or
-more tuples in ldap_referrals for this entry (they will be seen as
-values of "ref" attribute), you will have slapd return a referral, as
-described in the Administrators Guide.
+Referrals used to be implemented in a loose manner by adding an extra
+table that allowed any entry to host a "ref" attribute, along with
+a "referral" extra objectClass in table ldap_entry_objclasses.
+In the current implementation, referrals are treated like any other
+user-defined schema, since "referral" is a structural objectclass.
+The suggested practice is to define a "referral" entry in ldap_oc_mappings,
+holding a naming attribute, e.g. "ou" or "cn", a "ref" attribute,
+containing the url; in case multiple referrals per entry are needed,
+a separate table for urls can be created, where urls are mapped
+to the respective entries.
+The use of the naming attribute usually requires to add 
+an "extensibleObject" value to ldap_entry_objclasses.
+
 .LP
 .SH Caveats
 As previously stated, this backend should not be considered
 a replacement of other data storage backends, but rather a gateway
 to existing RDBMS storages that need to be published in LDAP form.
 .LP
-The hasSubordintes operational attribute is honored by back-sql
+The \fBhasSubordintes\fP operational attribute is honored by back-sql
 in search results and in compare operations; it is partially honored
-also in filtering.  Owing to design limitations, a (braindead) filter
+also in filtering.  Owing to design limitations, a (braindead?) filter
 of the form
 \fB(!(hasSubordinates=TRUE))\fP
-will give no results instead of returning all the leaf entries.
+will give no results instead of returning all the leaf entries, because
+it actually expands into \fB... AND NOT (1=1)\fP.
 If you need to find all the leaf entries, please use
 \fB(hasSubordinates=FALSE)\fP
 instead.
 .LP
+A directoryString value of the form "__First___Last_"
+(where underscores should be replaced by spaces) corresponds
+to its prettified counterpart "First_Last"; this is not currently
+honored by back-sql if non-prettified data is written via RDBMS;
+when non-prettified data is written thru back-sql, the prettified 
+values are actually used instead.
+.LP
 .SH PROXY CACHE OVERLAY
 The proxy cache overlay 
 allows caching of LDAP search requests (queries) in a local database.
@@ -525,6 +650,7 @@ for details.
 There are example SQL modules in the slapd/back-sql/rdbms_depend/
 directory in the OpenLDAP source tree.
 .SH FILES
+
 .TP
 ETCDIR/slapd.conf
 default slapd configuration file
index 9fffff3ed7f6edefd84db08105484b50e9dbd73f..be14cf19fb9e821de9c067370c9d3b71cfcc11d1 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD.ACCESS 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapd.access \- access configuration for slapd, the stand-alone LDAP daemon
@@ -190,20 +190,19 @@ form is given,
 is implied, i.e. all attributes are addressed.
 .LP
 Using the form
-.B attrs=<attr> val[.<style>]=<attrval>
+.B attrs=<attr> val[.<attrstyle>]=<attrval>
 specifies access to a particular value of a single attribute.
-In this case, only a single attribute type may be given. A value
-.B <style>
-of
+In this case, only a single attribute type may be given. The
+.B <attrstyle>
 .B exact
 (the default) uses the attribute's equality matching rule to compare the
-value. If the value
-.B <style>
+value. If the
+.B <attrstyle>
 is
 .BR regex ,
 the provided value is used as a POSIX (''extended'') regular
-expression pattern.  If the attribute has DN syntax, the value
-.B <style>
+expression pattern.  If the attribute has DN syntax, the 
+.B <attrstyle>
 can be any of
 .BR base ,
 .BR onelevel ,
index 59051d01372fe0985502a417c01cb0cf2511c90a..8f8a4dab003a4f2375c3fc6506bc03bb2eef121a 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD.CONF 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
@@ -1373,7 +1373,7 @@ when initially populating a database).  If the rootdn is within
 a namingContext (suffix) of the database, a simple bind password
 may also be provided using the
 .B rootpw
-directive.
+directive. Note that the rootdn is always needed when using syncrepl.
 .TP
 .B rootpw <password>
 Specify a password (or hash of the password) for the rootdn.  The
@@ -1410,7 +1410,7 @@ with the inner suffix must come first in the configuration file.
 .B [sizelimit=<limit>]
 .B [timelimit=<limit>]
 .B [schemachecking=on|off]
-.B [updatedn=<dn>]
+.B [starttls=yes|critical]
 .B [bindmethod=simple|sasl]
 .B [binddn=<dn>]
 .B [saslmech=<mech>]
@@ -1486,15 +1486,12 @@ consumer site by turning on the
 .B schemachecking
 parameter. The default is off.
 The
-.B updatedn
-parameter specifies the DN in the consumer site
-which is allowed to make changes to the replica.
-The DN should have read/write access to the replica database.
-Generally, this DN
-.I should not
-be the same as the
-.B rootdn
-of the master database.
+.B starttls
+parameter specifies use of the StartTLS extended operation
+to establish a TLS session before Binding to the provider. If the
+.B critical
+argument is supplied, the session will be aborted if the StartTLS request
+fails. Otherwise the syncrepl session continues without TLS.
 A
 .B bindmethod
 of 
index d247e07a4ffee1b2cb9c3f9f4426f22db87b3486..85f12d4519da4e34224d4173d91c37b0962e6c02 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPD.PLUGIN 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2002-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2002-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapd.plugin \- plugin configuration for slapd, the stand-alone LDAP daemon
index d176d1ac9bf924a0daee3c9075b95809016df3bb..ddbcbc73d2a58156d4dd660ab955e8affa921982 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLAPD.REPLOG 5 "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapd.replog \- slapd replication log format
index b9173843741c2db33f127d9fb558f30885494120..9f53458f5119f1320682203ba21a8017f6141433 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-CHAIN 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation, All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation, All Rights Reserved.
 .\" Copying restrictions apply.  See the COPYRIGHT file.
 .\" $OpenLDAP$
 .SH NAME
index a409a6bb86f28c52219fb5d161b0b06fd943f5a6..4d106695da02d79e9291518c610cde12cb171692 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-GLUE 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index e59db4f871f4d41ab4f9843b45be6c9a3e80cada..ea9e7462ea0df317827f868bff77f7d830fc5567 100644 (file)
@@ -1,4 +1,4 @@
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .TH SLAPO_LASTMOD 5 "RELEASEDATE" "OpenLDAP LDVERSION"
 .SH NAME
index df80050c1fd9f10e5528f60089526be4b381d394..e925554d7125dff75cf7ccef670bfcbfd54146c3 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-PCACHE 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation, All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation, All Rights Reserved.
 .\" Copying restrictions apply.  See the COPYRIGHT file.
 .\" Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
 .\" $OpenLDAP$
index 977d8aef809b3056ca7fa781238e3f0da29c0218..4df428e853fcf87bd5c25c2f285f4945f74b9234 100644 (file)
@@ -1,5 +1,5 @@
 .\" $OpenLDAP$
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .TH SLAPO_PPOLICY 5 "RELEASEDATE" "OpenLDAP LDVERSION"
 .SH NAME
index 608d6f0f969838fbef5feaa8ec8f033932b1712a..44dae42f1f06c49a164a5f26a007cf195ee1e2b3 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-REFINT 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index c70e95f0103dcff09023b5403a0cc600e59f60b0..0fe80aaa7a6568cd410adf1c86ca3437d977ad48 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-RWM 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 1998-2004 The OpenLDAP Foundation, All Rights Reserved.
+.\" Copyright 1998-2005 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$
index 1df642f3153528a14be63c4c3f185b2b7d53a031..c0b611d834d365af0678dcdbcebc513927e5bd7d 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-SYNCPROV 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index cbdcc15911395bf2d25dc06c780eedfd741a8b84..ae30ff1a20e13f70e5a82ea89753af47ed44016c 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPO-UNIQUE 5 "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .\" $OpenLDAP$
 .SH NAME
index d097acc28f3ab2c0b5b59b3c87ca32018454687b..49c7ac012062b999d740952b1ec1276b278271b3 100644 (file)
@@ -1,6 +1,6 @@
 # man8 Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index c3ec91b36926f2185c093a9dc335d03aa33ff66b..a1be578dcf0433ec1b045ac24f07d83f807baf1b 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPACL 8C "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapacl \- Check access to a list of attributes.
index e9c2acca12add25597fdc0f36647f2557df7a5a1..29efdec7845ab71ea68055b6431c0a8edb4dca25 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLAPADD 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapadd \- Add entries to a SLAPD database
@@ -9,13 +9,10 @@ slapadd \- Add entries to a SLAPD database
 .B [\-v]
 .B [\-c]
 .B [\-u]
-.B [\-p]
-.B [\-r]
 .B [\-w]
 .B [\-d level]
 .B [\-b suffix]
 .B [\-n dbnum]
-.B [\-i rid1,rid2,...]
 .B [\-f slapd.conf]
 .B [\-l ldif-file]
 .SH DESCRIPTION
@@ -49,24 +46,10 @@ enable continue (ignore errors) mode.
 .B \-u
 enable dry-run (don't write to backend) mode.
 .TP
-.BI \-p
-If the LDIF input represents a syncrepl consumer replica,
-promote it to the syncrepl provider's content after adding
-the entries.
-.TP
-.BI \-r
-If  the  LDIF  input represents a  syncrepl  provider, demote 
-it  to  the syncrepl consumer replica after adding the entries.
-.TP
 .BI \-w
-When used with either 
-.B \-p
-or
-.B \-r,
-rebuild the new syncrepl
-information from the contents of the added entries.
-The syncrepl information contained in the LDIF input
-file is ignored.
+write syncrepl context information.
+After all entries are added, the contextCSN
+will be updated with the greatest CSN in the database.
 .TP
 .BI \-d " level"
 enable debugging messages as defined by the specified
@@ -87,11 +70,6 @@ cannot be used in conjunction with the
 .B \-b
 option.
 .TP
-.BI \-i " rid1,rid2,..."
-Specify the replication ids for one or more syncrepl consumer
-replicas contained in the LDIF input. If omitted, 0 is used
-as the replication id.
-.TP
 .BI \-f " slapd.conf"
 specify an alternative
 .BR slapd.conf (5)
index 2e838b654008f93ae8a5a38e89894cc6007dd3da..6b8242c610274f32b92d1c0828ec9887c2927904 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPAUTH 8C "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapauth \- Check a list of string-represented IDs for authc/authz.
index bb7e0811630251799b0c4756477054e702076a28..1609dbf8214c7825a061b3a38d7c09c635f04b85 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLAPCAT 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapcat \- SLAPD database to LDIF utility
@@ -8,8 +8,6 @@ slapcat \- SLAPD database to LDIF utility
 .B SBINDIR/slapcat
 .B [\-v]
 .B [\-c]
-.B [\-k]
-.B [\-m]
 .B [\-d level]
 .B [\-b suffix]
 .B [\-n dbnum]
@@ -44,16 +42,6 @@ Enable verbose mode.
 .B \-c
 Enable continue (ignore errors) mode.
 .TP
-.B \-k
-Include
-.B syncConsumerSubentry
-of the syncrepl consumer in the generated LDIF output.
-.TP
-.B \-m
-Include
-.B syncProviderSubentry
-of the syncrepl provider in the generated LDIF output.
-.TP
 .BI \-d " level"
 Enable debugging messages as defined by the specified
 .IR level .
index 6da01ff9206393bfb35c4206d9e02ec653afab4a..8030b21c1508242f574761a9c0b4bd628ec65710 100644 (file)
@@ -1,5 +1,5 @@
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .TH SLAPD 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .SH NAME
index 2d2a53f28e680044773d7cd0f4545cd07412643c..25a54e284a4485a8341dd65348eb93d93a89add7 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPDN 8C "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapdn \- Check a list of string-represented DNs based on schema syntax.
index 79f4e026445a71c98fc9ea8ecd2573618cee2609..be692667bdd86e0862204134cccb159f4fdb450f 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLAPINDEX 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slapindex \- SLAPD index to LDIF utility
index ee83f09d09e98d98dd70c1604440552b4bbe4e1c..d967edf0ae95391960282418f69e1dd5d65c832a 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLAPPASSWD 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slappasswd \- OpenLDAP password utility
@@ -96,10 +96,10 @@ This string needs to be in
 .BR sprintf (3)
 format and may include one (and only one) %s conversion.
 This conversion will be substituted with a string random
-characters from [A\-Za\-z0\-9./].  For example, "%.2s"
-provides a two character salt and "$1$%.8s" tells some
+characters from [A\-Za\-z0\-9./].  For example, '%.2s'
+provides a two character salt and '$1$%.8s' tells some
 versions of crypt(3) to use an MD5 algorithm and provides
-8 random characters of salt.  The default is "%s", which
+8 random characters of salt.  The default is '%s', which
 provides 31 characters of salt.
 .SH LIMITATIONS
 The practice storing hashed passwords in userPassword violates
index f01ba045ecc51f078b8ccca1b96b7e8f58433aea..168cef275ba15bc3b44bfb66118f7fbff66e909e 100644 (file)
@@ -1,5 +1,5 @@
 .TH SLAPTEST 8C "RELEASEDATE" "OpenLDAP LDVERSION"
-.\" Copyright 2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 2004-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slaptest \- Check the suitability of the slapd.conf file.
index 5082e87f7dcd2e46e14b975747184590501ce6f7..ef3799759086bc6b5cd665f5b26383b193d25923 100644 (file)
@@ -1,6 +1,6 @@
 .TH SLURPD 8C "RELEASEDATE" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
-.\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
+.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
 .SH NAME
 slurpd \- Standalone LDAP Update Replication Daemon
index 74757d5be8074aacb44a1e4cd943b9b472b567f7..1974393cf500fc02e3156efdfdd1e8c8b1ab3568 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 5fdcfc3f3516344f7b1ec1dd539c2ebe77793c9d..61c213ffeeffb4dedfa3f75d86f59362e5c4a0cd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2f3629ebada758dcd94bbfd01d327c2cdab79b19..34dd3785904412f09116546b1fc124ba4f3a7d44 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index dfb7e5359d51838d1ae5b5a0482301737910b5ea..a2408f96cd97b36c7473b59d6bf35ac97fba6e9b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e9eb037d7a06574b554c0524d9d5cba33b9451bb..928916124482fa693721856740c18ce7b6b6e2e2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c10ff20d33d30dfea5c2cd24349590d2d58e86ea..16cdc4b760e182f7da5761f0721a374e01183a66 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 95e7f3e089c48d4b84b66f8a2cd1b09e58637276..227193aeb5816bef3e302c8c3fc8ee42949406d4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e1b7168cacaa2352f68ed106d0aac918226ea47d..b0049c528647fd3478d3794bec035912eadd0ff4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e0a8980c142400240ec080a0112104f61545aba9..c823afcedf883c98d023332e35483b75b90de8ae 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index bfb8140bbdaeb83fdec0aa8705195a972d178aef..35b5e2bfd466a18588f29866619f7aca4746236a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7ccd22cdc1f34aa49a9cf598fcb65887f0082097..2578529795cdf37addeb45f2fefb96248d267d2e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c5218e982be48946fcd88c58ce88e36321479653..7d033e2a980d02fbfb82269ea1b57dd9355d66c9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 11a5f1abc1d98baa95fcb59cfcc877271dd9f609..2cef2d953d321d7d180f220c8bba1d41114223b8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0e10091cc5dbda542c11ac87a53ea6c6a2cc1656..a6dd76cd1371077c18de9190746970f1aabb4eb8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 473b8d5fdb522577e67ca1522c110e505369d356..7c629559cc162fa9a15332a6b17c7ec9f063f526 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 70ef99e7f2546039b731852240721c7283cf2dac..b1bda49ddf60bb78087f34099f3d042314cd2d0d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 20e5008fb9219791e70dfe1c84b5dd00c7e841e8..82230b967de04ad6c2decadd2d689e37ced1cdcf 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6c3e75d024761e6c1b20a2648bc50c9ddf22bebe..92f2e7aa076dc7e8d39a81c5b8c5aca42148dfac 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 656c6e20dd07c49b57a5db5fc196e5cde929cb7d..fb554878c74b20109e26e7cf84b7cd8102e7d4d4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5ddc70900f07f3b5b5c7a9d2f947b4eef6e63533..11ddb19489848a0b100b1ec35f63291c610853f7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 87d0cad063443f2db300154ee889ac8680e71994..aff5b8b6a6e14537774a83cb0f10cdbead22be31 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index acc5d6799c45614cf347d85919b1d358d379ae72..fc2eb2a984351593a3fde9caaad30598d8f6e4cb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8a361f2d09a3630047f419cba68b4ed289294613..861b37710eb3b3118ca92bdcb128dd1c01c9b651 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6f21ed5272a5a4cd9e6e617bccbe825c8035f8cf..fbb9bf330b65ecdf4285cb9c2a4372d0dae9cbb4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a783467e7c10fc17aa52cba9c20df0b6983afd19..56501588d56a436a7023ae00f9b4f16cfb27aee6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a353ce27e0dce503b0d893e1e0c5b521a3f1226c..3d76ea110a761f39a3da311f8e6b66264e0197b3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 60d535c3f491e9ba2bd145ce2202a19066bf3f9e..458f99fd483bcf5798a0c4019bb4504e9a9b54c5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 567b73df21ad0f20439a443887cf969a54a4da38..b1c67670a8610e8d2a211240157edf3c1124b231 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 35b62102c690435bab8ccd0031145addb352dd0c..c3c0da6485cabd1187b6984c22e9b0d6198ae4db 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0afea13fa17c03363a07dcc2260b67fe4158e973..a23f33f9c322d4e5127a5144312b7351d6e51f7f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cae4a09d72dce3ac5bdd95179dae2b38b9f73a3b..692f02c1a1a779f7ed1a0450b209f3af4cba0447 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index df300b9ff3df52883941a713ee2e6475bb8dbdcf..daccf104ec93f61a2556ee2256cda400ca0951cf 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -317,9 +317,10 @@ typedef struct ldapcontrol {
 #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3"  /* (&) (|) */
 #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
 #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
-#define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.4.1.4203.666.8.2"
 
 #ifdef LDAP_DEVEL
+/* LDAP Experimental (works in progress) Features */
+#define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.4.1.4203.666.8.2"
 #define LDAP_FEATURE_SUBORDINATE_SCOPE \
        "1.3.6.1.4.1.4203.666.8.1" /* "children" */
 #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
@@ -446,10 +447,8 @@ typedef struct ldapcontrol {
 #define LDAP_SCOPE_ONE                 LDAP_SCOPE_ONELEVEL
 #define LDAP_SCOPE_SUBTREE             ((ber_int_t) 0x0002)
 #define LDAP_SCOPE_SUB                 LDAP_SCOPE_SUBTREE
-#ifdef LDAP_DEVEL
 #define LDAP_SCOPE_SUBORDINATE ((ber_int_t) 0x0003) /* OpenLDAP extension */
 #define LDAP_SCOPE_CHILDREN            LDAP_SCOPE_SUBORDINATE
-#endif
 
 /* substring filter component types */
 #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U)     /* context specific */
index 8993bb13894bb22ca7a52642b7bc12af96863c6f..fcc7ecf782d79eb9722709278eda9c8886895dad 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 039d75dd2b78c4faf76a119455f1c40fd3432dc2..97ffa05f0e4e099a5deb9a2c5dea51eec7c0d459 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c70520720787c2a2ae0bff7bb463c85bb7ae6b84..440417f7c4201b57be39945d91b30da89abd4c87 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c3cd87d7992e1816372e2f428d8132d0c6b2fba8..fc3e3fc36141a82f1c1442fbbe237be9df1056b4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fb893da861c561eed9dcae81795f6eb5475c74dc..385fef52f64dae40f1fce5d7c1a5874e73b9b48e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9863f2218ba656c6b6ac300f622b0bd83eeb0fce..eb902986207323636fc6f96d1c2845702eba9295 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e95d8b3ae56bb85aff60edff25ce3e4256e054dc..bfed33a794bd527a86e66a0ea8d4798e2aa67bf5 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ef8cb983a82a8c4b7f243f8660ff9cf18c4a1b7c..a10bbd4c1b9945a92bbc162ab65472ddb6a285dd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  * 
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 75f9cd8a048f92df223b97a88f82d6b56f8ebf88..a9b2515757c7012bbad8650da24d8d19f80ddd1f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 572ce17261520ad82bba8bac223ec49f804f433e..2e4a895f93362860a04d7daa7794236093c382de 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ee0cf47bea2abc55d57a9085e426cc761f08cfcb..d23c1d2535b2bea66a7d8859512e5e6ca32a5871 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fe7045605f9f2ff2a1fa11e785cb35b34f86209c..ca51973687f575073c8b9fe4b2c176e024b67714 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 772767ef9bd4a5a841ace498c7adb5f9766f953c..362ba763b9bc319c2a4d84dae010c47203ada320 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0dc1a30b851fb9d773f1251629b032e7e5738c19..88c062217ea8bd58af52dfa6f330f7e2030fbbb0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,13 @@ ldif_parse_line LDAP_P((
        char **value,
        ber_len_t *vlen ));
 
+LDAP_LDIF_F( int )
+ldif_parse_line2 LDAP_P((
+       char *line,
+       struct berval *type,
+       struct berval *value,
+       int *freeval ));
+
 LDAP_LDIF_F( int )
 ldif_fetch_url LDAP_P((
        LDAP_CONST char *line,
index eae6df2433cc90ebefc7fd52903a623918b4c18b..ea2450c4a1264df3ed446301e06a235dff0b63af 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7313c9b73bfdfef98b9eb3f085e44271928f32f8..070404372ee3c93e0c7603a3be2f501a78eacf14 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 464878133f20869705d0954a4776cfa0785c9766..560318982315f6a3dca94a8c669622e491dfa625 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7889e40af587b19d5305e1f7cf7fbb524a6717e7..fe408afaca00060004b58721ab54286046f11116 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3d2db5ee301184ff6dbee575280e0cde13d6b715..5da1bec3870cdf74bbeeea48d8ae23d3168525e8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5fcf4a0ac58ce4b05eeadb13e1038a4e3b662667..1d34fd68867da46c3414eb97013a6695f0235d72 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b283b1642859af82ce6d6f68a84345b5e67f34af..b17ae11d0a7e23e4741fcd69b39433847a21f64a 100644 (file)
@@ -1,7 +1,7 @@
 /* include/portable.h.in.  Generated automatically from configure.in by autoheader.  */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation
+ * Copyright 1998-2005 The OpenLDAP Foundation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5c0c396ada4a224e37375546d58cb5ede1cd154f..ccf359c297ee09c33e6c4e586a506b850e8a428c 100644 (file)
@@ -2,7 +2,7 @@
  */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 656baaf41901fccda377e42e518fd054cb8a15da..f8cc9f2150eaacc926bdda77d3acf5d1f269cf05 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002,2003 IBM Corporation.
  * All rights reserved.
  *
index 4922183f0de13e49a4c69fc5d838248f80f33b0c..72e75ae356014cac64a0d8a68a3d29622cd24c43 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 923e8dd7113c90300ceced3f1b4f51a1eaaa3b1b..acb7461bb0c46e948f5ed773b142edd11fdfc280 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 41272b45228c203e9b6a1b530513224edb8dc085..b2485b7417935c502597a55de6a1f68b2f375a01 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 673624f29bef09f6a6f0c14e641feb22a2f48e3e..64b0e75798146722d4bff21144285c9f4ddec8dc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 46fcae994a0efe8019c32b62cb028abfdb9b5ada..bb465c07a576dcb850200896f5af8dba8579e8f6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cfd515fb3bfac27f5e4034872064ed1e67682b94..de6f947145baef3575e5b8fac6ceba184a233631 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6fcaa8fa3bdedc38a4acd05049127f427d75fbab..04ba7cabc65b8dd87cc01ada0946cab6cd1576c3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 41d81412342add04b58f479f14d3b4f1c355c5ac..521357d0482857d4c93d6c1ad90d804a17364652 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 44b51f29d1617c7e8c208b0a8f8847dce1f5d559..30ffac3a1e1e1c1dbd9001a43bc5b4353091624b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3731a24a467eb07cff02468a2df80f37e00744f2..758faa23fcf41ac37ccb8d452b7c2717fddf8c62 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index be0815f1947e075a48f52cba39a146a100f41eea..6e53a04c3d671025efa6df652acbbb6f74f8c5df 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 14cf29b795cbb16ebfd693559af6494457019a05..f5f7ce9b166a6078c236985a56e0d6772896348e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 76a914e429cbe98e7f0841e41cc9be911d726706..31335404052b7e82c041dedabb6cbb04172cf197 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 18b5bac87621dda49941a61dd3050361d63e3639..ea96e2d6ce745a4ab13fb1a5e5ec9ef996675591 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 14d81f027fd5b5e4c5b16897be82c6fd2d9c2c87..3ea89ee7799de444e224df00d974ab3a955599f5 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3faa94e9f0b42152fd4e65081750b4be327f1d41..11a44c265c22bd0f2566b745ae9ae25c401f3bcd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index dff8a8314645b8bda2ac17105bd4573d001f35ee..390f3e4416e7edca7b91462c487d0316ccd3e01e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 684d9afd084b055a977b83104bc352a9ae876bcc..cf33e95c6b8b0f0db359dbf0e0e38bf3a59291d6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4995b6bffc8a95a69705d781d1073e230f472115..42e47dab10932face859129860f0aeb60ecdf5a8 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 468753ec1970707838eb072638f348a8852c6d04..27b47b5f57afd591a11fefabcdfdf852f9f07cd3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2da6567cbeec4eb7a978c1a24a32729ac7d0f36e..35b0cb6ed1a77134af61b214ab1a127efb3fdb0a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8787dfc2563b6fe94e1ceadb506531f921c5ead3..4edeb28aee1bc856a726872c670d6f475be7f999 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8f6ac418fa029fbcdc4d2aeff7c99e901dc82773..6f463c93197d71d0777da2ad77f2c2a1de7ee68d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index a2e4a6583035188e200f11e29f91b9ab3ade0294..7a2f46aeb6840c4245475561590359d88d7492d0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 21af93145d6900c98a694ade1ac4e616770fe95e..40272b319a2a8c40a3e2ab2b56a0e9a76fe9894d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index eb9c40b52862a32f78d9782cd5de2af5a39f3d0b..2df55766549a9a27b68fc05261fbfdebfd67f058 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index dadf96060a84d4ada4e8df36e79685b8bfc16968..70249ad1b03ddeda10dfbbf13586455a519aafc1 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c9b6c722fe29debe8917fbf0aff3f41945f32870..7e9d73662fa69b66d83adf68892938bf8d1dec92 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c21101a35063528815da6e521dcc5f89bd61d89b..416f439ad6cc2bba5f0307519ce3758c1b1b284d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cac083f71ec270425684f69f18994f772af7ec88..16e768cb534e7f4ac9cec5f0e1fd27e5242dd88a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1bf7eb64269c0d2071f204d3ea7ddcc6e96c025f..a5d13d9fe9c8797216d78173790e447c10b718cd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a3696c20284597ed436f350a85094bb4b615d9ab..9e0abe37ee48c44b8da5074f292034b8a1c8e738 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c6ac44b9b024ab426a8aa3ecf317c8b47a53a0fa..befab53b3bb9d0b1d9c1d6f333ab9b438a14b725 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 47bcba7e09949a75d886726880be4055786e6499..2aded658223947582168ae766936c913c1a973aa 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ed0474ac757fbba68935bc97c53dfa6b470152f3..90dd25425aceb2ac4795a423dc002a43df69bebe 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d9ec7ba7027775947200fa054ff47d18871ba66f..d23ce6d4ecca08473acb7f80b074e99da3e3dfa8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7b2df874d1e02cf3799a200acab2c89f6c322d7e..ea9f29e0824ba7dc941ba1afd92c1cc54add6214 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8a71876f94d927428cafc4c64a3637ec27826a78..b5aae2a53a0220fc485f747fa2fc7441713de832 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 72acabbe66bd958089db643d6baff124876c64f9..ca45d8247fe110e373c212773a6d4cb68acfe3ed 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -438,10 +438,9 @@ ldap_dn_normalize( LDAP_CONST char *dnin,
  * as "\=", but it is treated as a regular char, i.e. it can also 
  * appear as '='.
  *
- * As such, we currently choose to allow reading unescaped '=',
- * but we always produce escaped '\3D'; this may change in the
- * future, if compatibility issues do not arise */
-#ifdef LDAP_DEVEL
+ * As such, in 2.2 we used to allow reading unescaped '=',
+ * but we always produced escaped '\3D'; this changes 
+ * since 2.3, if compatibility issues do not arise */
 #define LDAP_DN_NE(c) \
        ( LDAP_DN_RDN_SEP_V2(c) || LDAP_DN_AVA_SEP(c) \
          || LDAP_DN_QUOTES(c) \
@@ -451,17 +450,7 @@ ldap_dn_normalize( LDAP_CONST char *dnin,
          || LDAP_DN_AVA_EQUALS(c) \
          || LDAP_DN_ASCII_SPACE(c) || LDAP_DN_OCTOTHORPE(c) )
 #define LDAP_DN_SHOULDESCAPE(c)                ( LDAP_DN_AVA_EQUALS(c) )
-#else /* ! LDAP_DEVEL */
-#define LDAP_DN_NE(c) \
-       ( LDAP_DN_RDN_SEP_V2(c) || LDAP_DN_AVA_SEP(c) \
-         || LDAP_DN_AVA_EQUALS(c) || LDAP_DN_QUOTES(c) \
-         || (c) == '<' || (c) == '>' )
-#define LDAP_DN_MAYESCAPE(c) \
-       ( LDAP_DN_ESCAPE(c) || LDAP_DN_NE(c) \
-         || LDAP_DN_ASCII_SPACE(c) || LDAP_DN_OCTOTHORPE(c) )
-#define LDAP_DN_SHOULDESCAPE(c)                ( 0 )
-#endif /* ! LDAP_DEVEL */
-       
+
 #define LDAP_DN_NEEDESCAPE(c) \
        ( LDAP_DN_ESCAPE(c) || LDAP_DN_NE(c) )
 #define LDAP_DN_NEEDESCAPE_LEAD(c)     LDAP_DN_MAYESCAPE(c)
index 87421849c9912848855d4d386a63116f71e2427e..47766fc8e019becbf9c30f26e9ff62e3920a0f89 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c5a0d7cbb5fe3040722c72a45f2e39238fc88803..cc09462816f3596867e6ceb666e215a0f251260d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 25cb4b9686e69e1e1b09e7f76b1ad3b4131b5f6a..24a655d7ff2187489e3f0acc2eb336356c1ea19f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0a1f7e48d3bcb3064228fc22ccede06809821719..8ecda40f41e026ce9d92153a51176825f1e5755d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ead746250688a4a38844d3eeb4bd325efe7afd67..4f963cbd01a7009e33084d35cf5f49ad43105da6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4058d8ab7cefbc9e99f3401548abf4620243f9a4..593f1060cd0107cb64606284f6d5316b143a4c65 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b54b619591f899172a2c0e4a34339ca05a8cf905..3875d2ccd616175bc15f581582f9c73537cc32c0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8e0323fafc0d889bb19ff493ebe9247d3042822c..d7ca681bed89c94cb9d41afe5287ac11918144c8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 302ffa703f042febb8338eba9e7780fbbb2c7280..0f46ec39454c57cc39d4b8845a596d5fb400bcd4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4bdd4948da3807151270634ee41bc7821122c3f2..e5243c869d934c866be0b76b4908efabe5ad2f24 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ed2df964e723c379fe3fa4c964f96025611233a3..8cf53cd3f9485d30185f74719c761add7f037984 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5aead880196bdafaebb38db65ad951ba15f30644..dad33ed000da23d5e89af2845a49c8756c719e14 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Lars Uffmann.
  * All rights reserved.
  *
index ff2b93ed5182e1fb279195658938d08750e486e9..275c08e778ea084644196b54f3116b39eee868f5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d6e2dd1d2f981d92a6893f63f3b63f10573d5cb3..eef1510be5b8bcd043eed5dc82f0bcd506ac2f50 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e77a7c47ded48eff94d51081eef39dee22163d93..a54181dca658820ee40f545e738f278a2bb31993 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Hewlett-Packard Company.
  * Portions Copyright 2004 Howard Chu, Symas Corp.
  * All rights reserved.
index 4c703aca19b460ed43ca8baadcef8e09716ddec4..aaa3845448bc02b3c430f44fcfab3ce106d6a6de 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 84b6d69716178a568709b65d796d088fa4df9789..5267ce5ae8580b5c65c8139e73c40ccec74ffec0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5d2c6b59daba19eed118e99e0f28459a3e236134..ed9c6f3e22fdafbe4bb01bb4f6adc7a5c6cd9526 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 527302d97b1fb87d2aa9a9925f2ce9803a7de5ba..c695755b632d2a6274134a097a3638060aa38577 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3b6dccf68df3ab442f4bd29639fb980ff8be0578..91f30e6f675badbd8d04306ad605f7cc7d13c4b8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2b6bcb343a672cac8fab030e2e50ae0c33606ef7..1639072436c602001b477e0b4cb842190cafae8f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4639b4510520425b654205641064776db02f9b1d..6c76569b79149d0db1fd9ddb37a7e935e692a669 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a901888ffd918b6591916237b2515470183a9300..a2d97a3e01755b8ee780b5929c7ad56de38a15a9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 20e1a6bc0727ca4d828f1766520bb2777dd8ed39..7e2b52d5b21fcbb39c5f6dbc77f8cfe2da1e1263 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 910bf0459dac8a64043e40a793005e5718964cec..bf80ba7d651513adce7e56e7cbbdff6b1d5a1f30 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8f6906a8ac70b87a09f482651e7213199e28b4a8..60c228914b2a669ae19bd6da76322fa701474a09 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e6cca3382da72a29c9a3a2eea0201c173f4ecbfc..71069a5400348486c8d5cc6c67329c1bbfdb4f30 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 67b74616365262de22ec6bb9873d28e9c9b023a7..8cc5eb480fbe87602cef17a65985fc31f76aced0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0672ce5952401c6b9f0dfd61385cf78ae9a6bf7a..8a12a89545ca96ccf130e51965f888549ea960dd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3f40599d8b1545f476c5c19913fa0caed5f450e9..414f05d535b67feac995b7390c9caaf3be2b480b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5c77d19754c03826eaa4b3796fa1a1fcc7a48dc4..0158edf5b479ca9444e6a39a69145c030dcd0e5f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index be266ffe024e8de73eda5e9e224e0e1859b941ff..0f6379f443ebe538b22ce05f352af0594cc3aec0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
 #include <stdio.h>
 
 #include <ac/stdlib.h>
+#include <ac/ctype.h>
 
 #include <ac/socket.h>
 #include <ac/string.h>
@@ -286,192 +287,485 @@ static int str2scope( const char *p )
        return( -1 );
 }
 
-static int hex_escape( char *buf, const char *s, int list )
+static const char      hex[] = "0123456789ABCDEF";
+
+#define URLESC_NONE    0x0000U
+#define URLESC_COMMA   0x0001U
+#define URLESC_SLASH   0x0002U
+
+static int
+hex_escape_len( const char *s, unsigned list )
 {
-       int i;
-       int pos;
-       static const char hex[] = "0123456789ABCDEF";
+       int     len;
 
-       if( s == NULL ) return 0;
+       if ( s == NULL ) {
+               return 0;
+       }
 
-       for( pos=0,i=0; s[i]; i++ ) {
-               int escape = 0;
-               switch( s[i] ) {
-                       case ',':
-                               escape = list;
-                               break;
-                       case '%':
-                       case '?':
-                       case ' ':
-                       case '<':
-                       case '>':
-                       case '"':
-                       case '#':
-                       case '{':
-                       case '}':
-                       case '|':
-                       case '\\':
-                       case '^':
-                       case '~':
-                       case '`':
-                       case '[':
-                       case ']':
+       for ( len = 0; s[0]; s++ ) {
+               switch ( s[0] ) {
+               /* RFC 2396: reserved */
+               case '?':
+                       len += 3;
+                       break;
+
+               case ',':
+                       if ( list & URLESC_COMMA ) {
+                               len += 3;
+                       } else {
+                               len++;
+                       }
+                       break;
+
+               case '/':
+                       if ( list & URLESC_SLASH ) {
+                               len += 3;
+                       } else {
+                               len++;
+                       }
+                       break;
+
+               case ';':
+               case ':':
+               case '@':
+               case '&':
+               case '=':
+               case '+':
+               case '$':
+
+               /* RFC 2396: unreserved mark */
+               case '-':
+               case '_':
+               case '.':
+               case '!':
+               case '~':
+               case '*':
+               case '\'':
+               case '(':
+               case ')':
+                       len++;
+                       break;
+                       
+               /* RFC 2396: unreserved alphanum */
+               default:
+                       if ( !isalnum( s[0] ) ) {
+                               len += 3;
+                       } else {
+                               len++;
+                       }
+                       break;
+               }
+       }
+
+       return len;
+}
+
+static int
+hex_escape( char *buf, int len, const char *s, unsigned list )
+{
+       int     i;
+       int     pos;
+
+       if ( s == NULL ) {
+               return 0;
+       }
+
+       for ( pos = 0, i = 0; s[i] && pos < len; i++ ) {
+               int     escape = 0;
+
+               switch ( s[i] ) {
+               /* RFC 2396: reserved */
+               case '?':
+                       escape = 1;
+                       break;
+
+               case ',':
+                       if ( list & URLESC_COMMA ) {
                                escape = 1;
-                               break;
+                       }
+                       break;
 
-                       default:
-                               escape = s[i] < 0x20 || 0x1f >= s[i];
+               case '/':
+                       if ( list & URLESC_SLASH ) {
+                               escape = 1;
+                       }
+                       break;
+
+               case ';':
+               case ':':
+               case '@':
+               case '&':
+               case '=':
+               case '+':
+               case '$':
+
+               /* RFC 2396: unreserved mark */
+               case '-':
+               case '_':
+               case '.':
+               case '!':
+               case '~':
+               case '*':
+               case '\'':
+               case '(':
+               case ')':
+                       break;
+                       
+               /* RFC 2396: unreserved alphanum */
+               default:
+                       if ( !isalnum( s[i] ) ) {
+                               escape = 1;
+                       }
+                       break;
                }
 
-               if( escape ) {
+               if ( escape ) {
                        buf[pos++] = '%';
                        buf[pos++] = hex[ (s[i] >> 4) & 0x0f ];
                        buf[pos++] = hex[ s[i] & 0x0f ];
+
                } else {
                        buf[pos++] = s[i];
                }
        }
 
        buf[pos] = '\0';
+
        return pos;
 }
 
-static int hex_escape_args( char *buf, char **s )
+static int
+hex_escape_len_list( char **s, unsigned flags )
 {
-       int pos;
-       int i;
+       int     len;
+       int     i;
+
+       if ( s == NULL ) {
+               return 0;
+       }
+
+       len = 0;
+       for ( i = 0; s[i] != NULL; i++ ) {
+               if ( len ) {
+                       len++;
+               }
+               len += hex_escape_len( s[i], flags );
+       }
+
+       return len;
+}
+
+static int
+hex_escape_list( char *buf, int len, char **s, unsigned flags )
+{
+       int     pos;
+       int     i;
 
-       if( s == NULL ) return 0;
+       if ( s == NULL ) {
+               return 0;
+       }
 
        pos = 0;
-       for( i=0; s[i] != NULL; i++ ) {
-               if( pos ) {
+       for ( i = 0; s[i] != NULL; i++ ) {
+               int     curlen;
+
+               if ( pos ) {
                        buf[pos++] = ',';
+                       len--;
                }
-               pos += hex_escape( &buf[pos], s[i], 1 );
+               curlen = hex_escape( &buf[pos], len, s[i], flags );
+               len -= curlen;
+               pos += curlen;
        }
 
        return pos;
 }
 
-char * ldap_url_desc2str( LDAPURLDesc *u )
+static int
+desc2str_len( LDAPURLDesc *u )
 {
-       char *s;
-       int i;
-       int sep = 0;
-       int sofar;
-       size_t len = 0;
-       if( u == NULL ) return NULL;
-
-       if( u->lud_exts ) {
-               for( i=0; u->lud_exts[i]; i++ ) {
-                       len += strlen( u->lud_exts[i] ) + 1;
+       int     sep = 0;
+       int     len = 0;
+
+       if ( u == NULL ) {
+               return -1;
+       }
+
+       if ( u->lud_exts ) {
+               len += hex_escape_len_list( u->lud_exts, URLESC_COMMA );
+               if ( !sep ) {
+                       sep = 5;
                }
-               if( !sep ) sep = 5;
        }
 
-       if( u->lud_filter ) {
-               len += strlen( u->lud_filter );
-               if( !sep ) sep = 4;
+       if ( u->lud_filter ) {
+               len +=  hex_escape_len( u->lud_filter, URLESC_NONE );
+               if ( !sep ) {
+                       sep = 4;
+               }
        }
-       if ( len ) len++; /* ? */
 
-       switch( u->lud_scope ) {
+       switch ( u->lud_scope ) {
+       case LDAP_SCOPE_BASE:
+       case LDAP_SCOPE_ONELEVEL:
+       case LDAP_SCOPE_SUBTREE:
+#ifdef LDAP_FEATURE_SUBORDINATE_SCOPE
+       case LDAP_SCOPE_SUBORDINATE:
+#endif
+               switch ( u->lud_scope ) {
                case LDAP_SCOPE_BASE:
+                       len += STRLENOF( "base" );
+                       break;
+
                case LDAP_SCOPE_ONELEVEL:
+                       len += STRLENOF( "one" );
+                       break;
+
                case LDAP_SCOPE_SUBTREE:
+                       len += STRLENOF( "sub" );
+                       break;
+
 #ifdef LDAP_FEATURE_SUBORDINATE_SCOPE
                case LDAP_SCOPE_SUBORDINATE:
-#endif
-                       len += sizeof("subordinate");
-                       if( !sep ) sep = 3;
+                       len += STRLENOF( "subordinate" );
                        break;
 
-               default:
-                       if ( len ) len++; /* ? */
+#endif
+               }
+
+               if ( !sep ) {
+                       sep = 3;
+               }
+               break;
+
+       default:
+               break;
        }
 
-       if( u->lud_attrs ) {
-               for( i=0; u->lud_attrs[i]; i++ ) {
-                       len += strlen( u->lud_attrs[i] ) + 1;
+       if ( u->lud_attrs ) {
+               len +=  hex_escape_len_list( u->lud_attrs, URLESC_NONE );
+               if ( !sep ) {
+                       sep = 2;
                }
-               if( !sep ) sep = 2;
-       } else if ( len ) len++; /* ? */
+       }
 
-       if( u->lud_dn ) {
-               len += strlen( u->lud_dn ) + 1;
-               if( !sep ) sep = 1;
+       if ( u->lud_dn && u->lud_dn[0] ) {
+               len += hex_escape_len( u->lud_dn, URLESC_NONE );
+               if ( !sep ) {
+                       sep = 1;
+               }
        };
 
-       if( u->lud_port ) {
-               len += sizeof(":65535") - 1;
+       len += sep;
+
+       if ( u->lud_port ) {
+               char    buf[] = ":65535";
+
+               len += snprintf( buf, sizeof( buf ), ":%d", u->lud_port );
+               if ( u->lud_host && u->lud_host[0] ) {
+                       len += strlen( u->lud_host );
+               }
+
+       } else {
+               if ( u->lud_host && u->lud_host[0] ) {
+                       len += hex_escape_len( u->lud_host, URLESC_SLASH );
+               }
+       }
+
+       len += strlen( u->lud_scheme ) + STRLENOF( "://" );
+
+       return len;
+}
+
+int
+desc2str( LDAPURLDesc *u, char *s, int len )
+{
+       int     i;
+       int     sep = 0;
+       int     sofar = 0;
+       int     gotscope = 0;
+
+       if ( u == NULL ) {
+               return -1;
        }
 
-       if( u->lud_host ) {
-               len+=strlen( u->lud_host );
+       if ( s == NULL ) {
+               return -1;
        }
 
-       len += strlen( u->lud_scheme ) + sizeof("://");
+       switch ( u->lud_scope ) {
+       case LDAP_SCOPE_BASE:
+       case LDAP_SCOPE_ONELEVEL:
+       case LDAP_SCOPE_SUBTREE:
+#ifdef LDAP_FEATURE_SUBORDINATE_SCOPE
+       case LDAP_SCOPE_SUBORDINATE:
+#endif
+               gotscope = 1;
+               break;
+       }
 
-       /* allocate enough to hex escape everything -- overkill */
-       s = LDAP_MALLOC( 3*len );
+       if ( u->lud_exts ) {
+               sep = 5;
+       } else if ( u->lud_filter ) {
+               sep = 4;
+       } else if ( gotscope ) {
+               sep = 3;
+       } else if ( u->lud_attrs ) {
+               sep = 2;
+       } else if ( u->lud_dn && u->lud_dn[0] ) {
+               sep = 1;
+       }
 
-       if( s == NULL ) return NULL;
+       if ( u->lud_port ) {
+               len -= sprintf( s, "%s://%s:%d%n", u->lud_scheme,
+                               u->lud_host ? u->lud_host : "",
+                               u->lud_port, &sofar );
 
-       if( u->lud_port ) {
-               sprintf( s,     "%s://%s:%d%n", u->lud_scheme,
-                       u->lud_host, u->lud_port, &sofar );
        } else {
-               sprintf( s,     "%s://%s%n", u->lud_scheme,
-                       u->lud_host, &sofar );
+               len -= sprintf( s, "%s://%n", u->lud_scheme, &sofar );
+               if ( u->lud_host && u->lud_host[0] ) {
+                       i = hex_escape( &s[sofar], len, u->lud_host, URLESC_SLASH );
+                       sofar += i;
+                       len -= i;
+               }
        }
-       
-       if( sep < 1 ) goto done;
+
+       assert( len >= 0 );
+
+       if ( sep < 1 ) {
+               goto done;
+       }
+
        s[sofar++] = '/';
+       len--;
+
+       assert( len >= 0 );
 
-       sofar += hex_escape( &s[sofar], u->lud_dn, 0 );
+       if ( u->lud_dn && u->lud_dn[0] ) {
+               i = hex_escape( &s[sofar], len, u->lud_dn, URLESC_NONE );
+               sofar += i;
+               len -= i;
 
-       if( sep < 2 ) goto done;
+               assert( len >= 0 );
+       }
+
+       if ( sep < 2 ) {
+               goto done;
+       }
        s[sofar++] = '?';
+       len--;
 
-       sofar += hex_escape_args( &s[sofar], u->lud_attrs );
+       assert( len >= 0 );
 
-       if( sep < 3 ) goto done;
+       i = hex_escape_list( &s[sofar], len, u->lud_attrs, URLESC_NONE );
+       sofar += i;
+       len -= i;
+
+       assert( len >= 0 );
+
+       if ( sep < 3 ) {
+               goto done;
+       }
        s[sofar++] = '?';
+       len--;
 
-       switch( u->lud_scope ) {
+       assert( len >= 0 );
+
+       switch ( u->lud_scope ) {
        case LDAP_SCOPE_BASE:
                strcpy( &s[sofar], "base" );
-               sofar += sizeof("base") - 1;
+               sofar += STRLENOF("base");
+               len -= STRLENOF("base");
                break;
+
        case LDAP_SCOPE_ONELEVEL:
                strcpy( &s[sofar], "one" );
-               sofar += sizeof("one") - 1;
+               sofar += STRLENOF("one");
+               len -= STRLENOF("one");
                break;
+
        case LDAP_SCOPE_SUBTREE:
                strcpy( &s[sofar], "sub" );
-               sofar += sizeof("sub") - 1;
+               sofar += STRLENOF("sub");
+               len -= STRLENOF("sub");
                break;
+
 #ifdef LDAP_FEATURE_SUBORDINATE_SCOPE
        case LDAP_SCOPE_SUBORDINATE:
                strcpy( &s[sofar], "children" );
-               sofar += sizeof("children") - 1;
+               sofar += STRLENOF("children");
+               len -= STRLENOF("children");
                break;
 #endif
        }
 
-       if( sep < 4 ) goto done;
+       assert( len >= 0 );
+
+       if ( sep < 4 ) {
+               goto done;
+       }
        s[sofar++] = '?';
+       len--;
+
+       assert( len >= 0 );
 
-       sofar += hex_escape( &s[sofar], u->lud_filter, 0 );
+       i = hex_escape( &s[sofar], len, u->lud_filter, URLESC_NONE );
+       sofar += i;
+       len -= i;
 
-       if( sep < 5 ) goto done;
+       assert( len >= 0 );
+
+       if ( sep < 5 ) {
+               goto done;
+       }
        s[sofar++] = '?';
+       len--;
+
+       assert( len >= 0 );
+
+       i = hex_escape_list( &s[sofar], len, u->lud_exts, URLESC_COMMA );
+       sofar += i;
+       len -= i;
 
-       sofar += hex_escape_args( &s[sofar], u->lud_exts );
+       assert( len >= 0 );
 
 done:
-       s[sofar] = '\0';
+       if ( len < 0 ) {
+               return -1;
+       }
+
+       return sofar;
+}
+
+char *
+ldap_url_desc2str( LDAPURLDesc *u )
+{
+       int     len;
+       char    *s;
+
+       if ( u == NULL ) {
+               return NULL;
+       }
+
+       len = desc2str_len( u );
+       if ( len < 0 ) {
+               return NULL;
+       }
+       
+       /* allocate enough to hex escape everything -- overkill */
+       s = LDAP_MALLOC( len + 1 );
+
+       if ( s == NULL ) {
+               return NULL;
+       }
+
+       if ( desc2str( u, s, len ) != len ) {
+               LDAP_FREE( s );
+               return NULL;
+       }
+
+       s[len] = '\0';
+
        return s;
 }
 
@@ -1099,50 +1393,50 @@ char *
 ldap_url_list2urls(
        LDAPURLDesc *ludlist )
 {
-       LDAPURLDesc *ludp;
-       int size;
-       char *s, *p, buf[32];   /* big enough to hold a long decimal # (overkill) */
+       LDAPURLDesc     *ludp;
+       int             size, sofar;
+       char            *s;
 
-       if (ludlist == NULL)
+       if ( ludlist == NULL ) {
                return NULL;
+       }
 
        /* figure out how big the string is */
-       size = 1;       /* nul-term */
-       for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
-               size += strlen(ludp->lud_scheme);
-               if ( ludp->lud_host ) {
-                       size += strlen(ludp->lud_host);
-                       /* will add [ ] below */
-                       if (strchr(ludp->lud_host, ':'))
-                               size += 2;
-               }
-               size += sizeof(":/// ");
-
-               if (ludp->lud_port != 0) {
-                       size += sprintf(buf, ":%d", ludp->lud_port);
+       for ( size = 0, ludp = ludlist; ludp != NULL; ludp = ludp->lud_next ) {
+               int     len = desc2str_len( ludp );
+               if ( len < 0 ) {
+                       return NULL;
                }
+               size += len + 1;
        }
+       
+       s = LDAP_MALLOC( size );
 
-       s = LDAP_MALLOC(size);
-       if (s == NULL) {
+       if ( s == NULL ) {
                return NULL;
        }
 
-       p = s;
-       for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
-               p += sprintf(p, "%s://", ludp->lud_scheme);
-               if ( ludp->lud_host ) {
-                       p += sprintf(p, strchr(ludp->lud_host, ':') 
-                                       ? "[%s]" : "%s", ludp->lud_host);
+       for ( sofar = 0, ludp = ludlist; ludp != NULL; ludp = ludp->lud_next ) {
+               int     len;
+
+               len = desc2str( ludp, &s[sofar], size );
+               
+               if ( len < 0 ) {
+                       LDAP_FREE( s );
+                       return NULL;
                }
-               if (ludp->lud_port != 0)
-                       p += sprintf(p, ":%d", ludp->lud_port);
-               *p++ = '/';
-               *p++ = ' ';
+
+               sofar += len;
+               size -= len;
+
+               s[sofar++] = ' ';
+               size--;
+
+               assert( size >= 0 );
        }
-       if (p != s)
-               p--;    /* nuke that extra space */
-       *p = 0;
+
+       s[sofar - 1] = '\0';
+
        return s;
 }
 
@@ -1191,6 +1485,30 @@ ldap_free_urldesc( LDAPURLDesc *ludp )
        LDAP_FREE( ludp );
 }
 
+static int
+ldap_int_is_hexpair( char *s )
+{
+       int     i;
+
+       for ( i = 0; i < 2; i++ ) {
+               if ( s[i] >= '0' && s[i] <= '9' ) {
+                       continue;
+               }
+
+               if ( s[i] >= 'A' && s[i] <= 'F' ) {
+                       continue;
+               }
+
+               if ( s[i] >= 'a' && s[i] <= 'f' ) {
+                       continue;
+               }
+
+               return 0;
+       }
+       
+       return 1;       
+}
+       
 static int
 ldap_int_unhex( int c )
 {
@@ -1206,10 +1524,20 @@ ldap_pvt_hex_unescape( char *s )
         * Remove URL hex escapes from s... done in place.  The basic concept for
         * this routine is borrowed from the WWW library HTUnEscape() routine.
         */
-       char    *p;
+       char    *p,
+               *save_s = s;
 
        for ( p = s; *s != '\0'; ++s ) {
                if ( *s == '%' ) {
+                       /*
+                        * FIXME: what if '%' is followed
+                        * by non-hexpair chars?
+                        */
+                       if ( !ldap_int_is_hexpair( s + 1 ) ) {
+                               p = save_s;
+                               break;
+                       }
+
                        if ( *++s == '\0' ) {
                                break;
                        }
@@ -1226,4 +1554,3 @@ ldap_pvt_hex_unescape( char *s )
        *p = '\0';
 }
 
-
index 146e906781315030a01a3a0e5edc8bd01123cd88..df477822f7f3dc1a361f3cb4fa17b6a8e933c48e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1d0fd2ab9462bff4aacb5b03422ceae2936508eb..9ed7dc7d021449b958e718f36165c5cd28525137 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e4975e0ff452aba2344eefdf2d165b39b5bcb3ee..407d13628d4c7f6266ce45a95dbf408ecb64620d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998 A. Hartgers.
  * All rights reserved.
  *
index d4c51453fd6100b3fe08588ec4d7e7963a168393..25241165e849e47a17b274ae4ca95d8f9eeeee6c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9f1a3b3b5cd6c5344eaa13267647315a9444a05a..498af5a180f869004197ce3b7c8b1b99c45444a9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1eb198cdfbb8398d9a8b84caad8ca07266006247..2e63c77fb1897b7ca3e2d2b119b20974e91f7f65 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index b0613c07514a0f1bca8442007bdd3fe9d40790e8..5acf713e115c0f2aeb147581a717189c4ea7600c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 35df5c7b4ab6fd20387188b0c0bcc693a074eac7..85ae1aa2db99e810132c88174e5e37ad83bdcac1 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
index cefb617717a6f12302f3e43dc41babae17798fc7..d81e0101b54d4320ada9655566be442cf7211606 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 38969deba2c0525f43d0b2b2d3246c8c5763cf04..6d66e391365605157287bec7befd0fa8aa12ff72 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5919ee6d49098f902b8c27aec39fb605fb94dd38..24a7a8d4ae431b5dd029ccbdf37fb450acdb058f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 95d07f9db67df05a91b0c5a0a34196762feba1d5..176cd55215349e34ffaa0c1903748dc1c7e6f3a4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9a5d3de8c9307693b59342aa3d4ede84c36d5e12..82dee868c78e9c9f12c00256b840a196cf7bc7ba 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index debe7c61d738b7a03319b98cfb1b6d610d2d07b0..0f9bae6f198717f5c469230588a44b8955da3fc8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e86b63cae642e95d2c0114c61602324e16e6d977..e609365447c5c0f4f36cffc2bc868dcad893d967 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a605feb24f750b310761b06f0a96abb6b0ea1c82..d19400b971abe62ab6bbc430b9640c0c0c884848 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9422b4310ec86d7dd9639260c198708d96c608dd..da18a36e551cd92f6d716f201856f4a190f5ae4f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5769861222b1038ad458e9ec3820fdc815e786c2..48c95a54ced3f7d05fa8d74a1cb17aa7ef13f4e0 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 7edff44ee01482c05d58e884abb8c60e4dea05cc..e846cfd0de1db94c833979e30147659bc471c1db 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 415fd3c2eedeb476eaf89be74fc124e979b117db..abe2d4d5aa51c0ce0b8e3141c132e1408f656e63 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8c2690be2584373b439a33b008c5abe055638b8a..91f5bc9186bca87ba3f6b78caac59d82736173d4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9cfac41f553e2ac8b92010e54704ec6566f905f6..1780eca07b5777f7c7bacf0febee8bb7abb68b9d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 97b501df12723a4a19b980a859730d42b5903079..6f1091dc0844a29b3a9191b921c0cc98bfb88181 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0d820977efbb81ae3968e6947f32f9de7cbc3072..6d947737164344690ce63af5c131966f9186b72b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e8b9686e94fd084eff487cf7a45fd9740b004386..8582545c8eb4e46618354f79ec47e9072607873f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9254b2a94976bde9493bf807ab4557c834780741..b4c2b6eafccefba29ca78936dd26ba92236f884f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8067d1e859bf7c6a26d566a081a27892ff84a165..1d67c021db17c475c0675ade297715f4d38d53b4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 64a716a85e927ffb54b26b82512e67be6a9b42cc..72ea83ad70a4b2d8bb79d82e3762a3f6d1671b1b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 62ae154e5cc21090f4db0f85f646fc8bde32253b..4d1fa3e2b6562c22ad08cdc7dd95ac19434e3131 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f52da0560b09a2322e8e9d963b68c64d12138bd3..06c7cf15a7da39779cd400a589ba9d592165e971 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6fb3b0a479a8709b2c7880d554be87909704191e..545b85eaa314ab93a631e0fedb2dda576f0213d5 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ## 
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 37f1da5bd163c6584661113c9c42a1a106f1e886..ad2918d5576f90daaf2522c0f11f01fa435c6057 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 442bb8e0b8e4f0ecab03e94e47834379258f3940..661ac0cd0f1538e9a9fec59fba672b2a3cd4d3af 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1995 IBM Corporation.
  * All rights reserved.
index d27805d1aef678547e539003722c869bfc8db7c7..b6a43ddb3340dd478ad9cb09a10a3c9666be6a7f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 058059a5c0abcb4b33fa2360b24abd6ca79f1d03..b7d8bc7b33405c06b127f9d0c6fa0e1244f92d77 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index dd599f74a4c7edcab0f8142cdaaa82b62721732e..02dbdefca88337d404a9770695cf09afabde2867 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index fb9e5ddaf0c3fa270d82f7d1cf2724faa5c0c75b..0a0ef8524924698f85be7ace6b9139cdf3d793ee 100644 (file)
@@ -3,7 +3,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index fbc24429910d4101dc71bd0f613d7ff760469f8d..6aaac84d768eba4138ebe194312018503934893e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 7f1a4b72a649baf974c37508ff4bc5b5b4e5db52..2745da308cd5c7e40d22ee35273ecbc0e5efe0c0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index a568fa9182fc6ad9bc9cb63729d6e13ace38759c..1bbe4aa9fbdfc94b6755c723f4ad712113120d03 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e6740640ddcadd002b3c2bda358fc9945d0de646..c2b8b2b7a9c12e470a8a7459a8bf7eb2b1a7469b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 1da25587af16b0a53659c02a4ba415f72d5c09c1..79f11406113fe8ce6984b445bfff5a368542d071 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -81,7 +81,14 @@ static const unsigned char b642nib[0x80] = {
  * ldif_parse_line - takes a line of the form "type:[:] value" and splits it
  * into components "type" and "value".  if a double colon separates type from
  * value, then value is encoded in base 64, and parse_line un-decodes it
- * (in place) before returning.
+ * (in place) before returning. The type and value are stored in malloc'd
+ * memory which must be freed by the caller.
+ *
+ * ldif_parse_line2 - operates in-place on input buffer, returning type
+ * in-place. Will return value in-place if possible, (must malloc for
+ * fetched URLs). If freeval is NULL, all return data will be malloc'd
+ * and the input line will be unmodified. Otherwise freeval is set to
+ * True if the value was malloc'd.
  */
 
 int
@@ -91,47 +98,66 @@ ldif_parse_line(
     char       **valuep,
     ber_len_t *vlenp
 )
+{
+       struct berval type, value;
+       int rc = ldif_parse_line2( (char *)line, &type, &value, NULL );
+
+       *typep = type.bv_val;
+       *valuep = value.bv_val;
+       *vlenp = value.bv_len;
+       return rc;
+}
+
+int
+ldif_parse_line2(
+    char       *line,
+       struct berval *type,
+       struct berval *value,
+       int             *freeval
+)
 {
        char    *s, *p, *d; 
        char    nib;
        int     b64, url;
-       char    *freeme, *type, *value;
-       ber_len_t vlen;
 
-       *typep = NULL;
-       *valuep = NULL;
-       *vlenp = 0;
+       BER_BVZERO( type );
+       BER_BVZERO( value );
 
        /* skip any leading space */
        while ( isspace( (unsigned char) *line ) ) {
                line++;
        }
 
-       freeme = ber_strdup( line );
+       if ( freeval ) {
+               *freeval = 0;
+       } else {
+               line = ber_strdup( line );
 
-       if( freeme == NULL ) {
-               ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
-                       _("ldif_parse_line: line malloc failed\n"));
-               return( -1 );
+               if( line == NULL ) {
+                       ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
+                               _("ldif_parse_line: line malloc failed\n"));
+                       return( -1 );
+               }
        }
 
-       type = freeme;
+       type->bv_val = line;
 
-       s = strchr( type, ':' );
+       s = strchr( type->bv_val, ':' );
 
        if ( s == NULL ) {
                ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
                        _("ldif_parse_line: missing ':' after %s\n"),
                        type );
-               ber_memfree( freeme );
+               if ( !freeval ) ber_memfree( line );
                return( -1 );
        }
 
        /* trim any space between type and : */
-       for ( p = &s[-1]; p > type && isspace( * (unsigned char *) p ); p-- ) {
+       for ( p = &s[-1]; p > type->bv_val && isspace( * (unsigned char *) p ); p-- ) {
                *p = '\0';
        }
        *s++ = '\0';
+       type->bv_len = s - type->bv_val - 1;
 
        url = 0;
        b64 = 0;
@@ -165,13 +191,13 @@ ldif_parse_line(
                        /* no value is present, error out */
                        ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
                                _("ldif_parse_line: %s missing base64 value\n"), type );
-                       ber_memfree( freeme );
+                       if ( !freeval ) ber_memfree( line );
                        return( -1 );
                }
 
-               byte = value = s;
+               byte = value->bv_val = s;
 
-               for ( p = s, vlen = 0; p < d; p += 4, vlen += 3 ) {
+               for ( p = s, value->bv_len = 0; p < d; p += 4, value->bv_len += 3 ) {
                        int i;
                        for ( i = 0; i < 4; i++ ) {
                                if ( p[i] != '=' && (p[i] & 0x80 ||
@@ -180,7 +206,7 @@ ldif_parse_line(
                                                _("ldif_parse_line: %s: invalid base64 encoding"
                                                " char (%c) 0x%x\n"),
                                            type, p[i], p[i] );
-                                       ber_memfree( freeme );
+                                       if ( !freeval ) ber_memfree( line );
                                        return( -1 );
                                }
                        }
@@ -194,7 +220,7 @@ ldif_parse_line(
                        byte[1] = (nib & RIGHT4) << 4;
                        /* third digit */
                        if ( p[2] == '=' ) {
-                               vlen += 1;
+                               value->bv_len += 1;
                                break;
                        }
                        nib = b642nib[ p[2] & 0x7f ];
@@ -202,7 +228,7 @@ ldif_parse_line(
                        byte[2] = (nib & RIGHT2) << 6;
                        /* fourth digit */
                        if ( p[3] == '=' ) {
-                               vlen += 2;
+                               value->bv_len += 2;
                                break;
                        }
                        nib = b642nib[ p[3] & 0x7f ];
@@ -210,59 +236,58 @@ ldif_parse_line(
 
                        byte += 3;
                }
-               s[ vlen ] = '\0';
+               s[ value->bv_len ] = '\0';
 
        } else if ( url ) {
                if ( *s == '\0' ) {
                        /* no value is present, error out */
                        ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
                                _("ldif_parse_line: %s missing URL value\n"), type );
-                       ber_memfree( freeme );
+                       if ( !freeval ) ber_memfree( line );
                        return( -1 );
                }
 
-               if( ldif_fetch_url( s, &value, &vlen ) ) {
+               if( ldif_fetch_url( s, &value->bv_val, &value->bv_len ) ) {
                        ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
                                _("ldif_parse_line: %s: URL \"%s\" fetch failed\n"),
                                type, s );
-                       ber_memfree( freeme );
+                       if ( !freeval ) ber_memfree( line );
                        return( -1 );
                }
+               if ( freeval ) *freeval = 1;
 
        } else {
-               value = s;
-               vlen = (int) (d - s);
+               value->bv_val = s;
+               value->bv_len = (int) (d - s);
        }
 
-       type = ber_strdup( type );
+       if ( !freeval ) {
+               struct berval bv = *type;
 
-       if( type == NULL ) {
-               ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
-                       _("ldif_parse_line: type malloc failed\n"));
-               if( url ) ber_memfree( value );
-               ber_memfree( freeme );
-               return( -1 );
-       }
+               ber_dupbv( type, &bv );
 
-       if( !url ) {
-               p = ber_memalloc( vlen + 1 );
-               if( p == NULL ) {
+               if( BER_BVISNULL( type )) {
                        ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
-                               _("ldif_parse_line: value malloc failed\n"));
-                       ber_memfree( type );
-                       ber_memfree( freeme );
+                               _("ldif_parse_line: type malloc failed\n"));
+                       if( url ) ber_memfree( value->bv_val );
+                       ber_memfree( line );
                        return( -1 );
                }
-               AC_MEMCPY( p, value, vlen );
-               p[vlen] = '\0';
-               value = p;
-       }
 
-       ber_memfree( freeme );
+               if( !url ) {
+                       bv = *value;
+                       ber_dupbv( value, &bv );
+                       if( BER_BVISNULL( value )) {
+                               ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
+                                       _("ldif_parse_line: value malloc failed\n"));
+                               ber_memfree( type->bv_val );
+                               ber_memfree( line );
+                               return( -1 );
+                       }
+               }
 
-       *typep = type;
-       *valuep = value;
-       *vlenp = vlen;
+               ber_memfree( line );
+       }
 
        return( 0 );
 }
index c932deed7fc84d5bf04cb8087034f7873377849c..0ff7514639623c1a2c6670ddee1ecf9bc64c43c1 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0a98fc7c2d08c97fd699eff572e67974d4efd028..27ff2a2122d7e4523b5fd0525b6d0f8cef47ba6c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 592f953b98312b334f227290031f68d384ed84a0..2dcd8c1b035cdd4a8733289f817c9369f401ae39 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e049c74a6577248e9f98b4c41f2dbdd3142f3c27..f1cac7d0763d611968bf3b73c3e517b4faee8e9a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4bbf56ad78eff472e106c9c4c7511931e2abece9..a4b314d0383b8041e8a5a9bebb00f974859a0174 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f16b49a2bc3f9d79f9b8717f175e3b8646458728..8fe4673aadd184725eff458e7c6f0a4a8d791f42 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -132,6 +132,7 @@ static LUTIL_PASSWD_HASH_FUNC hash_clear;
 #endif
 
 static struct pw_slist *pw_schemes;
+static int pw_inited;
 
 static const struct pw_scheme pw_schemes_default[] =
 {
@@ -173,6 +174,8 @@ int lutil_passwd_add(
 {
        struct pw_slist *ptr;
 
+       if (!pw_inited) lutil_passwd_init();
+
        ptr = ber_memalloc( sizeof( struct pw_slist ));
        if (!ptr) return -1;
        ptr->next = pw_schemes;
@@ -187,6 +190,8 @@ void lutil_passwd_init()
 {
        struct pw_scheme *s;
 
+       pw_inited = 1;
+
        for( s=(struct pw_scheme *)pw_schemes_default; s->name.bv_val; s++) {
                if ( lutil_passwd_add( &s->name, s->chk_fn, s->hash_fn ) ) break;
        }
@@ -207,7 +212,7 @@ static const struct pw_scheme *get_scheme(
 {
        struct pw_slist *pws;
 
-       if (!pw_schemes) lutil_passwd_init();
+       if (!pw_inited) lutil_passwd_init();
 
        for( pws=pw_schemes; pws; pws=pws->next ) {
                if( strcasecmp(scheme, pws->s.name.bv_val ) == 0 ) {
@@ -287,7 +292,7 @@ lutil_passwd(
                return -1;
        }
 
-       if (!pw_schemes) lutil_passwd_init();
+       if (!pw_inited) lutil_passwd_init();
 
        for( pws=pw_schemes; pws; pws=pws->next ) {
                if( pws->s.chk_fn ) {
index 5e1276af4cd16d2e117cd19ed30dcdb482009ca5..4677d57886ea1bf4f0772c91cf5f068f0a82358b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 277d0bd0d10891f97a5bbd1abe3c5ad7ccbfde40..f22ffa5c6ea7d7a5bf67a80e2f8f4289359b9eb0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c20d060a2ba2a4677a8a5912f9f2f54fdb5b1983..110a466e064437809c33f59fbbccfd2acb914d09 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 803c38b6117b848e1690c520a6cfa820c5c86efa..123266a61ae05cfe3265c2d95bb2a205abed9507 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8037a6d5f187faf6033b89205809657008373e1e..743d1e0db693a56f1a3b97801b8ed5e714cb506d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index dac642a61cc92226ad3e8281b56a0ae51d034f8c..a794206daab9cc4d45f9d678b5447efbc7700f54 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e354063505de476696cc991b6e497a9fa05dca64..b32a015571b465504565242c3439230f46082cee 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1ede99f41e0341434807d35830fd8a0959d063d7..692d2bebe6c9b311435c7c6dc751a7d9b2e72a15 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f64660219ef902cc05ab44a51d376e486b6c2179..f300f425746627717ef3ad28bf24e620d478f10b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 65bfe467181fb0c2ed115f4d3863f0d60b1516d4..7c322490685361153080e2578ea36ad2a3aa3ad9 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 982ca5907eb467aecabbe2e8d22d1eb9e861177d..b6c729406eb5aa0df8b99b5b8ce116ff36ca8a2c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index aad9f0a0df65f00e6d62e473852047b076fb8062..5f4c19d6f28a9c4ccc5a7529e51ed7c942ec819e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -296,7 +296,7 @@ rewrite_context_apply(
 
                                if ( do_continue ) {
                                        if ( rule->lr_next == NULL ) {
-                                               res = ( s == string ? strdup( s ) : s );
+                                               res = s;
                                        }
                                        goto rc_continue;
                                }
@@ -321,7 +321,7 @@ rewrite_context_apply(
                        if ( res != NULL ) {
                                struct rewrite_action *action;
                                
-                               if (s != string ) {
+                               if ( s != string && s != res ) {
                                        free( s );
                                }
                                s = res;
@@ -381,7 +381,7 @@ rewrite_context_apply(
                         * result back to the string
                         */
                        } else if ( rule->lr_next == NULL ) {
-                               res = ( s == string ? strdup( s ) : s );
+                               res = s;
                        }
                        
                        break;
index c11bc399a5e0fce8ea29afff64d27351843866fc..53f759975dfa4bb51d1f5261f24047f4027f4dc7 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -261,7 +261,9 @@ rewrite_session(
        case REWRITE_REGEXEC_UNWILLING:
        case REWRITE_REGEXEC_ERR:
                if ( *result != NULL ) {
-                       free( *result );
+                       if ( *result != string ) {
+                               free( *result );
+                       }
                        *result = NULL;
                }
 
index fff721820a44b626d422cdb8f791a6c023575809..186fd601dc5f62e723edb73f6184ccac0b7f1eba 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d8ba01cdb23b70dfc0edb554b76f0a86d96536f6..fe06eb14ac1156b65d57cd6a4c2ac98327564221 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 29a63b7fba5f75318a75f5bcb33f35977448fa4c..d41bab60d43eff1e1505b7a71631370d0e537a89 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1ef1af192280fbb1e88710f3da8bc91f9d6d4e69..77441c9df05be754db1e36ab3ce9a6b7f1115bcb 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 798620ad41ba4a6687a1195b7d8ab4aa03896ce3..ac616e16d040b5815b0b76b95f21903cfe2fb20d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f8d7e2bdac14056d6b6c6dd772622d5808a76a84..7735ecc200a5b0706cf40ff86364032237b6fbe0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1964deba52004c567056f58ab35efb09da72163d..b040ee7fd2b2a755c18801bbaf265d44d6a1e1ce 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,7 @@ int ldap_debug;
 int ldap_syslog;
 int ldap_syslog_level;
 
-char *
+static void
 apply( 
                FILE *fin, 
                const char *rewriteContext,
@@ -58,11 +58,12 @@ apply(
 
        rewrite_session_init( info, cookie );
 
-       string = strdup( arg );
+       string = (char *)arg;
        for ( sep = strchr( rewriteContext, ',' );
                        rewriteContext != NULL;
                        rewriteContext = sep,
-                       sep ? sep = strchr( rewriteContext, ',' ) : NULL ) {
+                       sep ? sep = strchr( rewriteContext, ',' ) : NULL )
+       {
                char    *errmsg = "";
 
                if ( sep != NULL ) {
@@ -105,17 +106,19 @@ apply(
                if ( result == NULL ) {
                        break;
                }
-               free( string );
+               if ( string != arg && string != result ) {
+                       free( string );
+               }
                string = result;
        }
 
-       free( string );
+       if ( result && result != arg ) {
+               free( result );
+       }
 
        rewrite_session_delete( info, cookie );
 
        rewrite_info_delete( &info );
-
-       return result;
 }
 
 int
index ceeec1580c248d3f67a55dfe92a168020a3d2914..6a9e43c372ef6b4e92a8a132c8d61db5ed4d2dc3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -419,9 +419,8 @@ recurse:;
        
        op->lo_num_passes++;
        if ( regexec( &rule->lr_regex, string, nmatch, match, 0 ) != 0 ) {
-               if ( *result == NULL && strcnt > 0 ) {
+               if ( *result == NULL && string != arg ) {
                        free( string );
-                       string = NULL;
                }
 
                /*
@@ -435,7 +434,7 @@ recurse:;
 
        *result = val.bv_val;
        val.bv_val = NULL;
-       if ( strcnt > 0 ) {
+       if ( string != arg ) {
                free( string );
                string = NULL;
        }
index 4d05dd1fcea4ffa36d2a705b6df3750bea707647..18e21a5fe142ec6b5c196ad141f4f1cde5cd3b02 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3fb2ae24766ad0199e140d7169481a20eacb59a2..5ab89cd7f646706cecf6d3f1de43d4b2921fd7af 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9507242aee1875233988afded39320b64920b81b..9138b175c99be0c84b389b45bede82aaa00cf48e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index abffec09171c1df11db767df5f61192ea2e90e80..0448c8ee964a5bf3c901e72b6358df8cb3ac03fc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d5d9292a434901e1347e021fa813723851861b8a..f8616acfb2b10e6c10b9279d8c86fa3ebc7a3622 100644 (file)
@@ -1,6 +1,6 @@
 # servers Makefile.in for OpenLDAP
 # $OpenLDAP$
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 8f6dd9be40e8bf2e4e8b7d8607ca869ce2ca0daa..8c5ed6218942206882390965d91b8830b923001f 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,7 @@ SRCS  = main.c globals.c config.c daemon.c \
                oidm.c starttls.c index.c sets.c referral.c root_dse.c \
                sasl.c module.c mra.c mods.c sl_malloc.c zn_malloc.c limits.c \
                operational.c matchedValues.c cancel.c syncrepl.c \
-               backover.c ctxcsn.c ldapsync.c sessionlog.c frontend.c \
+               backover.c ctxcsn.c ldapsync.c frontend.c \
                slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
                slappasswd.c slaptest.c slapauth.c slapacl.c component.c \
                $(@PLAT@_SRCS)
@@ -52,12 +52,12 @@ OBJS        = main.o globals.o config.o daemon.o \
                oidm.o starttls.o index.o sets.o referral.o root_dse.o \
                sasl.o module.o mra.o mods.o sl_malloc.o zn_malloc.o limits.o \
                operational.o matchedValues.o cancel.o syncrepl.o \
-               backover.o ctxcsn.o ldapsync.o sessionlog.o frontend.o \
+               backover.o ctxcsn.o ldapsync.o frontend.o \
                slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
                slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
                $(@PLAT@_OBJS)
 
-LDAP_INCDIR= ../../include -I$(srcdir)/slapi -I.
+LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
 LDAP_LIBDIR= ../../libraries
 
 SLAP_DIR=
@@ -70,7 +70,7 @@ SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
 XDEFS = $(MODULES_CPPFLAGS)
 XLDFLAGS = $(MODULES_LDFLAGS)
 
-XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L) liboverlays.a
+XLIBS = $(SLAPD_STATIC_DEPENDS) liboverlays.a $(SLAPD_L)
 XXLIBS = $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
 
@@ -80,10 +80,10 @@ BUILD_SRV = @BUILD_SLAPD@
 all-local-srv: all-cffiles
 
 NT_SLAPD_DEPENDS = slapd.exp
-NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
+NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) backends.o version.o
 
-UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
-UNIX_SLAPD_OBJECTS = $(OBJS) version.o
+UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) backends.o version.o $(SLAPD_L)
+UNIX_SLAPD_OBJECTS = $(OBJS) backends.o version.o
 
 SLAPD_DEPENDS = liboverlays.a $(@PLAT@_SLAPD_DEPENDS)
 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
@@ -262,8 +262,8 @@ slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
                $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done
 
 
-sslapd: version.o
-       $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
+sslapd: version.o backends.o
+       $(LTLINK) -static -o $@ $(OBJS) version.o backends.o $(LIBS) $(WRAP_LIBS)
 
 dummy $(SLAPD_DYNAMIC_BACKENDS): slapd
        cd $@; $(MAKE) $(MFLAGS) all
@@ -313,14 +313,14 @@ libbackends.a: .backend
 liboverlays.a: FORCE
        @cd overlays; $(MAKE) $(MFLAGS) all
 
-backend.c: backend.h
-
 version.c: Makefile
        @-$(RM) $@
        $(MKVERSION) -s -n Versionstr slapd > $@
 
 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND) 
 
+backends.o: backends.c $(srcdir)/slap.h
+
 depend-local-srv: FORCE
        @for i in $(SUBDIRS); do \
                if test -d $$i -a -f $$i/Makefile ; then \
@@ -334,6 +334,9 @@ depend-local-srv: FORCE
 clean-local:
        $(RM) *.exp *.def *.base *.a *.objs symdummy.c
 
+veryclean-local:
+       $(RM) backends.c
+
 clean-local-srv: FORCE
        @for i in $(SUBDIRS); do \
                if test -d $$i -a -f $$i/Makefile ; then \
index 78fa52904e60cd4eb39e6362cb4eef9b17874d58..6020e8a22881ea518fc9d26339842c9a0dadc0c3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d7cb98d2aee0ebf847f00a000a07f6ba9ef56737..623f0b18a26b1fb76aedf1a97a34896e27d4a404 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -253,7 +253,7 @@ access_allowed_mask(
                    "<= root access granted\n",
                        0, 0, 0 );
                if ( maskp ) {
-                       mask = ACL_LVL_WRITE;
+                       mask = ACL_LVL_MANAGE;
                }
 
                goto done;
@@ -541,8 +541,11 @@ acl_get(
                                Debug( LDAP_DEBUG_ACL,
                                        "acl_get: valpat %s\n",
                                        a->acl_attrval.bv_val, 0, 0 );
-                               if (regexec(&a->acl_attrval_re, val->bv_val, 0, NULL, 0))
+                               if ( regexec( &a->acl_attrval_re, val->bv_val, 0, NULL, 0 ) )
+                               {
                                        continue;
+                               }
+
                        } else {
                                int match = 0;
                                const char *text;
@@ -1741,7 +1744,9 @@ acl_check_modlist(
                Debug( LDAP_DEBUG_ACL,
                        "=> access_allowed: backend default %s access %s to \"%s\"\n",
                        access2str( ACL_WRITE ),
-                       op->o_bd->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val );
+                       op->o_bd->be_dfltaccess >= ACL_WRITE
+                               ? "granted" : "denied",
+                       op->o_dn.bv_val );
                ret = (op->o_bd->be_dfltaccess >= ACL_WRITE);
                goto done;
        }
@@ -2111,8 +2116,9 @@ aci_match_set (
        int             rc = 0;
        AciSetCookie    cookie;
 
-       if (setref == 0) {
+       if ( setref == 0 ) {
                ber_dupbv_x( &set, subj, op->o_tmpmemctx );
+
        } else {
                struct berval           subjdn, ndn = BER_BVNULL;
                struct berval           setat;
@@ -2122,7 +2128,7 @@ aci_match_set (
 
                /* format of string is "entry/setAttrName" */
                if ( aci_get_part( subj, 0, '/', &subjdn ) < 0 ) {
-                       return(0);
+                       return 0;
                }
 
                if ( aci_get_part( subj, 1, '/', &setat ) < 0 ) {
index 17f0274d561b0e601bc19e9011d384038f0a3579..d682ef7c5178f7eba1e59a673e373eb59fa93caa 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,10 +62,7 @@ static void          print_acl(Backend *be, AccessControl *a);
 static void            print_access(Access *b);
 #endif
 
-#ifdef LDAP_DEVEL
-static int
-check_scope( BackendDB *be, AccessControl *a );
-#endif /* LDAP_DEVEL */
+static int             check_scope( BackendDB *be, AccessControl *a );
 
 #ifdef SLAP_DYNACL
 static int
@@ -160,7 +157,6 @@ regtest(const char *fname, int lineno, char *pat) {
        regfree(&re);
 }
 
-#ifdef LDAP_DEVEL
 /*
  * Experimental
  *
@@ -181,6 +177,10 @@ check_scope( BackendDB *be, AccessControl *a )
 
        dn = be->be_nsuffix[0];
 
+       if ( BER_BVISEMPTY( &dn ) ) {
+               return ACL_SCOPE_OK;
+       }
+
        if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
                        a->acl_dn_style != ACL_STYLE_REGEX )
        {
@@ -295,7 +295,6 @@ regex_done:;
 
        return ACL_SCOPE_UNKNOWN;
 }
-#endif /* LDAP_DEVEL */
 
 void
 parse_acl(
@@ -303,8 +302,7 @@ parse_acl(
     const char *fname,
     int                lineno,
     int                argc,
-    char       **argv
-)
+    char       **argv )
 {
        int             i;
        char            *left, *right, *style, *next;
@@ -506,7 +504,7 @@ parse_acl(
                                                                        a->acl_attrs[0].an_desc->ad_cname.bv_val );
                                                                a->acl_attrval_style = ACL_STYLE_BASE;
                                                        }
-                                                       
+
                                                } else {
                                                        fprintf( stderr, 
                                                                "%s: line %d: unknown val.<style> \"%s\" "
@@ -1653,7 +1651,6 @@ parse_acl(
                }
 
                if ( be != NULL ) {
-#ifdef LDAP_DEVEL
                        if ( !BER_BVISNULL( &be->be_nsuffix[ 1 ] ) ) {
                                fprintf( stderr, "%s: line %d: warning: "
                                        "scope checking only applies to single-valued "
@@ -1693,7 +1690,6 @@ parse_acl(
                        default:
                                break;
                        }
-#endif /* LDAP_DEVEL */
                        acl_append( &be->be_acl, a );
 
                } else {
@@ -1720,6 +1716,9 @@ accessmask2str( slap_mask_t mask, char *buf )
                if ( ACL_LVL_IS_NONE(mask) ) {
                        ptr = lutil_strcopy( ptr, "none" );
 
+               } else if ( ACL_LVL_IS_DISCLOSE(mask) ) {
+                       ptr = lutil_strcopy( ptr, "disclose" );
+
                } else if ( ACL_LVL_IS_AUTH(mask) ) {
                        ptr = lutil_strcopy( ptr, "auth" );
 
@@ -1734,6 +1733,10 @@ accessmask2str( slap_mask_t mask, char *buf )
 
                } else if ( ACL_LVL_IS_WRITE(mask) ) {
                        ptr = lutil_strcopy( ptr, "write" );
+
+               } else if ( ACL_LVL_IS_MANAGE(mask) ) {
+                       ptr = lutil_strcopy( ptr, "manage" );
+
                } else {
                        ptr = lutil_strcopy( ptr, "unknown" );
                }
@@ -1751,6 +1754,11 @@ accessmask2str( slap_mask_t mask, char *buf )
                *ptr++ = '=';
        }
 
+       if ( ACL_PRIV_ISSET(mask, ACL_PRIV_MANAGE) ) {
+               none = 0;
+               *ptr++ = 'm';
+       } 
+
        if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) {
                none = 0;
                *ptr++ = 'w';
@@ -1776,6 +1784,11 @@ accessmask2str( slap_mask_t mask, char *buf )
                *ptr++ = 'x';
        } 
 
+       if ( ACL_PRIV_ISSET(mask, ACL_PRIV_DISCLOSE) ) {
+               none = 0;
+               *ptr++ = 'd';
+       } 
+
        if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) {
                none = 0;
                *ptr++ = 'n';
@@ -1817,7 +1830,10 @@ str2accessmask( const char *str )
                }
 
                for( i=1; str[i] != '\0'; i++ ) {
-                       if( TOLOWER((unsigned char) str[i]) == 'w' ) {
+                       if( TOLOWER((unsigned char) str[i]) == 'm' ) {
+                               ACL_PRIV_SET(mask, ACL_PRIV_MANAGE);
+
+                       } else if( TOLOWER((unsigned char) str[i]) == 'w' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
 
                        } else if( TOLOWER((unsigned char) str[i]) == 'r' ) {
@@ -1832,6 +1848,9 @@ str2accessmask( const char *str )
                        } else if( TOLOWER((unsigned char) str[i]) == 'x' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
 
+                       } else if( TOLOWER((unsigned char) str[i]) == 'd' ) {
+                               ACL_PRIV_SET(mask, ACL_PRIV_DISCLOSE);
+
                        } else if( str[i] != '0' ) {
                                ACL_INVALIDATE(mask);
                                return mask;
@@ -1844,6 +1863,9 @@ str2accessmask( const char *str )
        if ( strcasecmp( str, "none" ) == 0 ) {
                ACL_LVL_ASSIGN_NONE(mask);
 
+       } else if ( strcasecmp( str, "disclose" ) == 0 ) {
+               ACL_LVL_ASSIGN_DISCLOSE(mask);
+
        } else if ( strcasecmp( str, "auth" ) == 0 ) {
                ACL_LVL_ASSIGN_AUTH(mask);
 
@@ -1859,6 +1881,9 @@ str2accessmask( const char *str )
        } else if ( strcasecmp( str, "write" ) == 0 ) {
                ACL_LVL_ASSIGN_WRITE(mask);
 
+       } else if ( strcasecmp( str, "manage" ) == 0 ) {
+               ACL_LVL_ASSIGN_MANAGE(mask);
+
        } else {
                ACL_INVALIDATE( mask );
        }
@@ -1873,7 +1898,7 @@ acl_usage( void )
                "<access clause> ::= access to <what> "
                                "[ by <who> <access> [ <control> ] ]+ \n"
                "<what> ::= * | [dn[.<dnstyle>]=<DN>] [filter=<filter>] [attrs=<attrlist>]\n"
-               "<attrlist> ::= <attr> [val[.<style>]=<value>] | <attr> , <attrlist>\n"
+               "<attrlist> ::= <attr> [val[.<attrstyle>]=<value>] | <attr> , <attrlist>\n"
                "<attr> ::= <attrname> | entry | children\n",
                "<who> ::= [ * | anonymous | users | self | dn[.<dnstyle>]=<DN> ]\n"
                        "\t[dnattr=<attrname>]\n"
@@ -1884,14 +1909,16 @@ acl_usage( void )
                        "\t[aci=<attrname>]\n"
 #endif
                        "\t[ssf=<n>] [transport_ssf=<n>] [tls_ssf=<n>] [sasl_ssf=<n>]\n",
+               "<style> ::= exact | regex | base(Object)\n"
                "<dnstyle> ::= base(Object) | one(level) | sub(tree) | children | "
                        "exact | regex\n"
-               "<style> ::= exact | regex | base(Object)\n"
+               "<attrstyle> ::= exact | regex | base(Object) | one(level) | "
+                       "sub(tree) | children\n"
                "<peernamestyle> ::= exact | regex | ip | path\n"
                "<domainstyle> ::= exact | regex | base(Object) | sub(tree)\n"
                "<access> ::= [self]{<level>|<priv>}\n"
-               "<level> ::= none | auth | compare | search | read | write\n"
-               "<priv> ::= {=|+|-}{w|r|s|c|x|0}+\n"
+               "<level> ::= none|disclose|auth|compare|search|read|write|manage\n"
+               "<priv> ::= {=|+|-}{0|d|x|c|s|r|w|m}+\n"
                "<control> ::= [ stop | continue | break ]\n"
        );
        exit( EXIT_FAILURE );
@@ -2053,6 +2080,9 @@ access2str( slap_access_t access )
        if ( access == ACL_NONE ) {
                return "none";
 
+       } else if ( access == ACL_DISCLOSE ) {
+               return "disclose";
+
        } else if ( access == ACL_AUTH ) {
                return "auth";
 
@@ -2067,6 +2097,10 @@ access2str( slap_access_t access )
 
        } else if ( access == ACL_WRITE ) {
                return "write";
+
+       } else if ( access == ACL_MANAGE ) {
+               return "manage";
+
        }
 
        return "unknown";
@@ -2078,6 +2112,9 @@ str2access( const char *str )
        if ( strcasecmp( str, "none" ) == 0 ) {
                return ACL_NONE;
 
+       } else if ( strcasecmp( str, "disclose" ) == 0 ) {
+               return ACL_DISCLOSE;
+
        } else if ( strcasecmp( str, "auth" ) == 0 ) {
                return ACL_AUTH;
 
@@ -2092,6 +2129,9 @@ str2access( const char *str )
 
        } else if ( strcasecmp( str, "write" ) == 0 ) {
                return ACL_WRITE;
+
+       } else if ( strcasecmp( str, "manage" ) == 0 ) {
+               return ACL_MANAGE;
        }
 
        return( ACL_INVALID_ACCESS );
index a05cefe556dcefb2629e3cacfee5fd391e37f340..34f8cb4f20402b88c3e2d66371f6095d902b590f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2945064004b5ad29777b793293a1abb222854d0e..204caa0380237e391c63363ec61d7298468ab519 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -583,6 +583,8 @@ slap_mods2entry(
                tail = &attr->a_next;
        }
 
+       *text = NULL;
+
        return LDAP_SUCCESS;
 }
 
index bc3d12f53e4fdc72771102bd89072d2e68ec8a27..58c40006bd468bfde683978ad7f2e59499618359 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7dce6c6dd034737bee2886135679459c08c52bae..8908a65da90cc9a986a329e442740e9d3b90a8da 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5b8665f67d2bd245ba4f29867b48e1b4ce87e795..14112134cf0fa29c979504a3592c092ac1bab6e1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 16d7d00402e0a08d6e617a7e60d13cdd26107fbf..f439138a523a89bcc42706659835b1ac117fd1eb 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -18,14 +18,14 @@ SRCS = init.c tools.c config.c \
        extended.c referral.c operational.c \
        attr.c index.c key.c dbcache.c filterindex.c \
        dn2entry.c dn2id.c error.c id2entry.c idl.c \
-       nextid.c cache.c trans.c ctxcsn.c
+       nextid.c cache.c trans.c
 
 OBJS = init.lo tools.lo config.lo \
        add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \
        extended.lo referral.lo operational.lo \
        attr.lo index.lo key.lo dbcache.lo filterindex.lo \
        dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo \
-       nextid.lo cache.lo trans.lo ctxcsn.lo
+       nextid.lo cache.lo trans.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index 1463e400315df7c943873a69e600c7784b313746..3a1f6942f44c8194775383d8c783daf4f6582f55 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -367,19 +367,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef BDB_PSEARCH
-       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
-                       &ctxcsn_e, &ctxcsn_added, locker );
-               switch ( rc ) {
-               case BDB_CSN_ABORT :
-                       goto return_results;
-               case BDB_CSN_RETRY :
-                       goto retry;
-               }
-       }
-#endif
-
        /* post-read */
        if( op->o_postread ) {
                if( postread_ctrl == NULL ) {
@@ -421,31 +408,6 @@ retry:     /* transaction retry */
                        suffix_ei = BEI(e);
                }
 
-#ifdef BDB_PSEARCH
-               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                       if ( ctxcsn_added ) {
-                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                       (struct berval *)&slap_ldapsync_cn_bv, locker );
-                       }
-               }
-
-               if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) {
-                       ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-                       assert( BEI(e) );
-                       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                               rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_ADD );
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_add)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                               }
-                       }
-                       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-               }
-#endif
-
                if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
                        rs->sr_text = "txn_commit failed";
                } else {
index 3947aeab7294afed0abd813f9bbf74367d968b27..73c35c86c2078cce61b68f50d253d1dd1aac6828 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 327862790ee9729a17c27b855b811cb8ce67beec..d788665c3c044442d6eb556d4f986f522b306065 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,8 +23,6 @@
 
 LDAP_BEGIN_DECL
 
-#undef BDB_PSEARCH
-
 #define DB_VERSION_FULL ((DB_VERSION_MAJOR << 24) | (DB_VERSION_MINOR << 16) | DB_VERSION_PATCH)
 
 #define BDB_SUBENTRIES 1
@@ -184,11 +182,6 @@ struct bdb_info {
 
        ID                      bi_lastid;
        ldap_pvt_thread_mutex_t bi_lastid_mutex;
-#ifdef BDB_PSEARCH
-       LDAP_LIST_HEAD(pl, slap_op) bi_psearch_list;
-       ldap_pvt_thread_rdwr_t bi_pslist_rwlock;
-       LDAP_LIST_HEAD(se, slap_session_entry) bi_session_list;
-#endif
        int             bi_idl_cache_max_size;
        int             bi_idl_cache_size;
        Avlnode         *bi_idl_tree;
@@ -261,19 +254,19 @@ struct bdb_op_info {
 
 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
 #define BDB_ID2DISK( src, dst )        \
-       do { int i0; ID tmp; char *ptr; \
-               tmp = (src); ptr = (char *)(dst);       \
+       do { int i0; ID tmp; unsigned char *_p; \
+               tmp = (src); _p = (char *)(dst);        \
                for ( i0=sizeof(ID)-1; i0>=0; i0-- ) {  \
-                       ptr[i0] = tmp & 0xff; tmp >>= 8;        \
+                       _p[i0] = tmp & 0xff; tmp >>= 8; \
                } \
        } while(0);
 
 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
 #define BDB_DISK2ID( src, dst ) \
-       do { int i0; ID tmp = 0; unsigned char *ptr;    \
-               ptr = (unsigned char *)(src);   \
+       do { int i0; ID tmp = 0; unsigned char *_p;     \
+               _p = (unsigned char *)(src);    \
                for ( i0=0; i0<sizeof(ID); i0++ ) {     \
-                       tmp <<= 8; tmp |= *ptr++;       \
+                       tmp <<= 8; tmp |= *_p++;        \
                } *(dst) = tmp; \
        } while (0);
 
index 9ebdfe7a86c5a55147f494f589baccff8db7fb4b..69d37564624622c771b70112e81f286fb095037b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -130,25 +130,20 @@ dn2entry_retry:
 
        switch ( op->oq_bind.rb_method ) {
        case LDAP_AUTH_SIMPLE:
-               rs->sr_err = access_allowed( op, e,
-                       password, NULL, ACL_AUTH, NULL );
-               if ( ! rs->sr_err ) {
+               a = attr_find( e->e_attrs, password );
+               if ( a == NULL ) {
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
                        goto done;
                }
 
-               if ( (a = attr_find( e->e_attrs, password )) == NULL ) {
-                       rs->sr_err = LDAP_INVALID_CREDENTIALS;
-                       goto done;
-               }
-
-               if ( slap_passwd_check( op->o_conn,
-                       a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 )
+               if ( slap_passwd_check( op, e, a, &op->oq_bind.rb_cred,
+                                       &rs->sr_text ) != 0 )
                {
+                       /* failure; stop front end from sending result */
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
                        goto done;
                }
-
+                       
                rs->sr_err = 0;
                break;
 
index 1d9f4899bb93ea6c799694d53cf8040bdfa30598..76d6e28c5e056d465694a2a128d24373662829c6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -919,11 +919,12 @@ bdb_cache_add(
        }
        bdb_cache_entryinfo_unlock( eip );
 
-       /* set lru mutex */
-       ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex );
        ++bdb->bi_cache.c_cursize;
        ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock );
 
+       /* set lru mutex */
+       ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex );
+
        /* lru_mutex is unlocked for us */
        bdb_cache_lru_add( bdb, locker, new );
 
index d23cf99f259889e9371c01b27ce23c0782d31ccb..9565a3ab62e2e492e747a955a2c4b21413676fc7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,19 +65,33 @@ dn2entry_retry:
        e = ei->bei_e;
        if ( rs->sr_err == DB_NOTFOUND ) {
                if ( e != NULL ) {
-                       rs->sr_matched = ch_strdup( e->e_dn );
-                       rs->sr_ref = is_entry_referral( e )
-                               ? get_entry_referrals( op, e )
-                               : NULL;
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+                       /* return referral only if "disclose"
+                        * is granted on the object */
+                       if ( ! access_allowed( op, e, slap_schema.si_ad_entry,
+                                               NULL, ACL_DISCLOSE, NULL ) )
+                       {
+                               rs->sr_err = LDAP_NO_SUCH_OBJECT;
+
+                       } else
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+                       {
+                               rs->sr_matched = ch_strdup( e->e_dn );
+                               rs->sr_ref = is_entry_referral( e )
+                                       ? get_entry_referrals( op, e )
+                                       : NULL;
+                               rs->sr_err = LDAP_REFERRAL;
+                       }
+
                        bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
                        e = NULL;
 
                } else {
                        rs->sr_ref = referral_rewrite( default_referral,
                                NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+                       rs->sr_err = rs->sr_ref ? LDAP_REFERRAL : LDAP_NO_SUCH_OBJECT;
                }
 
-               rs->sr_err = LDAP_REFERRAL;
                send_ldap_result( op, rs );
 
                ber_bvarray_free( rs->sr_ref );
@@ -89,14 +103,25 @@ dn2entry_retry:
        }
 
        if (!manageDSAit && is_entry_referral( e ) ) {
-               /* entry is a referral, don't allow add */
-               rs->sr_ref = get_entry_referrals( op, e );
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+               /* return referral only if "disclose"
+                * is granted on the object */
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry,
+                                       NULL, ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+               } else
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+               {
+                       /* entry is a referral, don't allow compare */
+                       rs->sr_ref = get_entry_referrals( op, e );
+                       rs->sr_err = LDAP_REFERRAL;
+                       rs->sr_matched = e->e_name.bv_val;
+               }
 
                Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
                        0, 0 );
 
-               rs->sr_err = LDAP_REFERRAL;
-               rs->sr_matched = e->e_name.bv_val;
                send_ldap_result( op, rs );
 
                ber_bvarray_free( rs->sr_ref );
@@ -112,18 +137,29 @@ dn2entry_retry:
                goto return_results;
        }
 
-       rs->sr_err = access_allowed( op, e, op->oq_compare.rs_ava->aa_desc,
-               &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL );
-       if ( ! rs->sr_err ) {
-               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+       if ( !access_allowed( op, e, op->oq_compare.rs_ava->aa_desc,
+               &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL ) )
+       {
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+               /* return error only if "disclose"
+                * is granted on the object */
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry,
+                                       NULL, ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+               } else
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+               {
+                       rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               }
                goto return_results;
        }
 
        rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
 
-       for(a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc );
+       for ( a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc );
                a != NULL;
-               a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ))
+               a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ) )
        {
                rs->sr_err = LDAP_COMPARE_FALSE;
 
@@ -140,14 +176,18 @@ dn2entry_retry:
 return_results:
        send_ldap_result( op, rs );
 
-       if( rs->sr_err == LDAP_COMPARE_FALSE || rs->sr_err == LDAP_COMPARE_TRUE ) {
+       switch ( rs->sr_err ) {
+       case LDAP_COMPARE_FALSE:
+       case LDAP_COMPARE_TRUE:
                rs->sr_err = LDAP_SUCCESS;
+               break;
        }
 
 done:
        /* free entry */
-       if( e != NULL ) {
-               bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+       if ( e != NULL ) {
+               bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
+                               e, &lock );
        }
 
        LOCK_ID_FREE ( bdb->bi_dbenv, locker );
index 0d51df2d285a076b4bdafa736ae7e2dc484dbc6c..ec70bf0095b73b2f95812578dfed5a65fa9112d2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -194,48 +194,7 @@ bdb_db_config(
                }
                if ( !( slapMode & SLAP_TOOL_MODE ) )
                        bdb->bi_idl_cache_max_size = atoi( argv[1] );
-#ifdef BDB_PSEARCH
-       } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) {
-               int se_id = 0, se_size = 0;
-               struct slap_session_entry *sent;
-               if ( argc < 3 ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
-                               " line\n", fname, lineno, 0 );
-                       return( 1 );
-               }
 
-               se_id = atoi( argv[1] );
-
-               if ( se_id < 0 || se_id > 999 ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "%s: line %d: session log id %d is out of range [0..999]\n",
-                               fname, lineno , se_id );
-                       return( 1 );
-               }
-
-               se_size = atoi( argv[2] );
-               if ( se_size < 0 ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "%s: line %d: session log size %d is negative\n",
-                               fname, lineno , se_size );
-                       return( 1 );
-               }
-
-               LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) {
-                       if ( sent->se_id == se_id ) {
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: session %d already exists\n",
-                                       fname, lineno , se_id );
-                               return( 1 );
-                       }
-               }
-               sent = (struct slap_session_entry *) ch_calloc( 1,
-                                               sizeof( struct slap_session_entry ));
-               sent->se_id = se_id;
-               sent->se_size = se_size;
-               LDAP_LIST_INSERT_HEAD( &bdb->bi_session_list, sent, se_link );
-#endif /* BDB_PSEARCH */
        /* anything else */
        } else {
                return SLAP_CONF_UNKNOWN;
diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c
deleted file mode 100644 (file)
index db57b90..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/* ctxcsn.c -- back-bdb Context CSN Management Routines */
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 2003-2004 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "lutil.h"
-#include "back-bdb.h"
-
-#ifdef BDB_PSEARCH
-int
-bdb_csn_commit(
-       Operation *op,
-       SlapReply *rs,
-       DB_TXN *tid,
-       EntryInfo *ei,
-       EntryInfo **suffix_ei,
-       Entry **ctxcsn_e,
-       int *ctxcsn_added,
-       u_int32_t locker
-)
-{
-       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
-       EntryInfo               *ctxcsn_ei = NULL;
-       DB_LOCK                 ctxcsn_lock;
-       struct berval   max_committed_csn;
-       DB_LOCK                 suffix_lock;
-       int                             rc, ret;
-       ID                              ctxcsn_id;
-       Entry                   *e;
-       char                    textbuf[SLAP_TEXT_BUFLEN];
-       size_t                  textlen = sizeof textbuf;
-       EntryInfo               *eip = NULL;
-
-       assert( !BER_BVISNULL( &op->o_bd->be_context_csn ) );
-
-       if ( ei ) {
-               e = ei->bei_e;
-       }
-
-       rc =  bdb_dn2entry( op, tid, &op->o_bd->be_context_csn, &ctxcsn_ei,
-                       1, locker, &ctxcsn_lock );
-       switch( rc ) {
-       case 0:
-       case DB_NOTFOUND:
-               break;
-       case DB_LOCK_DEADLOCK:
-       case DB_LOCK_NOTGRANTED:
-               return BDB_CSN_RETRY;
-       default:
-               return BDB_CSN_ABORT;
-       }
-       
-       *ctxcsn_e = ctxcsn_ei->bei_e;
-
-       slap_get_commit_csn( op, &max_committed_csn );
-
-       if ( max_committed_csn.bv_val == NULL ) {
-               return BDB_CSN_COMMIT;
-       }
-
-       *ctxcsn_added = 0;
-
-       switch( rc ) {
-       case 0:
-               if ( !*ctxcsn_e ) {
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "context csn not present";
-                       op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx );
-                       return BDB_CSN_ABORT;
-               } else {
-                       Modifications mod;
-                       struct berval modvals[2];
-                       Entry dummy;
-
-                       modvals[0] = max_committed_csn;
-                       modvals[1].bv_val = NULL;
-                       modvals[1].bv_len = 0;
-
-                       mod.sml_op = LDAP_MOD_REPLACE;
-                       mod.sml_values = modvals;
-                       mod.sml_nvalues = NULL;
-                       mod.sml_desc = slap_schema.si_ad_contextCSN;
-                       mod.sml_type = mod.sml_desc->ad_cname;
-                       mod.sml_next = NULL;
-
-                       dummy = **ctxcsn_e;
-                       ret = bdb_modify_internal( op, tid, &mod, &dummy,
-                                                                       &rs->sr_text, textbuf, textlen );                                                      
-                       op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx );
-                       if ( ret != LDAP_SUCCESS ) {
-                               Debug( LDAP_DEBUG_TRACE,
-                                               "bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 );
-                               if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs );
-                               switch( ret ) {
-                               case DB_LOCK_DEADLOCK:
-                               case DB_LOCK_NOTGRANTED:
-                                       goto rewind;
-                               default:
-                                       return BDB_CSN_ABORT;
-                               }
-                       }
-
-                       ret = bdb_id2entry_update( op->o_bd, tid, &dummy );
-                       switch ( ret ) {
-                       case 0 :
-                               break;
-                       case DB_LOCK_DEADLOCK :
-                       case DB_LOCK_NOTGRANTED :
-                               if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs );
-                               goto rewind;
-                       default :
-                               if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs );
-                               rs->sr_err = ret;
-                               rs->sr_text = "context csn update failed";
-                               return BDB_CSN_ABORT;
-                       }
-                       ret = bdb_cache_modify( *ctxcsn_e, dummy.e_attrs, bdb->bi_dbenv, locker, &ctxcsn_lock );
-                       if ( ret != LDAP_SUCCESS ) {
-                               if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs );
-                               switch( ret ) {
-                               case DB_LOCK_DEADLOCK:
-                               case DB_LOCK_NOTGRANTED:
-                                       goto rewind;
-                               }
-                       }
-               }
-               break;
-       case DB_NOTFOUND:
-               if ( op->o_tag == LDAP_REQ_ADD &&
-                                               be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname )) {
-                       *suffix_ei = NULL;
-                       eip = (EntryInfo *) ch_calloc( 1, sizeof( EntryInfo ));
-                       eip->bei_id = op->oq_add.rs_e->e_id;
-               } else {
-                       eip = *suffix_ei = ctxcsn_ei;
-               }
-
-               /* This serializes add. But this case is very rare : only once. */
-               rs->sr_err = bdb_next_id( op->o_bd, tid, &ctxcsn_id );
-               if ( rs->sr_err != 0 ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                               "bdb_csn_commit: next_id failed (%d)\n",
-                               rs->sr_err, 0, 0 );
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "internal error";
-                       return BDB_CSN_ABORT;
-               }
-
-               *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, &max_committed_csn );
-               op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx );
-               (*ctxcsn_e)->e_id = ctxcsn_id;
-               *ctxcsn_added = 1;
-
-               ret = bdb_dn2id_add( op, tid, eip, *ctxcsn_e );
-               switch ( ret ) {
-               case 0 :
-                       break;
-               case DB_LOCK_DEADLOCK :
-               case DB_LOCK_NOTGRANTED :
-                       goto rewind;
-               case DB_KEYEXIST :
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "context csn exists before context prefix does";
-                       return BDB_CSN_ABORT;
-               default :
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "context csn store failed";
-                       return BDB_CSN_ABORT;
-               }
-
-               if ( *suffix_ei == NULL ) {
-                       ch_free( eip );
-               }
-
-               ret = bdb_id2entry_add( op->o_bd, tid, *ctxcsn_e );
-               switch ( ret ) {
-               case 0 :
-                       break;
-               case DB_LOCK_DEADLOCK :
-               case DB_LOCK_NOTGRANTED :
-                       goto rewind;
-               default :
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "context csn store failed";
-                       return BDB_CSN_ABORT;
-               }
-               ret = bdb_index_entry_add( op, tid, *ctxcsn_e );
-               switch ( ret ) {
-               case 0 :
-                       break;
-               case DB_LOCK_DEADLOCK :
-               case DB_LOCK_NOTGRANTED :
-                       goto rewind;
-               default :
-                       rs->sr_err = LDAP_OTHER;
-                       rs->sr_text = "context csn indexing failed";
-                       return BDB_CSN_ABORT;
-               }
-               break;
-       case DB_LOCK_DEADLOCK:
-       case DB_LOCK_NOTGRANTED:
-               Debug( LDAP_DEBUG_TRACE,
-                               "bdb_csn_commit : bdb_dn2entry retry\n", 0, 0, 0 );
-               goto rewind;
-       case LDAP_BUSY:
-               rs->sr_err = rc;
-               rs->sr_text = "ldap server busy";
-               return BDB_CSN_ABORT;
-       default:
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "internal error";
-               return BDB_CSN_ABORT;
-       }
-
-       return BDB_CSN_COMMIT;
-
-rewind :
-       slap_rewind_commit_csn( op );
-       return BDB_CSN_RETRY;
-}
-
-int
-bdb_get_commit_csn(
-       Operation       *op,
-       SlapReply       *rs,
-       struct berval   **search_context_csn,
-       u_int32_t       locker,
-       DB_LOCK         *ctxcsn_lock
-)
-{
-       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
-       struct berval csn = BER_BVNULL;
-       EntryInfo       *ctxcsn_ei = NULL;
-       EntryInfo       *suffix_ei = NULL;
-       Entry           *ctxcsn_e = NULL;
-       DB_TXN          *ltid = NULL;
-       Attribute       *csn_a;
-       char            gid[DB_XIDDATASIZE];
-       char            csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
-       int                     num_retries = 0;
-       int                     ctxcsn_added = 0;
-       int                     rc;
-       struct sync_cookie syncCookie = { NULL, -1, NULL};
-       syncinfo_t      *si;
-       u_int32_t       ctxcsn_locker = 0;
-
-       if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) &&
-                !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-               char substr[67];
-               struct berval ctxcsn_ndn = BER_BVNULL;
-               struct berval bv;
-
-               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                       sprintf( substr, "cn=syncrepl%ld", si->si_rid );
-                       ber_str2bv( substr, 0, 0, &bv );
-                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &bv, op->o_tmpmemctx );
-
-consumer_ctxcsn_retry :
-                       rs->sr_err = bdb_dn2entry( op, NULL, &ctxcsn_ndn, &ctxcsn_ei,
-                                                                               0, locker, ctxcsn_lock );
-                       switch(rs->sr_err) {
-                       case DB_LOCK_DEADLOCK:
-                       case DB_LOCK_NOTGRANTED:
-                               goto consumer_ctxcsn_retry;
-                       case 0:
-                               op->o_tmpfree( ctxcsn_ndn.bv_val, op->o_tmpmemctx );
-                               ctxcsn_ndn.bv_val = NULL;
-                               if ( ctxcsn_ei ) {
-                                       ctxcsn_e = ctxcsn_ei->bei_e;
-                               }
-                               break;
-                       case DB_NOTFOUND:
-                       default:
-                               rs->sr_err = LDAP_OTHER;
-                       case LDAP_BUSY:
-                               op->o_tmpfree( ctxcsn_ndn.bv_val, op->o_tmpmemctx );
-                               ctxcsn_ndn.bv_val = NULL;
-                               goto done;
-                       }
-
-                       if ( ctxcsn_e ) {
-                               csn_a = attr_find( ctxcsn_e->e_attrs,
-                                                       slap_schema.si_ad_syncreplCookie );
-                               if ( csn_a ) {
-                                       struct berval cookie;
-                                       const char *text;
-                                       int match = -1;
-                                       ber_dupbv( &cookie, &csn_a->a_vals[0] );
-                                       ber_bvarray_add( &syncCookie.octet_str, &cookie );
-                                       slap_parse_sync_cookie( &syncCookie );
-                                       if ( *search_context_csn &&
-                                               (*search_context_csn)->bv_val != NULL )
-                                       {
-                                               value_match( &match, slap_schema.si_ad_entryCSN,
-                                                       slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
-                                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                                       syncCookie.ctxcsn, *search_context_csn, &text );
-                                       }
-                                       if ( match < 0 ) {
-                                               /* set search_context_csn to the
-                                                  smallest syncrepl cookie value */
-                                               if ( *search_context_csn ) {
-                                                       ch_free( (*search_context_csn)->bv_val );
-                                                       ch_free( *search_context_csn );
-                                               }
-                                               *search_context_csn = ber_dupbv( NULL,
-                                                       syncCookie.ctxcsn );
-                                       }
-                                       slap_sync_cookie_free( &syncCookie, 0 );
-                               } else {
-                                       *search_context_csn = NULL;
-                               } 
-                       } else {
-                               *search_context_csn = NULL;
-                       }
-               }
-       } else if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) &&
-                LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-
-provider_ctxcsn_retry :
-               rs->sr_err = bdb_dn2entry( op, NULL, &op->o_bd->be_context_csn, &ctxcsn_ei,
-                                                                       0, locker, ctxcsn_lock );
-               switch(rs->sr_err) {
-               case 0:
-                       if ( ctxcsn_ei ) {
-                               ctxcsn_e = ctxcsn_ei->bei_e;
-                       }
-                       break;
-               case LDAP_BUSY:
-                       goto done;
-               case DB_LOCK_DEADLOCK:
-               case DB_LOCK_NOTGRANTED:
-                       goto provider_ctxcsn_retry;
-               case DB_NOTFOUND:
-                       snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
-                               bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
-
-                       slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
-
-                       if ( 0 ) {
-txn_retry:
-                               rs->sr_err = TXN_ABORT( ltid );
-                               ltid = NULL;
-                               if ( rs->sr_err != 0 ) {
-                                       rs->sr_err = LDAP_OTHER;
-                                       goto done;
-                               }
-                               ldap_pvt_thread_yield();
-                               bdb_trans_backoff( ++num_retries );
-                       }
-                       rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL,
-                                                               &ltid, bdb->bi_db_opflags );
-                       if ( rs->sr_err != 0 ) {
-                               rs->sr_err = LDAP_OTHER;
-                               goto done;
-                       }
-
-                       ctxcsn_locker = TXN_ID ( ltid );
-
-                       rs->sr_err = bdb_csn_commit( op, rs, ltid, NULL,
-                                               &suffix_ei, &ctxcsn_e,
-                                               &ctxcsn_added, ctxcsn_locker );
-                       switch( rs->sr_err ) {
-                       case BDB_CSN_ABORT:
-                               rs->sr_err = LDAP_OTHER;
-                               goto done;      
-                       case BDB_CSN_RETRY:
-                               goto txn_retry;
-                       }
-
-                       rs->sr_err = TXN_PREPARE( ltid, gid );
-                       if ( rs->sr_err != 0 ) {
-                               rs->sr_err = LDAP_OTHER;
-                               goto done;
-                       }
-
-                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                       (struct berval *)&slap_ldapsync_cn_bv, ctxcsn_locker );
-
-                       rs->sr_err = TXN_COMMIT( ltid, 0 );
-                       if ( rs->sr_err != 0 ) {
-                               rs->sr_err = LDAP_OTHER;
-                               goto done;
-                       }
-
-                       rs->sr_err = bdb_dn2entry( op, NULL,
-                                               &op->o_bd->be_context_csn,
-                                               &ctxcsn_ei, 0, ctxcsn_locker,
-                                               ctxcsn_lock );
-
-                       if ( ctxcsn_ei ) {
-                               ctxcsn_e = ctxcsn_ei->bei_e;
-                       }
-                       break;
-
-               default:
-                       rs->sr_err = LDAP_OTHER;
-                       goto done;
-               }
-
-               if ( ctxcsn_e ) {
-                       csn_a = attr_find( ctxcsn_e->e_attrs,
-                                               slap_schema.si_ad_contextCSN );
-                       if ( csn_a ) {
-                               *search_context_csn = ber_dupbv( NULL, &csn_a->a_vals[0] );
-                       } else {
-                               *search_context_csn = NULL;
-                       }
-               } else {
-                       *search_context_csn = NULL;
-               }
-       }
-
-       ltid = NULL;
-       rs->sr_err = LDAP_SUCCESS;
-
-done:
-    if( ltid != NULL ) {
-        TXN_ABORT( ltid );
-    }
-
-       return rs->sr_err;
-}
-#endif
index 60725caa326bd1a017e9829e29482422ff4863f5..adcdf463a7790cfcfca3a30b57250406edc18244 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -112,9 +112,6 @@ bdb_db_cache(
        rc = db->bdi_db->set_h_hash( db->bdi_db, bdb_db_hash );
 #endif
        rc = db->bdi_db->set_flags( db->bdi_db, DB_DUP | DB_DUPSORT );
-#if 0
-       rc = db->bdi_db->set_dup_compare( db->bdi_db, bdb_bt_compare );
-#endif
 
        file = ch_malloc( strlen( name ) + sizeof(BDB_SUFFIX) );
        sprintf( file, "%s" BDB_SUFFIX, name );
index e6008dc763a5297fe957a9875c454b8cc2ee3563..f7b3ff494f9e4e71bb27c5ed837c356e4e5d9f99 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -148,8 +148,6 @@ retry:      /* transaction retry */
 
        /* FIXME : dn2entry() should return non-glue entry */
        if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
-               BerVarray deref = NULL;
-
                Debug( LDAP_DEBUG_ARGS,
                        "<=- " LDAP_XSTRING(bdb_delete) ": no such object %s\n",
                        op->o_req_dn.bv_val, 0, 0);
@@ -163,18 +161,8 @@ retry:     /* transaction retry */
                        matched = NULL;
 
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                               }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                       LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
@@ -183,9 +171,6 @@ retry:      /* transaction retry */
                if ( rs->sr_ref != default_referral ) {
                        ber_bvarray_free( rs->sr_ref );
                }
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
@@ -377,22 +362,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef BDB_PSEARCH
-       ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-       LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-               rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_PREDELETE );
-               if ( rc == LDAP_BUSY && op->o_ps_send_wait ) {
-                       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-                       goto retry;
-               } else if ( rc ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                               LDAP_XSTRING(bdb_delete) ": persistent search "
-                               "failed (%d,%d)\n", rc, rs->sr_err, 0 );
-               }
-       }
-       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-#endif
-
        /* delete from dn2id */
        rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
        if ( rs->sr_err != 0 ) {
@@ -482,21 +451,6 @@ retry:     /* transaction retry */
        ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
 #endif
 
-#ifdef BDB_PSEARCH
-       if ( !dn_match( &ctxcsn_ndn, &op->o_req_ndn ) &&
-                !be_issuffix( op->o_bd, &op->o_req_ndn ) &&
-                       LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
-                       &ctxcsn_e, &ctxcsn_added, locker );
-               switch ( rc ) {
-               case BDB_CSN_ABORT :
-                       goto return_results;
-               case BDB_CSN_RETRY :
-                       goto retry;
-               }
-       }
-#endif
-
        if( op->o_noop ) {
                if ( ( rs->sr_err = TXN_ABORT( ltid ) ) != 0 ) {
                        rs->sr_text = "txn_abort (no-op) failed";
@@ -513,43 +467,6 @@ retry:     /* transaction retry */
                        goto retry;
                }
 
-#ifdef BDB_PSEARCH
-               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                       if ( ctxcsn_added ) {
-                               bdb_cache_add( bdb, suffix_ei,
-                                       ctxcsn_e, (struct berval *)&slap_ldapsync_cn_bv, locker );
-                       }
-               }
-
-               if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) {
-                       Attribute *a;
-                       a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
-                       if ( a ) {
-                               if( (void *) e->e_attrs != (void *) (e+1)) {
-                                       attr_delete( &e->e_attrs, slap_schema.si_ad_entryCSN );
-                                       attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN,
-                                       &op->o_sync_csn, NULL );
-                               } else {
-                                       a->a_vals[0] = op->o_sync_csn;
-                               }
-                       } else {
-                               /* Hm, the entryCSN ought to exist. ??? */
-                       }
-                       ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-                       LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                               rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE );
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_delete)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                               }
-                       }
-                       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-               }
-#endif
-
                rs->sr_err = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
index 397b5f276fcf75044bcc8d9d4d3107118ccd5c63..d6f9470c135fd6cd853ff1a1a849e5a8c8efb160 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6268fd3fd63989a88630046585887daf49657a08..b157ad23a9245f40b15eff0d8005893ef342181b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -391,45 +391,21 @@ bdb_dn2idl(
  * a B-Tree with sorted duplicates to store all the children of a node under
  * the same key. Also, the first item under the key contains the entry's own
  * rdn and the ID of the node's parent, to allow bottom-up tree traversal as
- * well as top-down. To keep this info first in the list, the nrdnlen is set
- * to the negative of its value.
+ * well as top-down. To keep this info first in the list, the high bit of all
+ * subsequent nrdnlen's is always set. This means we can only accomodate
+ * RDNs up to length 32767, but that's fine since full DNs are already
+ * restricted to 8192.
  *
  * The diskNode is a variable length structure. This definition is not
  * directly usable for in-memory manipulation.
  */
 typedef struct diskNode {
-       ID entryID;
-       short nrdnlen;
-       char nrdn[1];
-       char rdn[1];
+       unsigned char nrdnlen[2];
+       unsigned char nrdn[1];
+       unsigned char rdn[1];
+       unsigned char entryID[sizeof(ID)];
 } diskNode;
 
-/* Sort function for the sorted duplicate data items of a dn2id key.
- * Sorts based on normalized RDN, in length order.
- */
-int
-hdb_dup_compare(
-       DB *db, 
-       const DBT *usrkey,
-       const DBT *curkey )
-{
-       signed char *u = (signed char *)&(((diskNode *)(usrkey->data))->nrdnlen);
-       signed char *c = (signed char *)&(((diskNode *)(curkey->data))->nrdnlen);
-       int rc, i;
-
-       /* data is not aligned, cannot compare directly */
-#ifdef WORDS_BIGENDIAN
-       for( i = 0; i < (int)sizeof(short); i++)
-#else
-       for( i = sizeof(short)-1; i >= 0; i--)
-#endif
-       {
-               rc = u[i] - c[i];
-               if( rc ) return rc;
-       }
-       return strcmp( u+sizeof(short), c+sizeof(short) );
-}
-
 /* This function constructs a full DN for a given entry.
  */
 int hdb_fix_dn(
@@ -497,6 +473,7 @@ hdb_dn2id_add(
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        DBT             key, data;
+       ID              nid;
        int             rc, rlen, nrlen;
        diskNode *d;
        char *ptr;
@@ -510,18 +487,20 @@ hdb_dn2id_add(
        }
 
        d = op->o_tmpalloc(sizeof(diskNode) + rlen + nrlen, op->o_tmpmemctx);
-       d->entryID = e->e_id;
-       d->nrdnlen = nrlen;
+       d->nrdnlen[1] = nrlen & 0xff;
+       d->nrdnlen[0] = (nrlen >> 8) | 0x80;
        ptr = lutil_strncopy( d->nrdn, e->e_nname.bv_val, nrlen );
        *ptr++ = '\0';
        ptr = lutil_strncopy( ptr, e->e_name.bv_val, rlen );
-       *ptr = '\0';
+       *ptr++ = '\0';
+       BDB_ID2DISK( e->e_id, ptr );
 
        DBTzero(&key);
        DBTzero(&data);
-       key.data = &eip->bei_id;
+       key.data = &nid;
        key.size = sizeof(ID);
        key.flags = DB_DBT_USERMEM;
+       BDB_ID2DISK( eip->bei_id, &nid );
 
        /* Need to make dummy root node once. Subsequent attempts
         * will fail harmlessly.
@@ -545,9 +524,9 @@ hdb_dn2id_add(
        rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
 
        if (rc == 0) {
-               key.data = &e->e_id;
-               d->entryID = eip->bei_id;
-               d->nrdnlen = 0 - nrlen;
+               BDB_ID2DISK( e->e_id, &nid );
+               BDB_ID2DISK( eip->bei_id, ptr );
+               d->nrdnlen[0] ^= 0x80;
 
                rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
        }
@@ -570,15 +549,17 @@ hdb_dn2id_delete(
        DBC     *cursor;
        diskNode *d;
        int rc, nrlen;
+       ID      nid;
 
        DBTzero(&key);
        key.size = sizeof(ID);
        key.ulen = key.size;
-       key.data = &eip->bei_id;
+       key.data = &nid;
        key.flags = DB_DBT_USERMEM;
+       BDB_ID2DISK( eip->bei_id, &nid );
 
        DBTzero(&data);
-       data.size = sizeof(diskNode) + BEI(e)->bei_nrdn.bv_len;
+       data.size = sizeof(diskNode) + BEI(e)->bei_nrdn.bv_len - sizeof(ID) - 1;
        data.ulen = data.size;
        data.dlen = data.size;
        data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
@@ -590,22 +571,26 @@ hdb_dn2id_delete(
        if ( rc ) return rc;
 
        d = op->o_tmpalloc( data.size, op->o_tmpmemctx );
-       d->entryID = e->e_id;
-       d->nrdnlen = BEI(e)->bei_nrdn.bv_len;
+       d->nrdnlen[1] = BEI(e)->bei_nrdn.bv_len & 0xff;
+       d->nrdnlen[0] = (BEI(e)->bei_nrdn.bv_len >> 8) | 0x80;
        strcpy( d->nrdn, BEI(e)->bei_nrdn.bv_val );
        data.data = d;
 
        /* Delete our ID from the parent's list */
-       rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH | DB_RMW );
-       if ( rc == 0 )
-               rc = cursor->c_del( cursor, 0 );
+       rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE | DB_RMW );
+       if ( rc == 0 ) {
+               if ( !strcmp( d->nrdn, BEI(e)->bei_nrdn.bv_val ))
+                       rc = cursor->c_del( cursor, 0 );
+               else
+                       rc = DB_NOTFOUND;
+       }
 
        /* Delete our ID from the tree. With sorted duplicates, this
         * will leave any child nodes still hanging around. This is OK
         * for modrdn, which will add our info back in later.
         */
        if ( rc == 0 ) {
-               key.data = &e->e_id;
+               BDB_ID2DISK( e->e_id, &nid );
                rc = cursor->c_get( cursor, &key, &data, DB_SET | DB_RMW );
                if ( rc == 0 )
                        rc = cursor->c_del( cursor, 0 );
@@ -631,7 +616,7 @@ hdb_dn2id(
        int             rc = 0, nrlen;
        diskNode *d;
        char    *ptr;
-       ID idp = ei->bei_parent->bei_id;
+       ID idp;
 
        nrlen = dn_rdnlen( op->o_bd, in );
        if (!nrlen) nrlen = in->bv_len;
@@ -641,24 +626,31 @@ hdb_dn2id(
        key.data = &idp;
        key.ulen = sizeof(ID);
        key.flags = DB_DBT_USERMEM;
+       BDB_ID2DISK( ei->bei_parent->bei_id, &idp );
 
        DBTzero(&data);
-       data.size = sizeof(diskNode) + nrlen;
+       data.size = sizeof(diskNode) + nrlen - sizeof(ID) - 1;
        data.ulen = data.size * 3;
-       data.flags = DB_DBT_USERMEM;
+       data.dlen = data.ulen;
+       data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
 
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
        if ( rc ) return rc;
 
        d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
-       d->nrdnlen = nrlen;
+       d->nrdnlen[1] = nrlen & 0xff;
+       d->nrdnlen[0] = (nrlen >> 8) | 0x80;
        ptr = lutil_strncopy( d->nrdn, in->bv_val, nrlen );
        *ptr = '\0';
        data.data = d;
 
-       rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH );
+       rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE );
+       if ( rc == 0 && strncmp( d->nrdn, in->bv_val, nrlen )) {
+               rc = DB_NOTFOUND;
+       }
        if ( rc == 0 ) {
-               ei->bei_id = d->entryID;
+               ptr = data.data + data.size - sizeof(ID);
+               BDB_DISK2ID( ptr, &ei->bei_id );
                ei->bei_rdn.bv_len = data.size - sizeof(diskNode) - nrlen;
                ptr = d->nrdn + nrlen + 1;
                ber_str2bv( ptr, ei->bei_rdn.bv_len, 1, &ei->bei_rdn );
@@ -693,12 +685,14 @@ hdb_dn2id_parent(
        diskNode *d;
        char    *ptr;
        unsigned char *pt2;
+       ID      nid;
 
        DBTzero(&key);
        key.size = sizeof(ID);
-       key.data = &ei->bei_id;
+       key.data = &nid;
        key.ulen = sizeof(ID);
        key.flags = DB_DBT_USERMEM;
+       BDB_ID2DISK( ei->bei_id, &nid );
 
        DBTzero(&data);
        data.flags = DB_DBT_USERMEM;
@@ -712,12 +706,13 @@ hdb_dn2id_parent(
 
        rc = cursor->c_get( cursor, &key, &data, DB_SET );
        if ( rc == 0 ) {
-               if (d->nrdnlen >= 0) {
+               if (d->nrdnlen[0] & 0x80) {
                        rc = LDAP_OTHER;
                } else {
                        db_recno_t dkids;
-                       *idp = d->entryID;
-                       ei->bei_nrdn.bv_len = 0 - d->nrdnlen;
+                       ptr = data.data + data.size - sizeof(ID);
+                       BDB_DISK2ID( ptr, idp );
+                       ei->bei_nrdn.bv_len = (d->nrdnlen[0] << 8) | d->nrdnlen[1];
                        ber_str2bv( d->nrdn, ei->bei_nrdn.bv_len, 1, &ei->bei_nrdn );
                        ei->bei_rdn.bv_len = data.size - sizeof(diskNode) -
                                ei->bei_nrdn.bv_len;
@@ -751,13 +746,17 @@ hdb_dn2id_children(
        key.size = sizeof(ID);
        key.data = &e->e_id;
        key.flags = DB_DBT_USERMEM;
+       BDB_ID2DISK( e->e_id, &id );
 
+       /* IDL cache is in host byte order */
        if ( bdb->bi_idl_cache_size ) {
                rc = bdb_idl_cache_get( bdb, db, &key, NULL );
                if ( rc != LDAP_NO_SUCH_OBJECT ) {
                        return rc;
                }
        }
+
+       key.data = &id;
        DBTzero(&data);
        data.data = &d;
        data.ulen = sizeof(d);
@@ -797,6 +796,7 @@ struct dn2id_cookie {
        int rc;
        EntryInfo *ei;
        ID id;
+       ID nid;
        ID dbuf;
        ID *ids;
        void *ptr;
@@ -826,6 +826,7 @@ hdb_dn2idl_internal(
 )
 {
        if ( cx->bdb->bi_idl_cache_size ) {
+               cx->key.data = &cx->id;
                cx->rc = bdb_idl_cache_get(cx->bdb, cx->db, &cx->key, cx->tmp);
                if ( cx->rc == DB_NOTFOUND ) {
                        return cx->rc;
@@ -866,6 +867,7 @@ hdb_dn2idl_internal(
                cx->data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
 
                /* The first item holds the parent ID. Ignore it. */
+               cx->key.data = &cx->nid;
                cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data, DB_SET );
                if ( cx->rc ) {
                        cx->dbc->c_close( cx->dbc );
@@ -898,8 +900,8 @@ hdb_dn2idl_internal(
                                        diskNode *d = (diskNode *)j;
                                        short nrlen;
 
-                                       AC_MEMCPY( &ei.bei_id, &d->entryID, sizeof(ID) );
-                                       AC_MEMCPY( &nrlen, &d->nrdnlen, sizeof(d->nrdnlen) );
+                                       BDB_DISK2ID( j + len - sizeof(ID), &ei.bei_id );
+                                       nrlen = ((d->nrdnlen[0] ^ 0x80) << 8) | d->nrdnlen[1];
                                        ei.bei_nrdn.bv_len = nrlen;
                                        /* nrdn/rdn are set in-place.
                                         * hdb_cache_load will copy them as needed
@@ -931,6 +933,7 @@ hdb_dn2idl_internal(
 
 saveit:
        if ( cx->bdb->bi_idl_cache_max_size ) {
+               cx->key.data = &cx->id;
                bdb_idl_cache_put( cx->bdb, cx->db, &cx->key, cx->tmp, cx->rc );
        }
        ;
@@ -952,6 +955,7 @@ gotit:
                                for ( cx->id = bdb_idl_first( save, &idcurs );
                                        cx->id != NOID;
                                        cx->id = bdb_idl_next( save, &idcurs )) {
+                                       BDB_ID2DISK( cx->id, &cx->nid );
                                        cx->ei = NULL;
                                        hdb_dn2idl_internal( cx );
                                        if ( !BDB_IDL_IS_ZERO( cx->tmp ))
@@ -994,6 +998,7 @@ hdb_dn2idl(
 #endif
 
        cx.id = e->e_id;
+       BDB_ID2DISK( cx.id, &cx.nid );
        cx.ei = e->e_id ? BEI(e) : &bdb->bi_cache.c_dntree;
        cx.bdb = bdb;
        cx.db = cx.bdb->bi_dn2id->bdi_db;
@@ -1009,7 +1014,6 @@ hdb_dn2idl(
        }
 
        DBTzero(&cx.key);
-       cx.key.data = &cx.id;
        cx.key.ulen = sizeof(ID);
        cx.key.size = sizeof(ID);
        cx.key.flags = DB_DBT_USERMEM;
index 4d2f22277a39cff05e7ceda6c47be48b97453822..ea1db3215eaa399be728203b160416ee609ad86f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index bd65f8115fafce53d634eb9a341a4ba3b1feb888..aa21fa4db030a8b459e50771ce4d511ee78348d4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 64514cc86237ce678ce10294cf9f2b129d565074..d6fa3c32a6971dba2196020d774ef53ab5aa4948 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ba63ccea38630dabef6350e3ccef6162899038f2..b8d90289649e141671d0160e6f0507dcd3862d8a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7fcc6a0abbbdfb3ecd2e2c7d40bf8b613b39d7ab..186ad24b3cd6bc8eb1dcc60b697b91993b0a391b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -441,7 +441,14 @@ bdb_idl_fetch_key(
 #if DB_VERSION_FULL < 0x04010000
 #      define BDB_ENOUGH 5
 #else
+       /* We sometimes test with tiny IDLs, and BDB always wants buffers
+        * that are at least one page in size.
+        */
+# if BDB_IDL_DB_SIZE < 4096
+#   define BDB_ENOUGH 2048
+# else
 #      define BDB_ENOUGH 1
+# endif
 #endif
        ID buf[BDB_IDL_DB_SIZE*BDB_ENOUGH];
 
@@ -653,6 +660,7 @@ bdb_idl_insert_key(
                        if ( count >= BDB_IDL_DB_MAX ) {
                        /* No room, convert to a range */
                                DBT key2 = *key;
+                               db_recno_t i;
 
                                key2.dlen = key2.ulen;
                                key2.flags |= DB_DBT_PARTIAL;
@@ -679,35 +687,62 @@ bdb_idl_insert_key(
                                        }
                                }
                                BDB_DISK2ID( &nhi, &hi );
-                               if ( id < lo ) {
-                                       lo = id;
-                                       nlo = nid;
-                               } else if ( id > hi ) {
-                                       hi = id;
-                                       nhi = nid;
+                               /* Update hi/lo if needed, then delete all the items
+                                * between lo and hi
+                                */
+                               data.data = &nid;
+                               if ( id > hi ) {
+                                       rc = cursor->c_del( cursor, 0 );
+                                       if ( rc != 0 ) {
+                                               err = "c_del hi";
+                                               goto fail;
+                                       }
+                                       rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
+                                       if ( rc != 0 ) {
+                                               err = "c_put hi";
+                                               goto fail;
+                                       }
                                }
-                               rc = db->del( db, tid, key, 0 );
+                               /* Don't fetch anything, just position cursor */
+                               data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
+                               data.dlen = data.ulen = 0;
+                               rc = cursor->c_get( cursor, key, &data, DB_SET | DB_RMW );
                                if ( rc != 0 ) {
-                                       err = "del";
+                                       err = "c_get 2";
                                        goto fail;
                                }
-                               data.data = &nid;
-                               nid = 0;
-                               rc = cursor->c_put( cursor, key, &data, DB_KEYFIRST );
-                               if ( rc != 0 ) {
-                                       err = "c_put 0";
-                                       goto fail;
+                               if ( id < lo ) {
+                                       rc = cursor->c_del( cursor, 0 );
+                                       if ( rc != 0 ) {
+                                               err = "c_del lo";
+                                               goto fail;
+                                       }
+                                       rc = cursor->c_put( cursor, key, &data, DB_KEYFIRST );
+                                       if ( rc != 0 ) {
+                                               err = "c_put lo";
+                                               goto fail;
+                                       }
                                }
-                               nid = nlo;
-                               rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
-                               if ( rc != 0 ) {
-                                       err = "c_put lo";
-                                       goto fail;
+                               /* Delete all the records between lo and hi */
+                               for ( i=2; i<count; i++ ) {
+                                       rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_DUP | DB_RMW );
+                                       if ( rc != 0 ) {
+                                               err = "c_get next_dup";
+                                               goto fail;
+                                       }
+                                       rc = cursor->c_del( cursor, 0 );
+                                       if ( rc != 0 ) {
+                                               err = "c_del range";
+                                               goto fail;
+                                       }
                                }
-                               nid = nhi;
-                               rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
+                               /* Store the range marker */
+                               data.size = data.ulen = sizeof(ID);
+                               data.flags = DB_DBT_USERMEM;
+                               nid = 0;
+                               rc = cursor->c_put( cursor, key, &data, DB_KEYFIRST );
                                if ( rc != 0 ) {
-                                       err = "c_put hi";
+                                       err = "c_put range";
                                        goto fail;
                                }
                        } else {
index c0479465e4bc5a74fc814e0bb99b72d77a46a655..357c6539bdf62ce9a5eff51f7623ea8653b6e98d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a93fdc49a2f190dbad934a5d46879c566b56f14c..6f101275be1381fe06946781603b3d11727facc2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -241,7 +241,7 @@ static int indexer(
 
                if( rc == LDAP_SUCCESS && keys != NULL ) {
                        for( i=0; keys[i].bv_val != NULL; i++ ) {
-                               bdb_key_change( op->o_bd, db, txn, &keys[i], id, opid );
+                               rc = bdb_key_change( op->o_bd, db, txn, &keys[i], id, opid );
                                if( rc ) {
                                        ber_bvarray_free_x( keys, op->o_tmpmemctx );
                                        goto done;
index dc36130bc3bce5d2a156fdfd88424c1fbe9d8373..188464e42affe255161a26b5f555bf5a97b38b3f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -85,11 +85,6 @@ bdb_db_init( BackendDB *be )
        bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
        bdb->bi_search_stack = NULL;
 
-#ifdef BDB_PSEARCH
-       LDAP_LIST_INIT (&bdb->bi_psearch_list);
-       ldap_pvt_thread_rdwr_init ( &bdb->bi_pslist_rwlock );
-#endif
-
        ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
@@ -101,31 +96,6 @@ bdb_db_init( BackendDB *be )
        return 0;
 }
 
-int
-bdb_bt_compare(
-       DB *db, 
-       const DBT *usrkey,
-       const DBT *curkey )
-{
-       unsigned char *u, *c;
-       int i, x;
-
-       u = usrkey->data;
-       c = curkey->data;
-
-#ifdef WORDS_BIGENDIAN
-       for( i = 0; i < (int)sizeof(ID); i++)
-#else
-       for( i = sizeof(ID)-1; i >= 0; i--)
-#endif
-       {
-               x = u[i] - c[i];
-               if( x ) return x;
-       }
-
-       return 0;
-}
-
 static void *
 bdb_checkpoint( void *ctx, void *arg )
 {
@@ -321,10 +291,6 @@ bdb_db_open( BackendDB *be )
                }
 
                if( i == BDB_ID2ENTRY ) {
-#if 0
-                       rc = db->bdi_db->set_bt_compare( db->bdi_db,
-                               bdb_bt_compare );
-#endif
                        rc = db->bdi_db->set_pagesize( db->bdi_db,
                                BDB_ID2ENTRY_PAGESIZE );
                        if ( slapMode & SLAP_TOOL_READMAIN ) {
@@ -336,20 +302,12 @@ bdb_db_open( BackendDB *be )
                        rc = db->bdi_db->set_flags( db->bdi_db, 
                                DB_DUP | DB_DUPSORT );
 #ifndef BDB_HIER
-#if 0
-                       rc = db->bdi_db->set_dup_compare( db->bdi_db,
-                               bdb_bt_compare );
-#endif
                        if ( slapMode & SLAP_TOOL_READONLY ) {
                                flags |= DB_RDONLY;
                        } else {
                                flags |= DB_CREATE;
                        }
 #else
-                       rc = db->bdi_db->set_dup_compare( db->bdi_db,
-                               bdb_dup_compare );
-                       rc = db->bdi_db->set_bt_compare( db->bdi_db,
-                               bdb_bt_compare );
                        if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
                                flags |= DB_RDONLY;
                        } else {
@@ -378,10 +336,14 @@ bdb_db_open( BackendDB *be )
                        bdb->bi_dbenv_mode );
 #endif
 
-               if( rc != 0 ) {
+               if ( rc != 0 ) {
+                       char    buf[SLAP_TEXT_BUFLEN];
+
+                       snprintf( buf, sizeof(buf), "%s/%s", 
+                               bdb->bi_dbenv_home, bdbi_databases[i].file );
                        Debug( LDAP_DEBUG_ANY,
                                "bdb_db_open: db_open(%s) failed: %s (%d)\n",
-                               bdb->bi_dbenv_home, db_strerror(rc), rc );
+                               buf, db_strerror(rc), rc );
                        return rc;
                }
 
@@ -501,68 +463,6 @@ bdb_db_destroy( BackendDB *be )
                ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
        }
 
-#ifdef BDB_PSEARCH
-       ldap_pvt_thread_rdwr_destroy ( &bdb->bi_pslist_rwlock );
-       ps = LDAP_LIST_FIRST( &bdb->bi_psearch_list );
-
-       if ( ps ) {
-               psn = LDAP_LIST_NEXT( ps, o_ps_link );
-
-               saved_tmpmemctx = ps->o_tmpmemctx;
-
-               if (!BER_BVISNULL(&ps->o_req_dn)) {
-                       slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->o_req_ndn)) {
-                       slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->ors_filterstr)) {
-                       slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx);
-               }
-               if (ps->ors_filter != NULL) {
-                       filter_free_x(ps, ps->ors_filter);
-               }
-               if ( ps->ors_attrs != NULL) {
-                       ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx);
-               }
-
-               slap_op_free( ps );
-
-               if ( saved_tmpmemctx ) {
-                       slap_sl_mem_destroy( NULL, saved_tmpmemctx );
-               }
-       }
-
-       while ( psn ) {
-               ps = psn;
-               psn = LDAP_LIST_NEXT( ps, o_ps_link );
-
-               saved_tmpmemctx = ps->o_tmpmemctx;
-
-               if (!BER_BVISNULL(&ps->o_req_dn)) {
-                       slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->o_req_ndn)) {
-                       slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->ors_filterstr)) {
-                       slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx);
-               }
-               if (ps->ors_filter != NULL) {
-                       filter_free_x(ps, ps->ors_filter);
-               }
-               if ( ps->ors_attrs != NULL) {
-                       ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx);
-               }
-
-               slap_op_free( ps );
-
-               if ( saved_tmpmemctx ) {
-                       slap_sl_mem_destroy( NULL, saved_tmpmemctx );
-               }
-       }
-#endif
-
        ch_free( bdb );
        be->be_private = NULL;
 
index 563489bccf1de236182db91d1ea45bf7643c75fe..e64236693578b93efa160842596e3ec413bd1a8e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index bb5208ede19928d8309067d93dca350974e3865b..db166d0c37acde5378a888c0fe272dad02ae79db 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -307,16 +307,6 @@ retry:     /* transaction retry */
                Debug(LDAP_DEBUG_TRACE,
                        LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0);
 
-#ifdef BDB_PSEARCH
-               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-               while ( pm_list != NULL ) {
-                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                       pm_prev = pm_list;
-                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                       ch_free( pm_prev );
-               }
-#endif
-
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
@@ -382,7 +372,6 @@ retry:      /* transaction retry */
        if (( rs->sr_err == DB_NOTFOUND ) ||
                ( !manageDSAit && e && is_entry_glue( e )))
        {
-               BerVarray deref = NULL;
                if ( e != NULL ) {
                        rs->sr_matched = ch_strdup( e->e_dn );
                        rs->sr_ref = is_entry_referral( e )
@@ -392,18 +381,8 @@ retry:     /* transaction retry */
                        e = NULL;
 
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                       LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
@@ -412,9 +391,6 @@ retry:      /* transaction retry */
                if ( rs->sr_ref != default_referral ) {
                        ber_bvarray_free( rs->sr_ref );
                }
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
@@ -447,25 +423,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef BDB_PSEARCH
-       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) {
-               ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                       rc = bdb_psearch(op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY );
-                       if ( rc == LDAP_BUSY && op->o_ps_send_wait ) {
-                               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-                               goto retry;
-                       } else if ( rc ) {
-                               Debug( LDAP_DEBUG_TRACE,
-                                       LDAP_XSTRING(bdb_modify)
-                                       ": persistent search failed (%d,%d)\n",
-                                       rc, rs->sr_err, 0 );
-                       }
-               }
-               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-       }
-#endif
-
        if( op->o_preread ) {
                if( preread_ctrl == NULL ) {
                        preread_ctrl = &ctrls[num_ctrls++];
@@ -537,19 +494,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef BDB_PSEARCH
-       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
-                       &ctxcsn_e, &ctxcsn_added, locker );
-               switch ( rc ) {
-               case BDB_CSN_ABORT :
-                       goto return_results;
-               case BDB_CSN_RETRY :
-                       goto retry;
-               }
-       }
-#endif
-
        if( op->o_postread ) {
                if( postread_ctrl == NULL ) {
                        postread_ctrl = &ctrls[num_ctrls++];
@@ -573,6 +517,8 @@ retry:      /* transaction retry */
                        goto return_results;
                }
        } else {
+               /* may have changed in bdb_modify_internal() */
+               e->e_ocflags = dummy.e_ocflags;
                rc = bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock );
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
@@ -581,47 +527,6 @@ retry:     /* transaction retry */
                }
                dummy.e_attrs = NULL;
 
-#ifdef BDB_PSEARCH
-               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                       if ( ctxcsn_added ) {
-                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                       (struct berval *)&slap_ldapsync_cn_bv, locker );
-                       }
-               }
-
-               if ( rs->sr_err == LDAP_SUCCESS ) {
-                       /* Loop through in-scope entries for each psearch spec */
-                       ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-                       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                               rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_modify)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                               }
-                       }
-                       pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-                       while ( pm_list != NULL ) {
-                               rc = bdb_psearch(op, rs, pm_list->ps_op,
-                                                       e, LDAP_PSEARCH_BY_SCOPEOUT);
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_modify)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                               }
-                               LDAP_LIST_REMOVE ( pm_list, ps_link );
-                               pm_prev = pm_list;
-                               pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                               ch_free( pm_prev );
-                       }
-                       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-               }
-#endif
-
                rs->sr_err = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
@@ -661,15 +566,6 @@ return_results:
 
 done:
        if( ltid != NULL ) {
-#ifdef BDB_PSEARCH
-               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-               while ( pm_list != NULL ) {
-                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                       pm_prev = pm_list;
-                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                       ch_free( pm_prev );
-               }
-#endif
                TXN_ABORT( ltid );
                op->o_private = NULL;
        }
index 217c76501dc73d237fe03df6050fb9941d515142..333be33ee7b41d4e69f5386a8643794461641314 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -100,15 +100,6 @@ retry:     /* transaction retry */
                }
                Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn)
                                ": retrying...\n", 0, 0, 0 );
-#ifdef BDB_PSEARCH
-               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-               while ( pm_list != NULL ) {
-                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                       pm_prev = pm_list;
-                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                       ch_free( pm_prev );
-               }
-#endif
 
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
@@ -172,7 +163,6 @@ retry:      /* transaction retry */
        if (( rs->sr_err == DB_NOTFOUND ) ||
                ( !manageDSAit && e && is_entry_glue( e )))
        {
-               BerVarray deref = NULL;
                if( e != NULL ) {
                        rs->sr_matched = ch_strdup( e->e_dn );
                        rs->sr_ref = is_entry_referral( e )
@@ -182,27 +172,14 @@ retry:    /* transaction retry */
                        e = NULL;
 
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                       LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
                send_ldap_result( op, rs );
 
                ber_bvarray_free( rs->sr_ref );
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
@@ -720,23 +697,6 @@ retry:     /* transaction retry */
 
        dummy.e_attrs = e->e_attrs;
 
-#ifdef BDB_PSEARCH
-       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) {
-               ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                       rc = bdb_psearch( op, rs, ps_list, &dummy, LDAP_PSEARCH_BY_PREMODIFY );
-                       if ( rc ) {
-                               Debug( LDAP_DEBUG_TRACE,
-                                       LDAP_XSTRING(bdb_modrdn)
-                                       ": persistent search failed (%d,%d)\n",
-                                       rc, rs->sr_err, 0 );
-                       }
-               }
-               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-       }
-#endif
-
-
        /* modify entry */
        rs->sr_err = bdb_modify_internal( op, lt2, &mod[0], &dummy,
                &rs->sr_text, textbuf, textlen );
@@ -805,19 +765,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef BDB_PSEARCH
-       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
-                       &ctxcsn_e, &ctxcsn_added, locker );
-               switch ( rc ) {
-               case BDB_CSN_ABORT :
-                       goto return_results;
-               case BDB_CSN_RETRY :
-                       goto retry;
-               }
-       }
-#endif
-
        if( op->o_postread ) {
                if( postread_ctrl == NULL ) {
                        postread_ctrl = &ctrls[num_ctrls++];
@@ -853,47 +800,6 @@ retry:     /* transaction retry */
                new_dn.bv_val = NULL;
                new_ndn.bv_val = NULL;
 
-#ifdef BDB_PSEARCH
-               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                       if ( ctxcsn_added ) {
-                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                       (struct berval *)&slap_ldapsync_cn_bv, locker );
-                       }
-               }
-
-               if ( rs->sr_err == LDAP_SUCCESS ) {
-                       /* Loop through in-scope entries for each psearch spec */
-                       ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-                       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                               rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_modrdn)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                       }
-                       }
-                       pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-                       while ( pm_list != NULL ) {
-                               rc = bdb_psearch(op, rs, pm_list->ps_op,
-                                                       e, LDAP_PSEARCH_BY_SCOPEOUT);
-                               if ( rc ) {
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(bdb_modrdn)
-                                               ": persistent search failed "
-                                               "(%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-                               }
-                               pm_prev = pm_list;
-                               LDAP_LIST_REMOVE ( pm_list, ps_link );
-                               pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                               ch_free( pm_prev );
-                       }
-                       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-               }
-#endif
-
                if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
                        rs->sr_text = "txn_commit failed";
                } else {
@@ -980,15 +886,6 @@ done:
        }
 
        if( ltid != NULL ) {
-#ifdef BDB_PSEARCH
-               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-               while ( pm_list != NULL ) {
-                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                       pm_prev = pm_list;
-                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                       ch_free( pm_prev );
-               }
-#endif
                TXN_ABORT( ltid );
                op->o_private = NULL;
        }
index a42280707987c4e7b1806b1d1cb2ac46dd330fdd..15483a75b148d108dd7239f87dc6b032a74d2732 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7c4590e6c203aecfe72b3a3e78573217b36ffa06..671a67dfff98587b8754fafc08ac577ce4fd3f3a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -97,10 +97,10 @@ bdb_operational(
        if ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
                        ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
        {
-               int     hasSubordinates;
+               int     hasSubordinates, rc;
 
-               rs->sr_err = bdb_hasSubordinates( op, rs->sr_entry, &hasSubordinates );
-               if ( rs->sr_err == LDAP_SUCCESS ) {
+               rc = bdb_hasSubordinates( op, rs->sr_entry, &hasSubordinates );
+               if ( rc == LDAP_SUCCESS ) {
                        *ap = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE );
                        assert( *ap );
 
@@ -108,6 +108,6 @@ bdb_operational(
                }
        }
 
-       return rs->sr_err;
+       return LDAP_SUCCESS;
 }
 
index 672ab7804a743b57e688cad7e7ba805be0a62997..c770b3fc4221d811c1cacc3f8ea8541fce4b7923 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -51,20 +51,6 @@ int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
 
 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
 
-/*
- * ctxcsn.c
- */
-#define bdb_csn_commit                         BDB_SYMBOL(csn_commit)
-#define bdb_get_commit_csn                     BDB_SYMBOL(get_commit_csn)
-
-int bdb_csn_commit LDAP_P(( Operation *op, SlapReply *rs, DB_TXN *tid,
-                                               EntryInfo *ei, EntryInfo **suffix_ei, Entry **ctxcsn_e,
-                                               int *ctxcsn_added, u_int32_t locker ));
-
-int bdb_get_commit_csn LDAP_P(( Operation *op, SlapReply *rs,
-                                               struct berval **search_context_csn,
-                                               u_int32_t locker, DB_LOCK *ctxcsn_lock ));
-
 /*
  * dbcache.c
  */
@@ -125,7 +111,6 @@ int bdb_dn2idl(
 
 #ifdef BDB_HIER
 #define bdb_dn2id_parent                       BDB_SYMBOL(dn2id_parent)
-#define bdb_dup_compare                                BDB_SYMBOL(dup_compare)
 #define bdb_fix_dn                                     BDB_SYMBOL(fix_dn)
 
 int bdb_dn2id_parent(
@@ -134,11 +119,6 @@ int bdb_dn2id_parent(
        EntryInfo *ei,
        ID *idp );
 
-int bdb_dup_compare(
-       DB *db,
-       const DBT *usrkey,
-       const DBT *curkey );
-
 int bdb_fix_dn( Entry *e, int checkit );
 #endif
 
@@ -300,13 +280,6 @@ ID bdb_idl_first( ID *ids, ID *cursor );
 ID bdb_idl_next( ID *ids, ID *cursor );
 
 
-#define bdb_bt_compare                         BDB_SYMBOL(bt_compare)
-
-int bdb_bt_compare(
-       DB *db,
-       const DBT *a,
-       const DBT *b );
-
 
 /*
  * index.c
@@ -552,34 +525,6 @@ int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
 
 #endif
 
-/*
- * search.c
- */
-
-#define bdb_abandon                                    BDB_SYMBOL(abandon)
-#define bdb_cancel                                     BDB_SYMBOL(cancel)
-#define bdb_do_search                          BDB_SYMBOL(do_search)
-#define bdb_psearch                            BDB_SYMBOL(psearch)
-
-BI_op_abandon bdb_abandon;
-BI_op_cancel bdb_cancel;
-
-int bdb_psearch(
-       Operation       *op,
-       SlapReply       *rs,
-       Operation       *ps_op,
-       Entry           *entry,
-       int             psearch_type
-);
-
-int bdb_do_search(
-       Operation       *op,
-       SlapReply       *rs,
-       Operation       *ps_op,
-       Entry           *entry,
-       int             psearch_type
-);
-
 /*
  * trans.c
  */
index 382feca3612339e2e314779246a6284905492a72..c52288bc2615fdb4a545bca6cc5b6af430bfbc22 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -103,7 +103,7 @@ dn2entry_retry:
 
                if( rs->sr_ref != NULL ) {
                        /* send referrals */
-                       rs->sr_err = LDAP_REFERRAL;
+                       rc = rs->sr_err = LDAP_REFERRAL;
                        send_ldap_result( op, rs );
                        ber_bvarray_free( rs->sr_ref );
                        rs->sr_ref = NULL;
index e47ce1f86b60ced155cf875f6c7ebcc9bfcc7ae6..9b863f1217b92b2022445a0fae075ed1b4b73986 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,7 @@ static int base_candidate(
        ID              *ids );
 
 static int search_candidates(
-       Operation *stackop,     /* op with the current threadctx/slab cache */
-       Operation *sop,         /* search op */
+       Operation *op,
        SlapReply *rs,
        Entry *e,
        u_int32_t locker,
@@ -302,314 +301,8 @@ sameido:
        return rs->sr_err;
 }
 
-#ifdef BDB_PSEARCH
-
-#define is_sync_protocol(op)   \
-       ((op)->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST)
-
-#define IS_BDB_REPLACE(type) (( type == LDAP_PSEARCH_BY_DELETE ) || \
-       ( type == LDAP_PSEARCH_BY_SCOPEOUT ))
-#define IS_PSEARCH (op != sop)
-#define IS_POST_SEARCH ( op->ors_post_search_id != NOID )
-
-static Operation *
-bdb_drop_psearch( Operation *op, ber_int_t msgid )
-{
-       Operation       *ps_list;
-       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
-
-       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-               if ( ps_list->o_connid == op->o_connid ) {
-                       if ( ps_list->o_msgid == msgid ) {
-                               ps_list->o_abandon = 1;
-                               LDAP_LIST_REMOVE( ps_list, o_ps_link );
-                               ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
-                               LDAP_STAILQ_REMOVE( &op->o_conn->c_ops, ps_list,
-                                       slap_op, o_next );
-                               LDAP_STAILQ_NEXT( ps_list, o_next ) = NULL;
-                               op->o_conn->c_n_ops_executing--;
-                               op->o_conn->c_n_ops_completed++;
-                               ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
-                               return ps_list;
-                       }
-               }
-       }
-
-       return NULL;
-}
-
 int
-bdb_abandon( Operation *op, SlapReply *rs )
-{
-       Operation       *ps;
-       void            *saved_tmpmemctx;
-
-       ps = bdb_drop_psearch( op, op->oq_abandon.rs_msgid );
-       if ( ps ) {
-               saved_tmpmemctx = ps->o_tmpmemctx;
-
-               if (!BER_BVISNULL(&ps->o_req_dn)) {
-                       slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->o_req_ndn)) {
-                       slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->ors_filterstr)) {
-                       ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx);
-               }
-               if (ps->ors_filter != NULL) {
-                       filter_free_x(ps, ps->ors_filter);
-               }
-               if (ps->ors_attrs != NULL) {
-                       ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx);
-               }
-
-               slap_op_free ( ps );
-
-               if ( saved_tmpmemctx ) {
-                       slap_sl_mem_destroy( NULL, saved_tmpmemctx );
-               }
-
-               return LDAP_SUCCESS;
-       }
-       return LDAP_UNAVAILABLE;
-}
-
-int
-bdb_cancel( Operation *op, SlapReply *rs )
-{
-       Operation       *ps;
-       void            *saved_tmpmemctx;
-
-       ps = bdb_drop_psearch( op, op->oq_cancel.rs_msgid );
-       if ( ps ) {
-               saved_tmpmemctx = ps->o_tmpmemctx;
-
-               rs->sr_err = LDAP_CANCELLED;
-               send_ldap_result( ps, rs );
-
-               if (!BER_BVISNULL(&ps->o_req_dn)) {
-                       slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->o_req_ndn)) {
-                       slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx );
-               }
-               if (!BER_BVISNULL(&ps->ors_filterstr)) {
-                       ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx);
-               }
-               if (ps->ors_filter != NULL) {
-                       filter_free_x(ps, ps->ors_filter);
-               }
-               if (ps->ors_attrs != NULL) {
-                       ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx);
-               }
-
-               slap_op_free ( ps );
-
-               if ( saved_tmpmemctx ) {
-                       slap_sl_mem_destroy( NULL, saved_tmpmemctx );
-               }
-
-               return LDAP_SUCCESS;
-       }
-       return LDAP_UNAVAILABLE;
-}
-
-int bdb_search( Operation *op, SlapReply *rs )
-{
-       int rc;
-       struct pc_entry *pce = NULL;
-       struct pc_entry *tmp_pce = NULL;
-       Entry ps_e = {0};
-       Attribute *a;
-
-       ps_e.e_private = NULL;
-       ldap_pvt_thread_mutex_init( &op->o_pcmutex );
-       LDAP_TAILQ_INIT( &op->o_ps_pre_candidates );
-       LDAP_TAILQ_INIT( &op->o_ps_post_candidates );
-
-       op->ors_post_search_id = NOID;
-       rc = bdb_do_search( op, rs, op, NULL, 0 );
-
-       ldap_pvt_thread_mutex_lock( &op->o_pcmutex );
-       pce = LDAP_TAILQ_FIRST( &op->o_ps_post_candidates );
-       ldap_pvt_thread_mutex_unlock( &op->o_pcmutex );
-
-       while ( rc == LDAP_SUCCESS && pce &&
-                       op->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST ) {
-
-               ps_e.e_id = op->ors_post_search_id = pce->pc_id;
-               if ( op->o_sync_csn.bv_val ) {
-                       ch_free( op->o_sync_csn.bv_val );
-                       op->o_sync_csn.bv_val = NULL;
-               }
-               ber_dupbv( &op->o_sync_csn, &pce->pc_csn );
-               ber_dupbv( &ps_e.e_name, &pce->pc_ename );
-               ber_dupbv( &ps_e.e_nname, &pce->pc_enname );
-               a = ch_calloc( 1, sizeof( Attribute ));
-               a->a_desc = slap_schema.si_ad_entryUUID;
-               a->a_vals = ch_calloc( 2, sizeof( struct berval ));
-               ber_dupbv( &a->a_vals[0], &pce->pc_entryUUID );
-               a->a_nvals = a->a_vals;
-               a->a_next = NULL;
-               ps_e.e_attrs = a;
-
-               rc = bdb_do_search( op, rs, op, &ps_e, 0 );
-
-               tmp_pce = pce;
-               ldap_pvt_thread_mutex_lock( &op->o_pcmutex );
-               pce = LDAP_TAILQ_NEXT( pce, pc_link );
-               LDAP_TAILQ_REMOVE( &op->o_ps_post_candidates, tmp_pce, pc_link );
-               ldap_pvt_thread_mutex_unlock( &op->o_pcmutex );
-
-               ch_free( tmp_pce->pc_csn.bv_val );
-               ch_free( tmp_pce->pc_entryUUID.bv_val );
-               ch_free( tmp_pce->pc_ename.bv_val );
-               ch_free( tmp_pce->pc_enname.bv_val );
-               ch_free( tmp_pce );     
-               entry_clean( &ps_e );
-       }
-       return rc;
-}
-
-#define BDB_PSEARCH_MAX_WAIT 3
-int bdb_psearch( Operation *op, SlapReply *rs, Operation *sop,
-       Entry *ps_e, int ps_type )
-{
-       int     rc;
-       struct pc_entry *pce = NULL;
-       struct pc_entry *p = NULL;
-       int num_retries = 0;
-
-       op->ors_post_search_id = NOID;
-
-       switch (ps_type) {
-       case LDAP_PSEARCH_BY_PREMODIFY:
-       case LDAP_PSEARCH_BY_PREDELETE:
-
-               if ( !op->o_ps_send_wait ) {
-                       if ( sop->o_refresh_in_progress ) {
-                               pce = (struct pc_entry *) ch_calloc(
-                                                       1, sizeof( struct pc_entry ));
-                               pce->pc_id = ps_e->e_id;
-                               ldap_pvt_thread_mutex_lock( &sop->o_pcmutex );
-                               if ( LDAP_TAILQ_EMPTY( &sop->o_ps_pre_candidates )) {
-                                       LDAP_TAILQ_INSERT_HEAD(
-                                                       &sop->o_ps_pre_candidates, pce, pc_link );
-                               } else {
-                                       LDAP_TAILQ_FOREACH( p,
-                                                       &sop->o_ps_pre_candidates, pc_link ) {
-                                               if ( p->pc_id > pce->pc_id )
-                                                       break;
-                                       }
-
-                                       if ( p ) {
-                                               LDAP_TAILQ_INSERT_BEFORE( p, pce, pc_link );
-                                       } else {
-                                               LDAP_TAILQ_INSERT_TAIL(
-                                                               &sop->o_ps_pre_candidates,
-                                                               pce, pc_link );
-                                       }
-                               }
-                               ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex );
-                       } else {
-                               rc = bdb_do_search( op, rs, sop, ps_e, ps_type );
-                               return rc;
-                       }
-               } else {
-                       pce = op->o_ps_send_wait;
-               }
-
-               /* Wait until refresh search send the entry */
-               while ( !pce->pc_sent ) {
-                       if ( sop->o_refresh_in_progress ) {
-                               if ( num_retries == BDB_PSEARCH_MAX_WAIT ) {
-                                       op->o_ps_send_wait = pce;
-                                       return LDAP_BUSY;
-                               }
-                               ldap_pvt_thread_yield();
-                               bdb_trans_backoff( ++num_retries );
-                       } else {
-                               break;
-                       }
-               }
-
-               op->o_ps_send_wait = NULL;
-
-               if ( !sop->o_refresh_in_progress && !pce->pc_sent ) {
-                       /* refresh ended without processing pce */
-                       /* need to perform psearch for ps_e */
-                       ldap_pvt_thread_mutex_lock( &sop->o_pcmutex );
-                       LDAP_TAILQ_REMOVE( &sop->o_ps_pre_candidates, pce, pc_link );
-                       ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex );
-                       ch_free( pce );
-                       rc = bdb_do_search( op, rs, sop, ps_e, ps_type );
-                       return rc;
-               } else {
-                       /* the pce entry was sent in the refresh phase */
-                       if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) {
-                               struct psid_entry* psid_e;
-                               psid_e = (struct psid_entry *) ch_calloc(1,
-                                                       sizeof(struct psid_entry));
-                               psid_e->ps_op = sop;
-                               LDAP_LIST_INSERT_HEAD( &op->o_pm_list, psid_e, ps_link );
-                       }
-
-                       ldap_pvt_thread_mutex_lock( &sop->o_pcmutex );
-                       LDAP_TAILQ_REMOVE( &sop->o_ps_pre_candidates, pce, pc_link );
-                       ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex );
-                       ch_free( pce );
-                       return LDAP_SUCCESS;
-               } 
-               break;
-       case LDAP_PSEARCH_BY_DELETE:
-       case LDAP_PSEARCH_BY_SCOPEOUT:
-       case LDAP_PSEARCH_BY_ADD:
-       case LDAP_PSEARCH_BY_MODIFY:
-               ldap_pvt_thread_mutex_lock( &op->o_pcmutex );
-               if ( sop->o_refresh_in_progress ||
-                               !LDAP_TAILQ_EMPTY( &sop->o_ps_post_candidates )) {
-                       pce = (struct pc_entry *) ch_calloc( 1, sizeof( struct pc_entry ));
-                       pce->pc_id = ps_e->e_id;
-                       ber_dupbv( &pce->pc_csn, &op->o_sync_csn );
-                       if ( ps_type == LDAP_PSEARCH_BY_DELETE ) {
-                               Attribute *a;
-                               for ( a = ps_e->e_attrs; a != NULL; a = a->a_next ) {
-                                       AttributeDescription *desc = a->a_desc;
-                                       if ( desc == slap_schema.si_ad_entryUUID ) {
-                                               ber_dupbv( &pce->pc_entryUUID, &a->a_nvals[0] );
-                                       }
-                               }
-                       }       
-                       ber_dupbv( &pce->pc_ename, &ps_e->e_name ); 
-                       ber_dupbv( &pce->pc_enname, &ps_e->e_nname ); 
-                       LDAP_TAILQ_INSERT_TAIL( &sop->o_ps_post_candidates, pce, pc_link );
-                       ldap_pvt_thread_mutex_unlock( &op->o_pcmutex );
-               } else {
-                       ldap_pvt_thread_mutex_unlock( &op->o_pcmutex );
-                       rc = bdb_do_search( op, rs, sop, ps_e, ps_type );
-                       return rc;
-               }
-               break;
-       default:
-               Debug( LDAP_DEBUG_TRACE, "do_psearch: invalid psearch type\n",
-                               0, 0, 0 );
-               return LDAP_OTHER;
-       }
-}
-#else
-int bdb_search( Operation *op, SlapReply *rs )
-{
-       return bdb_do_search( op, rs, op, NULL, 0 );
-}
-#endif
-
-/* For persistent searches, op is the currently executing operation,
- * sop is the persistent search. For regular searches, sop = op.
- */
-int
-bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
-       Entry *ps_e, int ps_type )
+bdb_search( Operation *op, SlapReply *rs )
 {
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        time_t          stoptime;
@@ -620,6 +313,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
        Entry           *matched = NULL;
        EntryInfo       *ei, ei_root = {0};
        struct berval   realbase = BER_BVNULL;
+       slap_mask_t     mask;
        int             manageDSAit;
        int             tentries = 0;
        ID              lastid = NOID;
@@ -630,136 +324,12 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
        struct  bdb_op_info     *opinfo = NULL;
        DB_TXN                  *ltid = NULL;
 
-#ifdef BDB_PSEARCH
-       Filter          contextcsnand, contextcsnle, cookief, csnfnot,
-                       csnfeq, csnfand, csnfge;
-       AttributeAssertion aa_ge, aa_eq, aa_le;
-       struct berval   *search_context_csn = NULL;
-       DB_LOCK         ctxcsn_lock;
-       LDAPControl     *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
-       int             num_ctrls = 0;
-       AttributeName   uuid_attr[2];
-       int             rc_sync = 0;
-       int             entry_sync_state = -1;
-       AttributeName   null_attr;
-       int             no_sync_state_change = 0;
-
-
-       Operation       *ps_list;
-       int                     sync_send_present_mode = 1;
-       int                     match;
-       MatchingRule *mr;
-       const char *text;
-       int                     slog_found = 0;
-
-       struct pc_entry *pce = NULL;
-       BerVarray       syncUUID_set = NULL;
-       int                     syncUUID_set_cnt = 0;
-
-#endif
-
        Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_search) "\n", 0, 0, 0);
-       attrs = sop->oq_search.rs_attrs;
+       attrs = op->oq_search.rs_attrs;
 
        opinfo = (struct bdb_op_info *) op->o_private;
 
-#ifdef BDB_PSEARCH
-       if ( !IS_POST_SEARCH && !IS_PSEARCH &&
-                       sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST ) {
-               struct slap_session_entry *sent;
-               if ( sop->o_sync_state.sid >= 0 ) {
-                       LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) {
-                               if ( sent->se_id == sop->o_sync_state.sid ) {
-                                       sop->o_sync_slog_size = sent->se_size;
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       /* psearch needs to be registered before refresh begins */
-       if ( !IS_POST_SEARCH && !IS_PSEARCH &&
-                       sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
-               sop->o_refresh_in_progress = 1;
-               ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-               LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link );
-               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-
-       } else if ( !IS_POST_SEARCH && !IS_PSEARCH &&
-                               sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST
-                               && sop->o_sync_slog_size >= 0 )
-       {
-               ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
-               LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                       if ( ps_list->o_sync_slog_size >= 0 ) {
-                               if ( ps_list->o_sync_state.sid == sop->o_sync_state.sid ) {
-                                       slog_found = 1;
-                                       break;
-                               }
-                       }
-               }
-
-               if ( slog_found ) {
-                       if ( ps_list->o_sync_slog_omitcsn.bv_len != 0 ) {
-                               mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering;
-                               if ( sop->o_sync_state.ctxcsn &&
-                                       sop->o_sync_state.ctxcsn->bv_val != NULL )
-                               {
-                                       value_match( &match, slap_schema.si_ad_entryCSN, mr,
-                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                               sop->o_sync_state.ctxcsn,
-                                               &ps_list->o_sync_slog_omitcsn,
-                                               &text );
-                               } else {
-                                       match = -1;
-                               }
-                               if ( match >= 0 ) {
-                                       sync_send_present_mode = 0;
-                               }
-                       } else {
-                               sync_send_present_mode = 0;
-                       }
-               } else if ( sop->o_sync_slog_size >= 0 ) {
-                       LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link );
-               } else {
-                       sop->o_sync_state.sid = -1;
-               }
-               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
-       }
-
-       null_attr.an_desc = NULL;
-       null_attr.an_oc = NULL;
-       null_attr.an_oc_exclude = 0;
-       BER_BVZERO( &null_attr.an_name );
-
-       for( num_ctrls = 0; num_ctrls < SLAP_MAX_RESPONSE_CONTROLS; num_ctrls++ ) {
-               ctrls[num_ctrls] = NULL;
-       }
-       num_ctrls = 0;
-
-       if ( IS_PSEARCH && IS_BDB_REPLACE(ps_type)) {
-               attrs = uuid_attr;
-               attrs[0].an_desc = NULL;
-               attrs[0].an_oc = NULL;
-               attrs[0].an_oc_exclude = 0;
-               BER_BVZERO( &attrs[0].an_name );
-       }
-#endif
-
-       manageDSAit = get_manageDSAit( sop );
-
-#ifdef BDB_PSEARCH
-       /* Sync control overrides manageDSAit */
-       if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-               if ( manageDSAit == SLAP_CONTROL_NONE ) {
-                       manageDSAit = SLAP_CONTROL_CRITICAL;
-               }
-       } else if ( IS_PSEARCH ) {
-               if ( manageDSAit == SLAP_CONTROL_NONE ) {
-                       manageDSAit = SLAP_CONTROL_CRITICAL;
-               }
-       }
-#endif
+       manageDSAit = get_manageDSAit( op );
 
        if ( opinfo && opinfo->boi_txn ) {
                ltid = opinfo->boi_txn;
@@ -771,22 +341,12 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
                case 0:
                        break;
                default:
-                       send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
+                       send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
                        return rs->sr_err;
                }
        }
 
-#ifdef BDB_PSEARCH
-       if ( IS_POST_SEARCH ) {
-               cursor = 0;
-               candidates[0] = 1;
-               candidates[1] = op->ors_post_search_id;
-               search_context_csn = ber_dupbv( NULL, &op->o_sync_csn );        
-               goto loop_start;
-       }
-#endif
-
-       if ( sop->o_req_ndn.bv_len == 0 ) {
+       if ( op->o_req_ndn.bv_len == 0 ) {
                /* DIT root special case */
                ei_root.bei_e = &e_root;
                ei_root.bei_parent = &ei_root;
@@ -799,7 +359,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
        } else {
 dn2entry_retry:
                /* get entry with reader lock */
-               rs->sr_err = bdb_dn2entry( op, ltid, &sop->o_req_ndn, &ei,
+               rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei,
                        1, locker, &lock );
        }
 
@@ -811,7 +371,7 @@ dn2entry_retry:
                e = ei->bei_e;
                break;
        case LDAP_BUSY:
-               send_ldap_error( sop, rs, LDAP_BUSY, "ldap server busy" );
+               send_ldap_error( op, rs, LDAP_BUSY, "ldap server busy" );
                if ( !opinfo )
                        LOCK_ID_FREE (bdb->bi_dbenv, locker );
                return LDAP_BUSY;
@@ -819,7 +379,7 @@ dn2entry_retry:
        case DB_LOCK_NOTGRANTED:
                goto dn2entry_retry;
        default:
-               send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
+               send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
                if ( !opinfo )
                        LOCK_ID_FREE (bdb->bi_dbenv, locker );
                return rs->sr_err;
@@ -835,12 +395,28 @@ dn2entry_retry:
                struct berval matched_dn = BER_BVNULL;
 
                if ( matched != NULL ) {
-                       BerVarray erefs;
-                       ber_dupbv( &matched_dn, &matched->e_name );
+                       BerVarray erefs = NULL;
+
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+                       /* return referral only if "disclose"
+                        * is granted on the object */
+                       if ( ! access_allowed( op, matched,
+                                               slap_schema.si_ad_entry,
+                                               NULL, ACL_DISCLOSE, NULL ) )
+                       {
+                               rs->sr_err = LDAP_NO_SUCH_OBJECT;
 
-                       erefs = is_entry_referral( matched )
-                               ? get_entry_referrals( op, matched )
-                               : NULL;
+                       } else
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+                       {
+                               ber_dupbv( &matched_dn, &matched->e_name );
+
+                               erefs = is_entry_referral( matched )
+                                       ? get_entry_referrals( op, matched )
+                                       : NULL;
+                               rs->sr_err = LDAP_REFERRAL;
+                               rs->sr_matched = matched_dn.bv_val;
+                       }
 
 #ifdef SLAP_ZONE_ALLOC
                        slap_zn_runlock(bdb->bi_cache.c_zctx, matched);
@@ -849,9 +425,9 @@ dn2entry_retry:
                                matched, &lock);
                        matched = NULL;
 
-                       if( erefs ) {
+                       if ( erefs ) {
                                rs->sr_ref = referral_rewrite( erefs, &matched_dn,
-                                       &sop->o_req_dn, sop->oq_search.rs_scope );
+                                       &op->o_req_dn, op->oq_search.rs_scope );
                                ber_bvarray_free( erefs );
                        }
 
@@ -860,12 +436,11 @@ dn2entry_retry:
                        slap_zn_runlock(bdb->bi_cache.c_zctx, matched);
 #endif
                        rs->sr_ref = referral_rewrite( default_referral,
-                               NULL, &sop->o_req_dn, sop->oq_search.rs_scope );
+                               NULL, &op->o_req_dn, op->oq_search.rs_scope );
+                       rs->sr_err = LDAP_REFERRAL;
                }
 
-               rs->sr_err = LDAP_REFERRAL;
-               rs->sr_matched = matched_dn.bv_val;
-               send_ldap_result( sop, rs );
+               send_ldap_result( op, rs );
 
                if ( !opinfo )
                        LOCK_ID_FREE (bdb->bi_dbenv, locker );
@@ -873,44 +448,72 @@ dn2entry_retry:
                        ber_bvarray_free( rs->sr_ref );
                        rs->sr_ref = NULL;
                }
-               if ( matched_dn.bv_val ) {
+               if ( !BER_BVISNULL( &matched_dn ) ) {
                        ber_memfree( matched_dn.bv_val );
                        rs->sr_matched = NULL;
                }
                return rs->sr_err;
        }
 
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       /* NOTE: __NEW__ "search" access is required
+        * on searchBase object */
+       if ( ! access_allowed_mask( op, e, slap_schema.si_ad_entry,
+                               NULL, ACL_SEARCH, NULL, &mask ) )
+       {
+               if ( !ACL_GRANT( mask, ACL_DISCLOSE ) ) {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+               } else {
+                       rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               }
+
+#ifdef SLAP_ZONE_ALLOC
+               slap_zn_runlock(bdb->bi_cache.c_zctx, e);
+#endif
+               if ( e != &e_root ) {
+                       bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+               }
+               send_ldap_result( op, rs );
+               return 1;
+       }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
        if ( !manageDSAit && e != &e_root && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
-               struct berval matched_dn;
-               BerVarray erefs;
+               struct berval matched_dn = BER_BVNULL;
+               BerVarray erefs = NULL;
                
                ber_dupbv( &matched_dn, &e->e_name );
                erefs = get_entry_referrals( op, e );
 
+               rs->sr_err = LDAP_REFERRAL;
+
 #ifdef SLAP_ZONE_ALLOC
                slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
                bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
                e = NULL;
 
-               if( erefs ) {
+               if ( erefs ) {
                        rs->sr_ref = referral_rewrite( erefs, &matched_dn,
-                               &sop->o_req_dn, sop->oq_search.rs_scope );
+                               &op->o_req_dn, op->oq_search.rs_scope );
                        ber_bvarray_free( erefs );
+
+                       if ( !rs->sr_ref ) {
+                               rs->sr_text = "bad_referral object";
+                       }
                }
 
                Debug( LDAP_DEBUG_TRACE,
                        LDAP_XSTRING(bdb_search) ": entry is referral\n",
                        0, 0, 0 );
 
-               if (!rs->sr_ref) rs->sr_text = "bad_referral object";
-               rs->sr_err = LDAP_REFERRAL;
                rs->sr_matched = matched_dn.bv_val;
-               send_ldap_result( sop, rs );
+               send_ldap_result( op, rs );
 
-               if ( !opinfo )
+               if ( !opinfo ) {
                        LOCK_ID_FREE (bdb->bi_dbenv, locker );
+               }
                ber_bvarray_free( rs->sr_ref );
                rs->sr_ref = NULL;
                ber_memfree( matched_dn.bv_val );
@@ -925,12 +528,15 @@ dn2entry_retry:
 #ifdef SLAP_ZONE_ALLOC
                slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
-               send_ldap_result( sop, rs );
+               if ( e != &e_root ) {
+                       bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+               }
+               send_ldap_result( op, rs );
                return 1;
        }
 
        /* compute it anyway; root does not use it */
-       stoptime = op->o_time + sop->ors_tlimit;
+       stoptime = op->o_time + op->ors_tlimit;
 
        /* need normalized dn below */
        ber_dupbv( &realbase, &e->e_nname );
@@ -950,68 +556,20 @@ dn2entry_retry:
        }
        e = NULL;
 
-#ifdef BDB_PSEARCH
-       if ( !IS_PSEARCH ) {
-               rs->sr_err = bdb_get_commit_csn( sop, rs, &search_context_csn,
-                       locker, &ctxcsn_lock );
-
-               if ( rs->sr_err != LDAP_SUCCESS ) {
-                       send_ldap_error( sop, rs, rs->sr_err,
-                               "error in csn management in search" );
-                       goto done;
-               }
-
-               if ( sop->o_sync_mode != SLAP_SYNC_NONE &&
-                       sop->o_sync_state.ctxcsn &&
-                       sop->o_sync_state.ctxcsn->bv_val &&
-                       ber_bvcmp( &sop->o_sync_state.ctxcsn[0], search_context_csn ) == 0 )
-               {
-                       bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock );
-                       goto nochange;
-               }
-       } else {
-               search_context_csn = ber_dupbv( NULL, &op->o_sync_csn );        
-       }
-#endif
-
        /* select candidates */
-       if ( sop->oq_search.rs_scope == LDAP_SCOPE_BASE ) {
+       if ( op->oq_search.rs_scope == LDAP_SCOPE_BASE ) {
                rs->sr_err = base_candidate( op->o_bd, &base, candidates );
 
        } else {
                BDB_IDL_ZERO( candidates );
                BDB_IDL_ZERO( scopes );
-               rs->sr_err = search_candidates( op, sop, rs, &base,
+               rs->sr_err = search_candidates( op, rs, &base,
                        locker, candidates, scopes );
        }
 
-#ifdef BDB_PSEARCH
-       if ( !IS_PSEARCH && sop->o_sync_mode != SLAP_SYNC_NONE ) {
-               bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock );
-       }
-#endif
-
        /* start cursor at beginning of candidates.
         */
        cursor = 0;
-#ifdef BDB_PSEARCH
-       if (IS_PSEARCH) {
-               if ( !BDB_IDL_IS_RANGE( candidates ) ) {
-                       cursor = bdb_idl_search( candidates, ps_e->e_id );
-                       if ( candidates[cursor] != ps_e->e_id ) {
-                               rs->sr_err = LDAP_SUCCESS;
-                               goto done;
-                       }
-               } else if ( ps_e->e_id < BDB_IDL_RANGE_FIRST( candidates ) ||
-                       ps_e->e_id > BDB_IDL_RANGE_LAST( candidates ))
-               {
-                       rs->sr_err = LDAP_SUCCESS;
-                       goto done;
-               }
-               candidates[0] = 1;
-               candidates[1] = ps_e->e_id;
-       }
-#endif
 
        if ( candidates[0] == 0 ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -1022,28 +580,28 @@ dn2entry_retry:
        }
 
        /* if not root and candidates exceed to-be-checked entries, abort */
-       if ( sop->ors_limit     /* isroot == FALSE */ &&
-               sop->ors_limit->lms_s_unchecked != -1 &&
-               BDB_IDL_N(candidates) > (unsigned) sop->ors_limit->lms_s_unchecked )
+       if ( op->ors_limit      /* isroot == FALSE */ &&
+               op->ors_limit->lms_s_unchecked != -1 &&
+               BDB_IDL_N(candidates) > (unsigned) op->ors_limit->lms_s_unchecked )
        {
                rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
-               send_ldap_result( sop, rs );
+               send_ldap_result( op, rs );
                rs->sr_err = LDAP_SUCCESS;
                goto done;
        }
 
-       if ( sop->ors_limit == NULL     /* isroot == TRUE */ ||
-               !sop->ors_limit->lms_s_pr_hide )
+       if ( op->ors_limit == NULL      /* isroot == TRUE */ ||
+               !op->ors_limit->lms_s_pr_hide )
        {
                tentries = BDB_IDL_N(candidates);
        }
 
-       if ( get_pagedresults( sop ) > SLAP_CONTROL_IGNORED ) {
-               PagedResultsState *ps = sop->o_pagedresults_state;
+       if ( get_pagedresults( op ) > SLAP_CONTROL_IGNORED ) {
+               PagedResultsState *ps = op->o_pagedresults_state;
                /* deferred cookie parsing */
-               rs->sr_err = parse_paged_cookie( sop, rs );
+               rs->sr_err = parse_paged_cookie( op, rs );
                if ( rs->sr_err != LDAP_SUCCESS ) {
-                       send_ldap_result( sop, rs );
+                       send_ldap_result( op, rs );
                        goto done;
                }
 
@@ -1054,7 +612,7 @@ dn2entry_retry:
                        if ( ps->ps_size == 0 ) {
                                rs->sr_err = LDAP_SUCCESS;
                                rs->sr_text = "search abandoned by pagedResult size=0";
-                               send_ldap_result( sop, rs );
+                               send_ldap_result( op, rs );
                                goto done;
                        }
                        for ( id = bdb_idl_first( candidates, &cursor );
@@ -1071,7 +629,7 @@ dn2entry_retry:
                                LDAP_XSTRING(bdb_search)
                                ": no paged results candidates\n",
                                0, 0, 0 );
-                       send_paged_response( sop, rs, &lastid, 0 );
+                       send_paged_response( op, rs, &lastid, 0 );
 
                        rs->sr_err = LDAP_OTHER;
                        goto done;
@@ -1079,172 +637,33 @@ dn2entry_retry:
                goto loop_begin;
        }
 
-#ifdef BDB_PSEARCH
-       if (( sop->o_sync_mode & SLAP_SYNC_REFRESH ) || IS_PSEARCH ) {
-               int match;
-
-               cookief.f_choice = LDAP_FILTER_AND;
-               cookief.f_and = &csnfnot;
-               cookief.f_next = NULL;
-
-               csnfnot.f_choice = LDAP_FILTER_NOT;
-               csnfnot.f_not = &csnfeq;
-               csnfnot.f_next = &csnfand;
-
-               csnfeq.f_choice = LDAP_FILTER_EQUALITY;
-               csnfeq.f_ava = &aa_eq;
-               csnfeq.f_av_desc = slap_schema.si_ad_entryCSN;
-               if ( sop->o_sync_state.ctxcsn != NULL ) {
-                       csnfeq.f_av_value = *sop->o_sync_state.ctxcsn;
-               } else {
-                       csnfeq.f_av_value = slap_empty_bv;
-               }
-
-               csnfand.f_choice = LDAP_FILTER_AND;
-               csnfand.f_and = &csnfge;
-               csnfand.f_next = NULL;
-
-               csnfge.f_choice = LDAP_FILTER_GE;
-               csnfge.f_ava = &aa_ge;
-               csnfge.f_av_desc = slap_schema.si_ad_entryCSN;
-               if ( sop->o_sync_state.ctxcsn != NULL ) {
-                       csnfge.f_av_value = *sop->o_sync_state.ctxcsn;
-               } else {
-                       csnfge.f_av_value = slap_empty_bv;
-               }
-
-               if ( search_context_csn && !IS_PSEARCH ) {
-                       csnfge.f_next = &contextcsnand;
-
-                       contextcsnand.f_choice = LDAP_FILTER_AND;
-                       contextcsnand.f_and = &contextcsnle;
-                       contextcsnand.f_next = NULL;
-       
-                       contextcsnle.f_choice = LDAP_FILTER_LE;
-                       contextcsnle.f_ava = &aa_le;
-                       contextcsnle.f_av_desc = slap_schema.si_ad_entryCSN;
-                       contextcsnle.f_av_value = *search_context_csn;
-                       contextcsnle.f_next = sop->oq_search.rs_filter;
-
-                       mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering;
-                       if ( sop->o_sync_state.ctxcsn &&
-                               sop->o_sync_state.ctxcsn->bv_val != NULL )
-                       {
-                               value_match( &match, slap_schema.si_ad_entryCSN, mr,
-                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                               &sop->o_sync_state.ctxcsn[0], search_context_csn,
-                                               &text );
-                       } else {
-                               match = -1;
-                       }
-                       no_sync_state_change = ( match >= 0 );
-               } else {
-                       csnfge.f_next = sop->oq_search.rs_filter;
-               }
-       }
-#endif
-
 loop_start:
 
        for ( id = bdb_idl_first( candidates, &cursor );
-                 id != NOID
-#ifdef BDB_PSEARCH
-                       && !no_sync_state_change
-#endif
-               ; id = bdb_idl_next( candidates, &cursor ) )
+                 id != NOID ; id = bdb_idl_next( candidates, &cursor ) )
        {
                int scopeok = 0;
                ID* idhole = NULL;
 
 loop_begin:
 
-#ifdef BDB_PSEARCH
-               if ( !IS_POST_SEARCH ) {
-                       idhole = (ID*) avl_find( sop->o_psearch_finished,
-                                                                        (caddr_t)&id, bdb_pfid_cmp );
-                       if ( idhole ) {
-                               avl_delete( &sop->o_psearch_finished,
-                                                       (caddr_t)idhole, bdb_pfid_cmp );
-                               sop->o_tmpfree( idhole, sop->o_tmpmemctx );
-                               goto loop_continue;
-                       }
-
-                       if ( sop->o_refresh_in_progress ) {
-                               ldap_pvt_thread_mutex_lock( &sop->o_pcmutex );
-                               pce = LDAP_TAILQ_FIRST( &sop->o_ps_pre_candidates );    
-                               while ( pce && pce->pc_sent ) {
-                                       pce = LDAP_TAILQ_NEXT( pce, pc_link );
-                               }
-                               ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex );
-                               if ( pce ) {
-                                       ID pos;
-                                       if ( BDB_IDL_IS_RANGE( candidates ) ) {
-                                               if ( pce->pc_id >= candidates[1] &&
-                                                        pce->pc_id <= candidates[2] &&
-                                                        pce->pc_id > cursor-1 ) {
-                                                       id = pce->pc_id;
-                                                       cursor--;
-                                                       avl_insert( &sop->o_psearch_finished,
-                                                                               (caddr_t)bdb_id_dup( sop, &pce->pc_id ),
-                                                                               bdb_pfid_cmp, avl_dup_error );
-                                               } else {
-                                                       pce->pc_sent = 1;
-                                               }
-                                       } else {
-                                               pos = bdb_idl_search(candidates, pce->pc_id);
-                                               if ( pos > cursor-1 && pos <= candidates[0] ) {
-                                                       id = pce->pc_id;
-                                                       cursor--;
-                                                       avl_insert( &sop->o_psearch_finished,
-                                                                               (caddr_t)bdb_id_dup( sop, &pce->pc_id ),
-                                                                               bdb_pfid_cmp, avl_dup_error );
-                                               } else {
-                                                       pce->pc_sent = 1;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               /* check for abandon */
-               if ( sop->o_abandon ) {
-                       if ( sop != op ) {
-                               bdb_drop_psearch( sop, sop->o_msgid );
-                       }
-                       rs->sr_err = LDAP_SUCCESS;
-                       goto done;
-               }
-
-               if ( sop->o_cancel ) {
-                       assert( sop->o_cancel == SLAP_CANCEL_REQ );
-                       rs->sr_err = LDAP_CANCELLED;
-                       send_ldap_result( sop, rs );
-                       sop->o_cancel = SLAP_CANCEL_ACK;
-                       rs->sr_err = LDAP_SUCCESS;
-                       goto done;
-               }
-#else
                /* check for abandon */
-               if ( sop->o_abandon ) {
+               if ( op->o_abandon ) {
                        rs->sr_err = LDAP_SUCCESS;
                        goto done;
                }
-#endif
 
                /* check time limit */
-               if ( sop->ors_tlimit != SLAP_NO_LIMIT
+               if ( op->ors_tlimit != SLAP_NO_LIMIT
                                && slap_get_time() > stoptime )
                {
                        rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
                        rs->sr_ref = rs->sr_v2ref;
-                       send_ldap_result( sop, rs );
+                       send_ldap_result( op, rs );
                        rs->sr_err = LDAP_SUCCESS;
                        goto done;
                }
 
-#ifdef BDB_PSEARCH
-               if (!IS_PSEARCH) {
-#endif
 fetch_entry_retry:
                        /* get the entry with reader lock */
                        ei = NULL;
@@ -1253,7 +672,7 @@ fetch_entry_retry:
 
                        if (rs->sr_err == LDAP_BUSY) {
                                rs->sr_text = "ldap server busy";
-                               send_ldap_result( sop, rs );
+                               send_ldap_result( op, rs );
                                goto done;
 
                        } else if ( rs->sr_err == DB_LOCK_DEADLOCK
@@ -1269,13 +688,6 @@ fetch_entry_retry:
                        }
 
                        if ( e == NULL ) {
-#ifdef BDB_PSEARCH
-                               if ( IS_POST_SEARCH ) {
-                                       /* send LDAP_SYNC_DELETE */
-                                       rs->sr_entry = e = ps_e;
-                                       goto post_search_no_entry;
-                               } else
-#endif
                                if( !BDB_IDL_IS_RANGE(candidates) ) {
                                        /* only complain for non-range IDLs */
                                        Debug( LDAP_DEBUG_TRACE,
@@ -1286,35 +698,26 @@ fetch_entry_retry:
 
                                goto loop_continue;
                        }
-#ifdef BDB_PSEARCH
-               } else {
-                       e = ps_e;
-               }
-#endif
 
                rs->sr_entry = e;
 
 #ifdef BDB_SUBENTRIES
-               /* FIXME: send all but syncrepl */
-#if 0
-               if ( !is_sync_protocol( sop ) )
-#endif
                {
                        if ( is_entry_subentry( e ) ) {
-                               if( sop->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
-                                       if(!get_subentries_visibility( sop )) {
+                               if( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
+                                       if(!get_subentries_visibility( op )) {
                                                /* only subentries are visible */
                                                goto loop_continue;
                                        }
 
-                               } else if ( get_subentries( sop ) &&
-                                       !get_subentries_visibility( sop ))
+                               } else if ( get_subentries( op ) &&
+                                       !get_subentries_visibility( op ))
                                {
                                        /* only subentries are visible */
                                        goto loop_continue;
                                }
 
-                       } else if ( get_subentries_visibility( sop )) {
+                       } else if ( get_subentries_visibility( op )) {
                                /* only subentries are visible */
                                goto loop_continue;
                        }
@@ -1330,7 +733,7 @@ fetch_entry_retry:
                 * scope while we are looking at it, and unless we're using
                 * BDB_HIER, its parents cannot be moved either.
                 */
-               switch( sop->ors_scope ) {
+               switch( op->ors_scope ) {
                case LDAP_SCOPE_BASE:
                        /* This is always true, yes? */
                        if ( id == base.e_id ) scopeok = 1;
@@ -1357,12 +760,12 @@ fetch_entry_retry:
                }
 
                /* aliases were already dereferenced in candidate list */
-               if ( sop->ors_deref & LDAP_DEREF_SEARCHING ) {
+               if ( op->ors_deref & LDAP_DEREF_SEARCHING ) {
                        /* but if the search base is an alias, and we didn't
                         * deref it when finding, return it.
                         */
                        if ( is_entry_alias(e) &&
-                               ((sop->ors_deref & LDAP_DEREF_FINDING) ||
+                               ((op->ors_deref & LDAP_DEREF_FINDING) ||
                                        !bvmatch(&e->e_nname, &op->o_req_ndn)))
                        {
                                goto loop_continue;
@@ -1371,7 +774,7 @@ fetch_entry_retry:
                        /* scopes is only non-empty for onelevel or subtree */
                        if ( !scopeok && BDB_IDL_N(scopes) ) {
                                unsigned x;
-                               if ( sop->ors_scope == LDAP_SCOPE_ONELEVEL ) {
+                               if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
                                        x = bdb_idl_search( scopes, e->e_id );
                                        if ( scopes[x] == e->e_id ) scopeok = 1;
                                } else {
@@ -1389,11 +792,7 @@ fetch_entry_retry:
                }
 
                /* Not in scope, ignore it */
-#ifdef BDB_PSEARCH
-               if ( !IS_POST_SEARCH && !scopeok )
-#else
                if ( !scopeok )
-#endif
                {
                        Debug( LDAP_DEBUG_TRACE,
                                LDAP_XSTRING(bdb_search)
@@ -1407,15 +806,15 @@ fetch_entry_retry:
                 * this for non-base searches, and don't check the filter
                 * explicitly here since it's only a candidate anyway.
                 */
-               if ( !manageDSAit && sop->oq_search.rs_scope != LDAP_SCOPE_BASE
+               if ( !manageDSAit && op->oq_search.rs_scope != LDAP_SCOPE_BASE
                        && is_entry_referral( e ) )
                {
-                       BerVarray erefs = get_entry_referrals( sop, e );
+                       BerVarray erefs = get_entry_referrals( op, e );
                        rs->sr_ref = referral_rewrite( erefs, &e->e_name, NULL,
-                               sop->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL
+                               op->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL
                                        ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE );
 
-                       send_search_reference( sop, rs );
+                       send_search_reference( op, rs );
 
                        ber_bvarray_free( rs->sr_ref );
                        ber_bvarray_free( erefs );
@@ -1429,84 +828,28 @@ fetch_entry_retry:
                }
 
                /* if it matches the filter and scope, send it */
-#ifndef BDB_PSEARCH
-               rs->sr_err = test_filter( sop, rs->sr_entry, sop->oq_search.rs_filter );
-#else
-               if (IS_PSEARCH) {
-                       if (ps_type != LDAP_PSEARCH_BY_SCOPEOUT) {
-                               rs->sr_err = test_filter( sop, rs->sr_entry, &cookief );
-                       } else {
-                               rs->sr_err = LDAP_COMPARE_TRUE;
-                       }
-
-               } else {
-                       if ( !IS_POST_SEARCH ) {
-                               if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-                                       rc_sync = test_filter( sop, rs->sr_entry, &cookief );
-                                       rs->sr_err = test_filter( sop, rs->sr_entry,
-                                                                               &contextcsnand );
-                                       if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
-                                               if ( rc_sync == LDAP_COMPARE_TRUE ) {
-                                                       if ( no_sync_state_change ) {
-                                                               Debug( LDAP_DEBUG_TRACE,
-                                                                       LDAP_XSTRING(bdb_search) ": "
-                                                                       "error in context csn management\n",
-                                                                       0, 0, 0 );
-                                                       }
-                                                       entry_sync_state = LDAP_SYNC_ADD;
-
-                                               } else {
-                                                       if ( no_sync_state_change ) {
-                                                               goto loop_continue;
-                                                       }
-                                                       entry_sync_state = LDAP_SYNC_PRESENT;
-                                               }
-                                       }
-                               } else {
-                                       rs->sr_err = test_filter( sop,
-                                               rs->sr_entry, sop->oq_search.rs_filter );
-                               }
-                       } else {
-                               if ( scopeok ) {
-                                       rs->sr_err = test_filter( sop,
-                                               rs->sr_entry, sop->oq_search.rs_filter );
-                               } else {
-                                       rs->sr_err = LDAP_COMPARE_TRUE;
-                               }
-                       }
-               }
-#endif
+               rs->sr_err = test_filter( op, rs->sr_entry, op->oq_search.rs_filter );
 
                if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
                        /* check size limit */
-                       if ( --sop->ors_slimit == -1
-#ifdef BDB_PSEARCH
-                               && sop->o_sync_slog_size == -1
-#endif
-                        ) {
-#ifdef BDB_PSEARCH
-                               if (!IS_PSEARCH) {
-#endif
+                       if ( --op->ors_slimit == -1) {
 #ifdef SLAP_ZONE_ALLOC
-                                       slap_zn_runlock(bdb->bi_cache.c_zctx, e);
+                               slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
-                                       bdb_cache_return_entry_r( bdb->bi_dbenv,
+                               bdb_cache_return_entry_r( bdb->bi_dbenv,
                                                &bdb->bi_cache, e, &lock );
-#ifdef BDB_PSEARCH
-                               }
-#endif
                                e = NULL;
                                rs->sr_entry = NULL;
                                rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
                                rs->sr_ref = rs->sr_v2ref;
-                               send_ldap_result( sop, rs );
+                               send_ldap_result( op, rs );
                                rs->sr_err = LDAP_SUCCESS;
                                goto done;
                        }
 
-                       if ( get_pagedresults(sop) > SLAP_CONTROL_IGNORED ) {
-                               if ( rs->sr_nentries >= ((PagedResultsState *)sop->o_pagedresults_state)->ps_size ) {
-                                       send_paged_response( sop, rs, &lastid, tentries );
+                       if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
+                               if ( rs->sr_nentries >= ((PagedResultsState *)op->o_pagedresults_state)->ps_size ) {
+                                       send_paged_response( op, rs, &lastid, tentries );
                                        goto done;
                                }
                                lastid = id;
@@ -1515,170 +858,12 @@ fetch_entry_retry:
                        if (e) {
                                /* safe default */
                                int result = -1;
-#ifdef BDB_PSEARCH
-                               if (IS_PSEARCH || IS_POST_SEARCH) {
-                                       int premodify_found = 0;
-
-                                       if ( IS_POST_SEARCH ||
-                                                ps_type == LDAP_PSEARCH_BY_ADD ||
-                                                ps_type == LDAP_PSEARCH_BY_DELETE ||
-                                                ps_type == LDAP_PSEARCH_BY_MODIFY ||
-                                                ps_type == LDAP_PSEARCH_BY_SCOPEOUT )
-                                       {
-                                               if ( !IS_POST_SEARCH &&
-                                                        ps_type == LDAP_PSEARCH_BY_MODIFY ) {
-                                                       struct psid_entry* psid_e;
-                                                       LDAP_LIST_FOREACH( psid_e,
-                                                               &op->o_pm_list, ps_link)
-                                                       {
-                                                               if( psid_e->ps_op == sop ) {
-                                                                       premodify_found = 1;
-                                                                       LDAP_LIST_REMOVE(psid_e, ps_link);
-                                                                       break;
-                                                               }
-                                                       }
-                                                       if (psid_e != NULL) free (psid_e);
-                                               }
-
-                                               if ( IS_POST_SEARCH ) {
-                                                       if ( scopeok ) {
-                                                               entry_sync_state = LDAP_SYNC_ADD;
-                                                       } else {
-post_search_no_entry:
-                                                               entry_sync_state = LDAP_SYNC_DELETE;
-                                                       }
-                                               } else if ( ps_type == LDAP_PSEARCH_BY_ADD ) {
-                                                       entry_sync_state = LDAP_SYNC_ADD;
-                                               } else if ( ps_type == LDAP_PSEARCH_BY_DELETE ) {
-                                                       entry_sync_state = LDAP_SYNC_DELETE;
-                                               } else if ( ps_type == LDAP_PSEARCH_BY_MODIFY ) {
-                                                       if ( premodify_found ) {
-                                                               entry_sync_state = LDAP_SYNC_MODIFY;
-                                                       } else {
-                                                               entry_sync_state = LDAP_SYNC_ADD;
-                                                       }
-                                               } else if ( ps_type == LDAP_PSEARCH_BY_SCOPEOUT ) {
-                                                       entry_sync_state = LDAP_SYNC_DELETE;
-                                               } else {
-                                                       rs->sr_err = LDAP_OTHER;
-                                                       goto done;
-                                               }
-
-                                               if ( sop->o_sync_slog_size != -1 ) {
-                                                       if ( entry_sync_state == LDAP_SYNC_DELETE ) {
-                                                               result = slap_add_session_log( op, sop, e );
-                                                       } else {
-                                                               result = 1;
-                                                       }
-                                               } else {
-                                                       struct berval cookie;
-                                                       slap_compose_sync_cookie( sop, &cookie,
-                                                               search_context_csn,
-                                                               sop->o_sync_state.sid,
-                                                               sop->o_sync_state.rid );
-                                                       rs->sr_err = slap_build_sync_state_ctrl(
-                                                               sop, rs, e, entry_sync_state, ctrls,
-                                                               num_ctrls++, 1, &cookie );
-                                                       if ( rs->sr_err != LDAP_SUCCESS ) goto done;
-                                                       if (!(IS_POST_SEARCH &&
-                                                               entry_sync_state == LDAP_SYNC_DELETE)) {
-                                                               rs->sr_attrs = attrs;
-                                                       } else {
-                                                               rs->sr_attrs = NULL;
-                                                       }
-                                                       rs->sr_operational_attrs = NULL;
-                                                       rs->sr_ctrls = ctrls;
-                                                       rs->sr_flags = 0;
-                                                       result = send_search_entry( sop, rs );
-                                                       if ( cookie.bv_val ) ch_free( cookie.bv_val );  
-                                                       slap_sl_free(
-                                                               ctrls[num_ctrls-1]->ldctl_value.bv_val,
-                                                               sop->o_tmpmemctx );
-                                                       slap_sl_free( ctrls[--num_ctrls],
-                                                               sop->o_tmpmemctx );
-                                                       ctrls[num_ctrls] = NULL;
-                                                       rs->sr_ctrls = NULL;
-                                               }
-
-                                       } else if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) {
-                                               struct psid_entry* psid_e;
-                                               psid_e = (struct psid_entry *) ch_calloc(1,
-                                                       sizeof(struct psid_entry));
-                                               psid_e->ps_op = sop;
-                                               LDAP_LIST_INSERT_HEAD( &op->o_pm_list,
-                                                       psid_e, ps_link );
-
-                                       } else {
-                                               Debug( LDAP_DEBUG_TRACE,
-                                                       LDAP_XSTRING(bdb_search)
-                                                       ": invalid ps_type (%d) \n",
-                                                       ps_type, 0, 0);
-                                       }
-
-                               } else {
-                                       if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-                                               if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */
-                                                       rs->sr_err = slap_build_sync_state_ctrl(
-                                                               sop, rs, e, entry_sync_state, ctrls,
-                                                               num_ctrls++, 0, NULL );
-                                                       if ( rs->sr_err != LDAP_SUCCESS ) goto done;
-                                                       rs->sr_ctrls = ctrls;
-                                                       rs->sr_attrs = sop->oq_search.rs_attrs;
-                                                       rs->sr_operational_attrs = NULL;
-                                                       rs->sr_flags = 0;
-                                                       result = send_search_entry( sop, rs );
-                                                       slap_sl_free(
-                                                               ctrls[num_ctrls-1]->ldctl_value.bv_val,
-                                                               sop->o_tmpmemctx );
-                                                       slap_sl_free( ctrls[--num_ctrls],
-                                                               sop->o_tmpmemctx );
-                                                       ctrls[num_ctrls] = NULL;
-                                                       rs->sr_ctrls = NULL;
-
-                                               } else { /* PRESENT */
-                                                       if ( sync_send_present_mode ) {
-                                                               result = slap_build_syncUUID_set( sop,
-                                                                       &syncUUID_set, e );
-                                                               if ( result <= 0 ) {
-                                                                       result = -1;    
-                                                               } else {
-                                                                       syncUUID_set_cnt++;
-                                                                       if ( syncUUID_set_cnt ==
-                                                                               SLAP_SYNCUUID_SET_SIZE )
-                                                                       {
-                                                                               rs->sr_err = LDAP_SUCCESS;
-                                                                               rs->sr_rspoid = LDAP_SYNC_INFO;
-                                                                               rs->sr_ctrls = NULL;
-                                                                               result = slap_send_syncinfo( sop, rs,
-                                                                                       LDAP_TAG_SYNC_ID_SET,
-                                                                                       NULL, 0, syncUUID_set, 0 );
-                                                                               if ( result != LDAP_SUCCESS ) {
-                                                                                       result = -1;
-                                                                               }
-                                                                               ber_bvarray_free_x( syncUUID_set,
-                                                                                       sop->o_tmpmemctx );
-                                                                               syncUUID_set = NULL;
-                                                                               syncUUID_set_cnt = 0;
-                                                                       }
-                                                               }
-
-                                                       } else {
-                                                               result = 1;
-                                                       }
-                                               }
-
-                                       } else {
-#endif
-                                               rs->sr_attrs = sop->oq_search.rs_attrs;
-                                               rs->sr_operational_attrs = NULL;
-                                               rs->sr_ctrls = NULL;
-                                               rs->sr_flags = 0;
-                                               rs->sr_err = LDAP_SUCCESS;
-                                               result = send_search_entry( sop, rs );
-#ifdef BDB_PSEARCH
-                                       }
-                               }
-#endif
+                               rs->sr_attrs = op->oq_search.rs_attrs;
+                               rs->sr_operational_attrs = NULL;
+                               rs->sr_ctrls = NULL;
+                               rs->sr_flags = 0;
+                               rs->sr_err = LDAP_SUCCESS;
+                               result = send_search_entry( op, rs );
 
                                switch (result) {
                                case 0:         /* entry sent ok */
@@ -1686,17 +871,11 @@ post_search_no_entry:
                                case 1:         /* entry not sent */
                                        break;
                                case -1:        /* connection closed */
-#ifdef BDB_PSEARCH
-                                       if (!IS_PSEARCH) {
-#endif
 #ifdef SLAP_ZONE_ALLOC
-                                               slap_zn_runlock(bdb->bi_cache.c_zctx, e);
-#endif
-                                               bdb_cache_return_entry_r(bdb->bi_dbenv,
-                                                       &bdb->bi_cache, e, &lock);
-#ifdef BDB_PSEARCH
-                                       }
+                                       slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
+                                       bdb_cache_return_entry_r(bdb->bi_dbenv,
+                                               &bdb->bi_cache, e, &lock);
                                        e = NULL;
                                        rs->sr_entry = NULL;
                                        rs->sr_err = LDAP_OTHER;
@@ -1714,194 +893,32 @@ post_search_no_entry:
 loop_continue:
                if( e != NULL ) {
                        /* free reader lock */
-#ifdef BDB_PSEARCH
-                       if (!IS_PSEARCH) {
-                               if (!(IS_POST_SEARCH &&
-                                                entry_sync_state == LDAP_SYNC_DELETE)) {
-#ifdef SLAP_ZONE_ALLOC
-                                       slap_zn_runlock(bdb->bi_cache.c_zctx, e);
-#endif
-                                       bdb_cache_return_entry_r( bdb->bi_dbenv,
-                                               &bdb->bi_cache, e , &lock );
-                                       if ( sop->o_nocaching ) {
-                                               bdb_cache_delete_entry( bdb, ei, locker, &lock );
-                                       }
-                               }
-                       }
-#else
 #ifdef SLAP_ZONE_ALLOC
                        slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
                        bdb_cache_return_entry_r( bdb->bi_dbenv,
                                &bdb->bi_cache, e , &lock );
-#endif
                        e = NULL;
                        rs->sr_entry = NULL;
                }
                
-#ifdef BDB_PSEARCH
-               if ( sop->o_refresh_in_progress ) {
-                       if ( pce ) {
-                               pce->pc_sent = 1;
-                       }
-               }
-#endif
-
                ldap_pvt_thread_yield();
        }
 
-#ifdef BDB_PSEARCH
-       if ( syncUUID_set_cnt > 0 ) {
-               rs->sr_err = LDAP_SUCCESS;
-               rs->sr_rspoid = LDAP_SYNC_INFO;
-               rs->sr_ctrls = NULL;
-               slap_send_syncinfo( sop, rs, LDAP_TAG_SYNC_ID_SET,
-                       NULL, 0, syncUUID_set, 0 );
-               ber_bvarray_free_x( syncUUID_set, sop->o_tmpmemctx );
-               syncUUID_set_cnt = 0;
-       }
-#endif
-
 nochange:
-#ifdef BDB_PSEARCH
-       if (!IS_PSEARCH && !IS_POST_SEARCH) {
-               if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-                       if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
-                               struct berval cookie;
-                               slap_compose_sync_cookie( sop, &cookie, search_context_csn,
-                                       sop->o_sync_state.sid, sop->o_sync_state.rid );
-
-                               if ( sync_send_present_mode ) {
-                                       rs->sr_err = LDAP_SUCCESS;
-                                       rs->sr_rspoid = LDAP_SYNC_INFO;
-                                       rs->sr_ctrls = NULL;
-                                       slap_send_syncinfo( sop, rs,
-                                               LDAP_TAG_SYNC_REFRESH_PRESENT, &cookie, 1, NULL, 0 );
-
-                               } else {
-                                       if ( !no_sync_state_change ) {
-                                               int slog_found = 0;
-                                               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
-                                               LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
-                                                       o_ps_link )
-                                               {
-                                                       if ( ps_list->o_sync_slog_size > 0 ) {
-                                                               if ( ps_list->o_sync_state.sid ==
-                                                                       sop->o_sync_state.sid )
-                                                               {
-                                                                       slog_found = 1;
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-               
-                                               if ( slog_found ) {
-                                                       rs->sr_err = LDAP_SUCCESS;
-                                                       rs->sr_rspoid = NULL;
-                                                       rs->sr_ctrls = NULL;
-                                                       slap_send_session_log( op, ps_list, rs );
-                                               }
-                                               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
-                                       }
-
-                                       rs->sr_err = LDAP_SUCCESS;
-                                       rs->sr_rspoid = LDAP_SYNC_INFO;
-                                       rs->sr_ctrls = NULL;
-                                       slap_send_syncinfo( sop, rs,
-                                               LDAP_TAG_SYNC_REFRESH_DELETE, &cookie, 1, NULL, 0 );
-                               }
-
-                               if ( cookie.bv_val ) ch_free( cookie.bv_val );
-
-                       } else {
-                               /* refreshOnly mode */
-                               struct berval cookie;
-                               slap_compose_sync_cookie( sop, &cookie, search_context_csn,
-                                       sop->o_sync_state.sid, sop->o_sync_state.rid );
-
-                               if ( sync_send_present_mode ) {
-                                       slap_build_sync_done_ctrl( sop, rs, ctrls,
-                                               num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_PRESENTS );
-
-                               } else {
-                                       if ( !no_sync_state_change ) {
-                                               int slog_found = 0;
-                                               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
-                                               LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
-                                                       o_ps_link )
-                                               {
-                                                       if ( ps_list->o_sync_slog_size > 0 ) {
-                                                               if ( ps_list->o_sync_state.sid ==
-                                                                               sop->o_sync_state.sid ) {
-                                                                       slog_found = 1;
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-               
-                                               if ( slog_found ) {
-                                                       slap_send_session_log( op, ps_list, rs );
-                                               }
-                                               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
-                                       }
-
-                                       slap_build_sync_done_ctrl( sop, rs, ctrls,
-                                               num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_DELETES );
-                               }
-
-                               rs->sr_ctrls = ctrls;
-                               rs->sr_ref = rs->sr_v2ref;
-                               rs->sr_err = (rs->sr_v2ref == NULL)
-                                       ? LDAP_SUCCESS : LDAP_REFERRAL;
-                               rs->sr_rspoid = NULL;
-                               send_ldap_result( sop, rs );
-                               if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) {
-                                       slap_sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
-                                               sop->o_tmpmemctx );
-                               }
-                               slap_sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
-                               ctrls[num_ctrls] = NULL;
-                               if ( cookie.bv_val ) ch_free( cookie.bv_val );  
-                       }
-
-               } else {
-#endif
-                       rs->sr_ctrls = NULL;
-                       rs->sr_ref = rs->sr_v2ref;
-                       rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
-                       rs->sr_rspoid = NULL;
-                       if ( get_pagedresults(sop) > SLAP_CONTROL_IGNORED ) {
-                               send_paged_response( sop, rs, NULL, 0 );
-                       } else {
-                               send_ldap_result( sop, rs );
-                       }
-#ifdef BDB_PSEARCH
-               }
-       }
-
-       if ( sop->o_refresh_in_progress ) {
-               sop->o_refresh_in_progress = 0;
+       rs->sr_ctrls = NULL;
+       rs->sr_ref = rs->sr_v2ref;
+       rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
+       rs->sr_rspoid = NULL;
+       if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
+               send_paged_response( op, rs, NULL, 0 );
+       } else {
+               send_ldap_result( op, rs );
        }
-#endif
 
        rs->sr_err = LDAP_SUCCESS;
 
 done:
-#ifdef BDB_PSEARCH
-       if ( sop->o_psearch_finished ) {
-               avl_free( sop->o_psearch_finished, ch_free );
-       }
-
-       if( !IS_PSEARCH && e != NULL ) {
-               /* free reader lock */
-#ifdef SLAP_ZONE_ALLOC
-               slap_zn_runlock(bdb->bi_cache.c_zctx, e);
-#endif
-               bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
-       }
-       ber_bvfree( search_context_csn );
-#endif
-
        if ( !opinfo )
                LOCK_ID_FREE( bdb->bi_dbenv, locker );
 
@@ -1994,7 +1011,6 @@ static void *search_stack( Operation *op )
 }
 
 static int search_candidates(
-       Operation *stackop,
        Operation *op,
        SlapReply *rs,
        Entry *e,
@@ -2031,11 +1047,7 @@ static int search_candidates(
         * these clauses are redundant.
         */
        if (!oc_filter(op->oq_search.rs_filter, 1, &depth)
-               && !get_subentries_visibility(op)
-#ifdef BDB_PSEARCH
-               && !is_sync_protocol(op)
-#endif
-       ) {
+               && !get_subentries_visibility(op)) {
                if( !get_manageDSAit(op) && !get_domainScope(op) ) {
                        /* match referral objects */
                        struct berval bv_ref = BER_BVC( "referral" );
@@ -2076,7 +1088,7 @@ static int search_candidates(
        if ( depth+1 > bdb->bi_search_stack_depth ) {
                stack = ch_malloc( (depth + 1) * BDB_IDL_UM_SIZE * sizeof( ID ) );
        } else {
-               stack = search_stack( stackop );
+               stack = search_stack( op );
        }
 
        if( op->ors_deref & LDAP_DEREF_SEARCHING ) {
index 033b0bd8bd6a350aee1e6ada2fb601ad00656b4f..f65d4b99d4b96edba4797c13104c88e24e0a8fc8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a18875ee146fc2a83689b04e72cb63eb9a292803..d5c3c66b9045ada8b1ea0ebc43d78968e6941822 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 214e9f70733a776699457484f8b2673be44798bd..54037046dcc1885bfe08280f97115a66d60a9d47 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## Portions Copyright 1998-2003 Kurt D. Zeilenga.
 ## All rights reserved.
 ##
index eb02774567e0615f56cef387d3151938563d87ba..a487d70e32438360d68d124035a411a720d04955 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 99f99de81e8f0c3593f400718155641a8dfc6c1c..1e057ecedfb3a7edf5233d5632ec09235d7a58f4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index c72a15b1c1df2b185d0045f8e7f6a5ac2123c538..5ba68ff34ebb2d77273d1c7a1f5a5c4f4df9fe59 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 097b4955699baaf3149c4b2d84892414a049cbef..e3f26d4aa0c4e4ab80e20d71bf3fb40061c18edd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 8aefa5fff32011ba5f88b49439272b234d337a20..700afe641a7a19a9fa6ef203917fd5c4b101571d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0e130de0b2f0bf1b25c4d2eaf1312838b1851c62..76b3372227c2da0b17e263d2b57b795078c9347b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 6970abe91ada97b71434ada5ba60eaba4fd43dbf..b191fca7fa523b0db4cc27e28ec52665c654963d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 99a37f55af1022c86c10e785a6846d94fa321dcc..e7fa1e7ec330d23aa30f663dc60f33d30bc6ae7e 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -21,13 +21,13 @@ XXSRCS = init.c tools.c config.c \
        add.c bind.c compare.c delete.c modify.c modrdn.c search.c \
        extended.c referral.c operational.c \
        attr.c index.c key.c dbcache.c filterindex.c trans.c \
-       dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c cache.c ctxcsn.c
+       dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c cache.c
 SRCS = $(XXSRCS)
 OBJS = init.lo tools.lo config.lo \
        add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \
        extended.lo referral.lo operational.lo \
        attr.lo index.lo key.lo dbcache.lo filterindex.lo trans.lo \
-       dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo cache.lo ctxcsn.lo
+       dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo cache.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index 33eb02296a6f0790f748cc975bf0eddd3df27e9d..e9961a4ebc093c3374f2bb9e51f4b4b988049fc0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Howard Chu @ Symas Corp.
  * All rights reserved.
  *
index cb52d04282e0897f5aaa39d137d168d4f2f562d1..8b05a86db8881cffbde6f4a3753097179659bf0a 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -14,9 +14,9 @@
 ## <http://www.OpenLDAP.org/license.html>.
 
 SRCS   = init.c config.c search.c bind.c unbind.c add.c compare.c \
-               delete.c modify.c modrdn.c extended.c
+               delete.c modify.c modrdn.c extended.c chain.c
 OBJS   = init.lo config.lo search.lo bind.lo unbind.lo add.lo compare.lo \
-               delete.lo modify.lo modrdn.lo extended.lo
+               delete.lo modify.lo modrdn.lo extended.lo chain.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index 3f4262a9fe370b9a9d67c2306fd4ff5204e5c649..1805a31b3e40429cca9ab5160bf4acb849ec7e62 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -58,7 +58,7 @@ ldap_back_add(
        }
 
        /* Count number of attributes in entry */
-       for (i = 1, a = op->oq_add.rs_e->e_attrs; a; i++, a = a->a_next)
+       for ( i = 1, a = op->oq_add.rs_e->e_attrs; a; i++, a = a->a_next )
                /* just count attrs */ ;
        
        /* Create array of LDAPMods for ldap_add() */
@@ -89,14 +89,12 @@ ldap_back_add(
        attrs[ i ] = NULL;
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                rc = -1;
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 retry:
        rs->sr_err = ldap_add_ext( lc->lc_ld, op->o_req_dn.bv_val, attrs,
@@ -110,9 +108,7 @@ retry:
        }
 
 cleanup:
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        if ( attrs ) {
                for ( --i; i >= 0; --i ) {
index 01a466a5be484d5fd6356ad43ab559b1e6ee1437..3f5b109d371bf53fdbb2d79ff7e0b88ce733586f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 #ifndef SLAPD_LDAP_H
 #define SLAPD_LDAP_H
 
-#include "proto-ldap.h"
-
-#ifdef LDAP_DEVEL
-#define LDAP_BACK_PROXY_AUTHZ
-#endif
-
 LDAP_BEGIN_DECL
 
 struct slap_conn;
@@ -71,7 +65,6 @@ struct ldapinfo {
 #define        acl_authcDN     acl_la.la_authcDN
 #define        acl_passwd      acl_la.la_passwd
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        /* ID assert stuff */
        int             idassert_mode;
 #define        LDAP_BACK_IDASSERT_LEGACY       0
@@ -95,7 +88,6 @@ struct ldapinfo {
        
        int             idassert_ppolicy;
        /* end of ID assert stuff */
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        ldap_pvt_thread_mutex_t         conn_mutex;
        int             savecred;
@@ -104,33 +96,8 @@ struct ldapinfo {
        int             rwm_started;
 };
 
-int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
-struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
-int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
-int ldap_back_retry(struct ldapconn *lc, Operation *op, SlapReply *rs);
-int ldap_back_map_result(SlapReply *rs);
-int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
-       ber_int_t msgid, int sendok);
-int    back_ldap_LTX_init_module(int argc, char *argv[]);
-
-extern int ldap_back_conn_cmp( const void *c1, const void *c2);
-extern int ldap_back_conn_dup( void *c1, void *c2 );
-extern void ldap_back_conn_free( void *c );
-
-#ifdef LDAP_BACK_PROXY_AUTHZ
-extern int
-ldap_back_proxy_authz_ctrl(
-               struct ldapconn *lc,
-               Operation       *op,
-               SlapReply       *rs,
-               LDAPControl     ***pctrls );
-
-extern int
-ldap_back_proxy_authz_ctrl_free(
-               Operation       *op,
-               LDAPControl     ***pctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
-
 LDAP_END_DECL
 
+#include "proto-ldap.h"
+
 #endif /* SLAPD_LDAP_H */
index 47e0941cba60303c4b5835dd6ded28217701f335..f7446f35c9c4250ac25720ee81de3bdf16f77bc7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 
 static LDAP_REBIND_PROC        ldap_back_rebind;
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
 static int
 ldap_back_proxy_authz_bind( struct ldapconn *lc, Operation *op, SlapReply *rs );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 int
 ldap_back_bind( Operation *op, SlapReply *rs )
@@ -70,7 +68,11 @@ ldap_back_bind( Operation *op, SlapReply *rs )
        rc = ldap_back_op_result( lc, op, rs, msgid, 1 );
 
        if ( rc == LDAP_SUCCESS ) {
-#if defined(LDAP_BACK_PROXY_AUTHZ)
+               /* If defined, proxyAuthz will be used also when
+                * back-ldap is the authorizing backend; for this
+                * purpose, a successful bind is followed by a
+                * bind with the configured identity assertion */
+               /* NOTE: use with care */
                if ( li->idassert_flags & LDAP_BACK_AUTH_OVERRIDE ) {
                        ldap_back_proxy_authz_bind( lc, op, rs );
                        if ( lc->lc_bound == 0 ) {
@@ -78,7 +80,6 @@ ldap_back_bind( Operation *op, SlapReply *rs )
                                goto done;
                        }
                }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
                lc->lc_bound = 1;
                ber_dupbv( &lc->lc_bound_ndn, &op->o_req_ndn );
@@ -348,7 +349,6 @@ ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs )
 
        ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
        if ( !lc->lc_bound ) {
-#ifdef LDAP_BACK_PROXY_AUTHZ
                /*
                 * FIXME: we need to let clients use proxyAuthz
                 * otherwise we cannot do symmetric pools of servers;
@@ -363,16 +363,15 @@ ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs )
                 */
                /*
                 * if no bind took place yet, but the connection is bound
-                * and the "proxyauthzdn" is set, then bind as 
-                * "proxyauthzdn" and explicitly add the proxyAuthz 
-                * control to every operation with the dn bound 
-                * to the connection as control value.
+                * and the "idassert-authcDN" (or other ID) is set, 
+                * then bind as the asserting ideintity and explicitly 
+                * add the proxyAuthz control to every operation with the
+                * dn bound to the connection as control value.
                 */
                if ( op->o_conn != NULL && BER_BVISNULL( &lc->lc_bound_ndn ) ) {
                        (void)ldap_back_proxy_authz_bind( lc, op, rs );
                        goto done;
                }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
                rs->sr_err = ldap_sasl_bind( lc->lc_ld,
                                lc->lc_bound_ndn.bv_val,
@@ -428,17 +427,30 @@ ldap_back_op_result(
         * to a successful state, get the error from the
         * remote server response */
        if ( ERR_OK( rs->sr_err ) ) {
+               int             rc;
+               struct timeval  tv = { 0, 0 };
+
+retry:;
                /* if result parsing fails, note the failure reason */
-               if ( ldap_result( lc->lc_ld, msgid, 1, NULL, &res ) == -1 ) {
+               switch ( ldap_result( lc->lc_ld, msgid, 1, &tv, &res ) ) {
+               case 0:
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 100000;    /* 0.1 s */
+                       ldap_pvt_thread_yield();
+                       goto retry;
+
+               case -1:
                        ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
                                        &rs->sr_err );
+                       break;
+
 
                /* otherwise get the result; if it is not
                 * LDAP_SUCCESS, record it in the reply
                 * structure (this includes 
                 * LDAP_COMPARE_{TRUE|FALSE}) */
-               } else {
-                       int rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
+               default:
+                       rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
                                        &match, &text, NULL, NULL, 1 );
                        rs->sr_text = text;
                        if ( rc != LDAP_SUCCESS ) {
@@ -514,7 +526,6 @@ ldap_back_retry( struct ldapconn *lc, Operation *op, SlapReply *rs )
        return ldap_back_dobind( lc, op, rs );
 }
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
 static int
 ldap_back_proxy_authz_bind( struct ldapconn *lc, Operation *op, SlapReply *rs )
 {
@@ -562,8 +573,13 @@ ldap_back_proxy_authz_bind( struct ldapconn *lc, Operation *op, SlapReply *rs )
 
        default:
                if ( li->idassert_authz ) {
-                       struct berval   authcDN = BER_BVISNULL( &op->o_conn->c_ndn ) ? slap_empty_bv : op->o_conn->c_ndn;
+                       struct berval authcDN;
 
+                       if ( BER_BVISNULL( &op->o_conn->c_ndn ) ) {
+                               authcDN = slap_empty_bv;
+                       } else {
+                               authcDN = op->o_conn->c_ndn;
+                       }       
                        rs->sr_err = slap_sasl_matches( op, li->idassert_authz,
                                        &authcDN, &authcDN );
                        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -724,6 +740,8 @@ ldap_back_proxy_authz_ctrl(
 
        *pctrls = NULL;
 
+       rs->sr_err = LDAP_SUCCESS;
+
        if ( ( BER_BVISNULL( &li->idassert_authcID ) || BER_BVISEMPTY( &li->idassert_authcID ) )
                        && ( BER_BVISNULL( &li->idassert_authcDN ) || BER_BVISEMPTY( &li->idassert_authcDN ) ) ) {
                goto done;
@@ -777,9 +795,13 @@ ldap_back_proxy_authz_ctrl(
 
        } else if ( li->idassert_authz ) {
                int             rc;
-               struct berval   authcDN = BER_BVISNULL( &op->o_conn->c_ndn ) ? slap_empty_bv : op->o_conn->c_ndn;
-
+               struct berval authcDN;
 
+               if ( BER_BVISNULL( &op->o_conn->c_ndn ) ) {
+                       authcDN = slap_empty_bv;
+               } else {
+                       authcDN = op->o_conn->c_ndn;
+               }
                rc = slap_sasl_matches( op, li->idassert_authz,
                                &authcDN, & authcDN );
                if ( rc != LDAP_SUCCESS ) {
@@ -823,7 +845,11 @@ ldap_back_proxy_authz_ctrl(
        case LDAP_BACK_IDASSERT_SELF:
                /* original behavior:
                 * assert the client's identity */
-               assertedID = BER_BVISNULL( &op->o_conn->c_ndn ) ? slap_empty_bv : op->o_conn->c_ndn;
+               if ( BER_BVISNULL( &op->o_conn->c_ndn ) ) {
+                       assertedID = slap_empty_bv;
+               } else {
+                       assertedID = op->o_conn->c_ndn;
+               }
                break;
 
        case LDAP_BACK_IDASSERT_ANONYMOUS:
@@ -899,6 +925,9 @@ ldap_back_proxy_authz_ctrl_free( Operation *op, LDAPControl ***pctrls )
 {
        LDAPControl     **ctrls = *pctrls;
 
+       /* we assume that the first control is the proxyAuthz
+        * added by back-ldap, so it's the only one we explicitly 
+        * free */
        if ( ctrls && ctrls != op->o_ctrls ) {
                assert( ctrls[ 0 ] );
 
@@ -914,4 +943,3 @@ ldap_back_proxy_authz_ctrl_free( Operation *op, LDAPControl ***pctrls )
 
        return 0;
 }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c
new file mode 100644 (file)
index 0000000..58b6106
--- /dev/null
@@ -0,0 +1,456 @@
+/* chain.c - chain LDAP operations */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Portions Copyright 2003 Howard Chu.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by the Howard Chu for inclusion
+ * in OpenLDAP Software.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+static BackendInfo *lback;
+
+#if 0
+static int
+ldap_chain_chk_referrals( Operation *op, SlapReply *rs )
+{
+       return LDAP_SUCCESS;
+}
+#endif
+
+static int
+ldap_chain_operational( Operation *op, SlapReply *rs )
+{
+       /* trap entries generated by back-ldap.
+        * FIXME: we need a better way to recognize them; a cleaner
+        * solution would be to be able to intercept the response
+        * of be_operational(), so that we can divert only those
+        * calls that fail because operational attributes were
+        * requested for entries that do not belong to the underlying
+        * database.  This fix is likely to intercept also entries
+        * generated by back-perl and so. */
+       if ( rs->sr_entry->e_private == NULL ) {
+               return 0;
+       }
+
+       return SLAP_CB_CONTINUE;
+}
+
+static int
+ldap_chain_cb_response( Operation *op, SlapReply *rs )
+{
+       assert( op->o_tag == LDAP_REQ_SEARCH );
+
+       if ( rs->sr_type == REP_SEARCH ) {
+               Attribute       **ap = &rs->sr_entry->e_attrs;
+
+               for ( ; *ap != NULL; ap = &(*ap)->a_next ) {
+                       /* will be generated later by frontend
+                        * (a cleaner solution would be that
+                        * the frontend checks if it already exists */
+                       if ( ad_cmp( (*ap)->a_desc, slap_schema.si_ad_entryDN ) == 0 )
+                       {
+                               Attribute *a = *ap;
+
+                               *ap = (*ap)->a_next;
+                               attr_free( a );
+
+                               /* there SHOULD be one only! */
+                               break;
+                       }
+               }
+               
+               return SLAP_CB_CONTINUE;
+       }
+
+       return 0;
+}
+
+static int
+ldap_chain_response( Operation *op, SlapReply *rs )
+{
+       slap_overinst   *on = (slap_overinst *) op->o_bd->bd_info;
+       void            *private = op->o_bd->be_private;
+       slap_callback   *sc = op->o_callback;
+       int             rc = 0;
+       int             cache = op->o_do_not_cache;
+       char            *authzid = NULL;
+       BerVarray       ref;
+       struct berval   ndn = op->o_ndn;
+
+       struct ldapinfo li, *lip = (struct ldapinfo *)on->on_bi.bi_private;
+
+       if ( rs->sr_err != LDAP_REFERRAL && rs->sr_type != REP_SEARCHREF )
+               return SLAP_CB_CONTINUE;
+
+       ref = rs->sr_ref;
+       rs->sr_ref = NULL;
+
+       op->o_callback = NULL;
+
+       if ( lip->url == NULL ) {
+               /* if we parse the URI then by no means 
+                * we can cache stuff or reuse connections, 
+                * because in back-ldap there's no caching
+                * based on the URI value, which is supposed
+                * to be set once for all (correct?) */
+               op->o_do_not_cache = 1;
+
+               /* FIXME: we're setting the URI of the first referral;
+                * what if there are more?  Is this something we should
+                * worry about? */
+               li = *lip;
+               op->o_bd->be_private = &li;
+
+               if ( rs->sr_type != REP_SEARCHREF ) {
+                       LDAPURLDesc     *srv;
+                       char            *save_dn;
+
+                       /* parse reference and use 
+                        * proto://[host][:port]/ only */
+                       rc = ldap_url_parse_ext( ref[0].bv_val, &srv );
+                       if ( rc != LDAP_URL_SUCCESS ) {
+                               /* error */
+                               return 1;
+                       }
+
+                       /* remove DN essentially because later on 
+                        * ldap_initialize() will parse the URL 
+                        * as a comma-separated URL list */
+                       save_dn = srv->lud_dn;
+                       srv->lud_dn = "";
+                       srv->lud_scope = LDAP_SCOPE_DEFAULT;
+                       li.url = ldap_url_desc2str( srv );
+                       srv->lud_dn = save_dn;
+                       ldap_free_urldesc( srv );
+
+                       if ( li.url == NULL ) {
+                               /* error */
+                               return 1;
+                       }
+               }
+
+       } else {
+               op->o_bd->be_private = on->on_bi.bi_private;
+       }
+
+       /* Chaining can be performed by a privileged user on behalf
+        * of normal users, using the ProxyAuthz control, by exploiting
+        * the identity assertion feature of back-ldap; see idassert-*
+        * directives in slapd-ldap(5).
+        */
+
+       switch ( op->o_tag ) {
+       case LDAP_REQ_BIND: {
+               struct berval   rndn = op->o_req_ndn;
+               Connection      *conn = op->o_conn;
+
+               op->o_req_ndn = slap_empty_bv;
+
+               op->o_conn = NULL;
+               rc = lback->bi_op_bind( op, rs );
+               op->o_req_ndn = rndn;
+               op->o_conn = conn;
+               }
+               break;
+       case LDAP_REQ_ADD:
+               {
+               int             cleanup_attrs = 0;
+
+               if ( op->ora_e->e_attrs == NULL ) {
+                       char            textbuf[ SLAP_TEXT_BUFLEN ];
+                       size_t          textlen = sizeof( textbuf );
+
+                       /* global overlay; create entry */
+                       /* NOTE: this is a hack to use the chain overlay
+                        * as global.  I expect to be able to remove this
+                        * soon by using slap_mods2entry() earlier in
+                        * do_add(), adding the operational attrs later
+                        * if required. */
+                       rs->sr_err = slap_mods2entry( op->ora_modlist,
+                                       &op->ora_e, 0, 1,
+                                       &rs->sr_text, textbuf, textlen );
+                       if ( rs->sr_err != LDAP_SUCCESS ) {
+                               send_ldap_result( op, rs );
+                               rc = 1;
+                               break;
+                       }
+               }
+               rc = lback->bi_op_add( op, rs );
+               if ( cleanup_attrs ) {
+                       attrs_free( op->ora_e->e_attrs );
+                       op->ora_e->e_attrs = NULL;
+               }
+               break;
+               }
+       case LDAP_REQ_DELETE:
+               rc = lback->bi_op_delete( op, rs );
+               break;
+       case LDAP_REQ_MODRDN:
+               rc = lback->bi_op_modrdn( op, rs );
+               break;
+       case LDAP_REQ_MODIFY:
+               rc = lback->bi_op_modify( op, rs );
+               break;
+       case LDAP_REQ_COMPARE:
+               rc = lback->bi_op_compare( op, rs );
+               break;
+       case LDAP_REQ_SEARCH:
+               if ( rs->sr_type == REP_SEARCHREF ) {
+                       struct berval   *curr = ref,
+                                       odn = op->o_req_dn,
+                                       ondn = op->o_req_ndn;
+                       slap_callback   sc2 = { 0 };
+                       int             tmprc = 0;
+                       ber_len_t       refcnt = 0;
+                       BerVarray       newref = NULL;
+
+                       sc2.sc_response = ldap_chain_cb_response;
+                       op->o_callback = &sc2;
+
+                       rs->sr_type = REP_SEARCH;
+
+                       /* copy the private info because we need to modify it */
+                       for ( ; !BER_BVISNULL( &curr[0] ); curr++ ) {
+                               LDAPURLDesc     *srv;
+                               char            *save_dn;
+
+                               /* parse reference and use
+                                * proto://[host][:port]/ only */
+                               tmprc = ldap_url_parse_ext( curr[0].bv_val, &srv );
+                               if ( tmprc != LDAP_URL_SUCCESS ) {
+                                       /* error */
+                                       rc = 1;
+                                       goto end_of_searchref;
+                               }
+
+                               /* remove DN essentially because later on 
+                                * ldap_initialize() will parse the URL 
+                                * as a comma-separated URL list */
+                               save_dn = srv->lud_dn;
+                               srv->lud_dn = "";
+                               srv->lud_scope = LDAP_SCOPE_DEFAULT;
+                               li.url = ldap_url_desc2str( srv );
+                               if ( li.url != NULL ) {
+                                       ber_str2bv_x( save_dn, 0, 1, &op->o_req_dn,
+                                                       op->o_tmpmemctx );
+                                       ber_dupbv_x( &op->o_req_ndn, &op->o_req_dn,
+                                                       op->o_tmpmemctx );
+                               }
+
+                               srv->lud_dn = save_dn;
+                               ldap_free_urldesc( srv );
+
+                               if ( li.url == NULL ) {
+                                       /* error */
+                                       rc = 1;
+                                       goto end_of_searchref;
+                               }
+
+
+                               /* FIXME: should we also copy filter and scope?
+                                * according to RFC3296, no */
+                               tmprc = lback->bi_op_search( op, rs );
+
+                               ldap_memfree( li.url );
+                               li.url = NULL;
+
+                               op->o_tmpfree( op->o_req_dn.bv_val,
+                                               op->o_tmpmemctx );
+                               op->o_tmpfree( op->o_req_ndn.bv_val,
+                                               op->o_tmpmemctx );
+
+                               if ( tmprc ) {
+                                       /* error */
+                                       rc = 1;
+                                       goto end_of_searchref;
+                               }
+
+                               if ( rs->sr_err != LDAP_SUCCESS ) {
+                                       /* if search was not successful,
+                                        * at least return the referral! */
+                                       /* FIXME: assumes referrals 
+                                        * are always created via
+                                        * referral_rewrite() and freed via
+                                        * ber_bvarray_free( rs->sr_ref ) */
+                                       newref = ch_realloc( newref, sizeof( struct berval ) * (refcnt + 2) );
+                                       ber_dupbv( &newref[ refcnt ], &curr[ 0 ] );
+                                       refcnt++;
+                                       BER_BVZERO( &newref[ refcnt ] );
+                               }
+                       }
+
+end_of_searchref:;
+                       op->o_req_dn = odn;
+                       op->o_req_ndn = ondn;
+                       rs->sr_type = REP_SEARCHREF;
+                       rs->sr_entry = NULL;
+
+                       /* if the error was bad, it was already returned
+                        * by back-ldap; destroy the referrals left;
+                        * otherwise, let the frontend return them. */
+                       if ( newref ) {
+                               if ( rc == 0 ) {
+                                       rc = SLAP_CB_CONTINUE;
+                                       if ( ref != default_referral ) {
+                                               ber_bvarray_free( ref );
+                                       }
+                                       ref = newref;
+
+                               } else {
+                                       ber_bvarray_free( newref );
+                               }
+                       }
+                       
+               } else {
+                       rc = lback->bi_op_search( op, rs );
+               }
+               break;
+       case LDAP_REQ_EXTENDED:
+               rc = lback->bi_extended( op, rs );
+               /* FIXME: ldap_back_extended() by design 
+                * doesn't send result; frontend is expected
+                * to send it... */
+               if ( rc != SLAPD_ABANDON ) {
+                       send_ldap_extended( op, rs );
+               }
+               break;
+       default:
+               rc = SLAP_CB_CONTINUE;
+               break;
+       }
+       op->o_do_not_cache = cache;
+       op->o_bd->be_private = private;
+       op->o_callback = sc;
+       op->o_ndn = ndn;
+       if ( authzid ) {
+               op->o_tmpfree( authzid, op->o_tmpmemctx );
+       }
+       rs->sr_ref = ref;
+       if ( lip->url == NULL && li.url != NULL ) {
+               ldap_memfree( li.url );
+       }
+
+       return rc;
+}
+
+static int
+ldap_chain_db_config(
+       BackendDB       *be,
+       const char      *fname,
+       int             lineno,
+       int             argc,
+       char    **argv
+)
+{
+       slap_overinst   *on = (slap_overinst *) be->bd_info;
+       void            *private = be->be_private;
+       char            *argv0 = NULL;
+       int             rc;
+
+       be->be_private = on->on_bi.bi_private;
+       if ( strncasecmp( argv[ 0 ], "chain-", sizeof( "chain-" ) - 1 ) == 0 ) {
+               argv0 = argv[ 0 ];
+               argv[ 0 ] = &argv[ 0 ][ sizeof( "chain-" ) - 1 ];
+       }
+       rc = lback->bi_db_config( be, fname, lineno, argc, argv );
+       if ( argv0 ) {
+               argv[ 0 ] = argv0;
+       }
+       
+       be->be_private = private;
+       return rc;
+}
+
+static int
+ldap_chain_db_init(
+       BackendDB *be
+)
+{
+       slap_overinst *on = (slap_overinst *) be->bd_info;
+       void *private = be->be_private;
+       int rc;
+
+       if ( lback == NULL ) {
+               lback = backend_info( "ldap" );
+
+               if ( lback == NULL ) {
+                       return -1;
+               }
+       }
+
+       be->be_private = NULL;
+       rc = lback->bi_db_init( be );
+       on->on_bi.bi_private = be->be_private;
+       be->be_private = private;
+
+       return rc;
+}
+
+static int
+ldap_chain_db_destroy(
+       BackendDB *be
+)
+{
+       slap_overinst *on = (slap_overinst *) be->bd_info;
+       void *private = be->be_private;
+       int rc;
+
+       be->be_private = on->on_bi.bi_private;
+       rc = lback->bi_db_destroy( be );
+       on->on_bi.bi_private = be->be_private;
+       be->be_private = private;
+       return rc;
+}
+
+static slap_overinst ldapchain;
+
+int
+chain_init( void )
+{
+       ldapchain.on_bi.bi_type = "chain";
+       ldapchain.on_bi.bi_db_init = ldap_chain_db_init;
+       ldapchain.on_bi.bi_db_config = ldap_chain_db_config;
+       ldapchain.on_bi.bi_db_destroy = ldap_chain_db_destroy;
+       
+       /* ... otherwise the underlying backend's function would be called,
+        * likely passing an invalid entry; on the contrary, the requested
+        * operational attributes should have been returned while chasing
+        * the referrals.  This all in all is a bit messy, because part
+        * of the operational attributes are generated by they backend;
+        * part by the frontend; back-ldap should receive all the available
+        * ones from the remote server, but then, on it own, it strips those
+        * it assumes will be (re)generated by the frontend (e.g.
+        * subschemaSubentry.) */
+       ldapchain.on_bi.bi_operational = ldap_chain_operational;
+       
+       ldapchain.on_response = ldap_chain_response;
+
+#if 0
+       ldapchain.on_bi.bi_chk_referrals = ldap_chain_chk_referrals;
+#endif
+
+       return overlay_register( &ldapchain );
+}
+
index 0670a51911b84f45ae9c73fe85da571b83a47753..ffa9f6bf77de6a5a59c1543a23b85839eef0d5ff 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -49,14 +49,12 @@ ldap_back_compare(
        }
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                rc = -1;
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 retry:
        rs->sr_err = ldap_compare_ext( lc->lc_ld, op->o_req_ndn.bv_val,
@@ -72,9 +70,7 @@ retry:
        }
 
 cleanup:
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
        
        return rc;
 }
index f80d7d0d2518ca80f2f93ef57905a8a671df4db0..bdbdc698ce279663b27bd6847b3ecd1a0a6cbb40 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -235,12 +235,14 @@ ldap_back_db_config(
                }
                ber_str2bv( argv[1], 0, 1, &li->acl_passwd );
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        /* identity assertion stuff... */
        } else if ( strncasecmp( argv[0], "idassert-", STRLENOF( "idassert-" ) ) == 0
-                       || strncasecmp( argv[0], "proxyauthz", STRLENOF( "proxyauthz" ) ) == 0 ) {
+                       || strncasecmp( argv[0], "proxyauthz", STRLENOF( "proxyauthz" ) ) == 0 )
+       {
+               /* NOTE: "proxyauthz{DN,pw}" was initially used; it's now
+                * deprected and undocumented, it can be dropped at some
+                * point, since nobody should be really using it */
                return parse_idassert( be, fname, lineno, argc, argv );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        /* save bind creds for referral rebinds? */
        } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
@@ -393,7 +395,6 @@ retry:
 }
 
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
 static int
 parse_idassert(
     BackendDB  *be,
@@ -557,7 +558,7 @@ parse_idassert(
                }
 
                if ( strcasecmp( argv[1], "none" ) == 0 ) {
-                       /* FIXME: is this useful? */
+                       /* FIXME: is this at all useful? */
                        li->idassert_authmethod = LDAP_AUTH_NONE;
 
                        if ( argc != 2 ) {
@@ -697,4 +698,3 @@ parse_idassert(
 
        return 0;
 }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
index b05872c9a64744d15449bdcbd0779acc706b3b57..4b0ce6b25c4df268440031f957a7d8e5cfb2ae0a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -49,7 +49,6 @@ ldap_back_delete(
                goto cleanup;
        }
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        ctrls = op->o_ctrls;
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
@@ -57,7 +56,6 @@ ldap_back_delete(
                rc = -1;
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 retry:
        rs->sr_err = ldap_delete_ext( lc->lc_ld, op->o_req_ndn.bv_val,
@@ -65,13 +63,13 @@ retry:
        rc = ldap_back_op_result( lc, op, rs, msgid, 1 );
        if ( rs->sr_err == LDAP_SERVER_DOWN && do_retry ) {
                do_retry = 0;
-               if ( ldap_back_retry (lc, op, rs )) goto retry;
+               if ( ldap_back_retry (lc, op, rs ) ) {
+                       goto retry;
+               }
        }
 
 cleanup:
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        return rc;
 }
index 879c0ce7ca0cda8696dd01bbf65f4d56f213690d..d4202d4c2b7e8971c9c3ee35382447ee9d7ef4e2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,6 @@ ldap_back_extended(
        for ( i = 0; exop_table[i].extended != NULL; i++ ) {
                if ( bvmatch( exop_table[i].oid, &op->oq_extended.rs_reqoid ) )
                {
-#ifdef LDAP_BACK_PROXY_AUTHZ 
                        struct ldapconn *lc;
                        LDAPControl     **oldctrls = NULL;
                        int             rc;
@@ -81,9 +80,6 @@ ldap_back_extended(
                        op->o_ctrls = oldctrls;
 
                        return rc;
-#else /* ! LDAP_BACK_PROXY_AUTHZ */
-                       return ( *exop_table[i].extended )( op, rs );
-#endif /* ! LDAP_BACK_PROXY_AUTHZ */
                }
        }
 
index e57190c2e21192e60e855b6f891d08a35a00c1cc..b00c579d36479c0792b4d0a9f796200e84031933 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -70,6 +70,10 @@ ldap_back_initialize( BackendInfo *bi )
        bi->bi_connection_init = 0;
        bi->bi_connection_destroy = ldap_back_conn_destroy;
 
+       if ( chain_init( ) ) {
+               return -1;
+       }
+
        return 0;
 }
 
@@ -86,7 +90,6 @@ ldap_back_db_init( Backend *be )
        BER_BVZERO( &li->acl_authcDN );
        BER_BVZERO( &li->acl_passwd );
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        li->idassert_mode = LDAP_BACK_IDASSERT_LEGACY;
 
        BER_BVZERO( &li->idassert_authcID );
@@ -105,7 +108,6 @@ ldap_back_db_init( Backend *be )
 
        /* by default, use proxyAuthz control on each operation */
        li->idassert_flags = LDAP_BACK_AUTH_NONE;
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        ldap_pvt_thread_mutex_init( &li->conn_mutex );
 
@@ -124,7 +126,6 @@ ldap_back_db_open( BackendDB *be )
                "ldap_back_db_open: URI=%s\n",
                li->url != NULL ? li->url : "", 0, 0 );
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        /* by default, use proxyAuthz control on each operation */
        switch ( li->idassert_mode ) {
        case LDAP_BACK_IDASSERT_LEGACY:
@@ -137,10 +138,14 @@ ldap_back_db_open( BackendDB *be )
        default:
                break;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 #if 0 && defined(SLAPD_MONITOR)
        {
+               /* FIXME: disabled because namingContexts doesn't have
+                * a matching rule, and using an MRA filter doesn't work
+                * because the normalized assertion is compared to the 
+                * non-normalized value, which in general differ.
+                * See ITS#3406 */
                struct berval   filter,
                                base = BER_BVC( "cn=Databases,cn=Monitor" );
                struct berval   vals[ 2 ];
@@ -217,7 +222,6 @@ ldap_back_db_destroy(
                        ch_free( li->acl_passwd.bv_val );
                        BER_BVZERO( &li->acl_passwd );
                }
-#ifdef LDAP_BACK_PROXY_AUTHZ
                if ( !BER_BVISNULL( &li->idassert_authcID ) ) {
                        ch_free( li->idassert_authcID.bv_val );
                        BER_BVZERO( &li->idassert_authcID );
@@ -242,7 +246,6 @@ ldap_back_db_destroy(
                        ch_free( li->idassert_sasl_realm.bv_val );
                        BER_BVZERO( &li->idassert_sasl_realm );
                }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
                 if ( li->conntree ) {
                        avl_free( li->conntree, ldap_back_conn_free );
                }
index bdfbdc7d1bfcfe90e28f53bb636695e3252b28f6..cc551243a1d095efeeda6dbdafaa2226d8312b78 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -96,14 +96,12 @@ ldap_back_modify(
        modv[ i ] = 0;
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                rc = -1;
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 retry:
        rs->sr_err = ldap_modify_ext( lc->lc_ld, op->o_req_ndn.bv_val, modv,
@@ -117,9 +115,7 @@ retry:
        }
 
 cleanup:;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        for ( i = 0; modv[ i ]; i++ ) {
                ch_free( modv[ i ]->mod_bvalues );
index 35a8125b7b6d33d1fce8a253ee09e6ec0efe8825..92cce0a749d5dd7b6a844d025ceafe275eb9bfd5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -56,14 +56,12 @@ ldap_back_modrdn(
        }
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                rc = -1;
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
 retry:
        rs->sr_err = ldap_rename( lc->lc_ld, op->o_req_ndn.bv_val,
@@ -78,9 +76,7 @@ retry:
        }
 
 cleanup:
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        return rc;
 }
index e5f3321b66a9c653bd9ad45007bb6d4245c16b49..eadc7d3949fd8228b947f9db3af785a58f37fa1e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,33 @@ extern BI_connection_destroy ldap_back_conn_destroy;
 
 extern BI_entry_get_rw         ldap_back_entry_get;
 
+int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
+struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
+int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
+int ldap_back_retry(struct ldapconn *lc, Operation *op, SlapReply *rs);
+int ldap_back_map_result(SlapReply *rs);
+int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
+       ber_int_t msgid, int sendok);
+int    back_ldap_LTX_init_module(int argc, char *argv[]);
+
+extern int ldap_back_conn_cmp( const void *c1, const void *c2);
+extern int ldap_back_conn_dup( void *c1, void *c2 );
+extern void ldap_back_conn_free( void *c );
+
+extern int
+ldap_back_proxy_authz_ctrl(
+               struct ldapconn *lc,
+               Operation       *op,
+               SlapReply       *rs,
+               LDAPControl     ***pctrls );
+
+extern int
+ldap_back_proxy_authz_ctrl_free(
+               Operation       *op,
+               LDAPControl     ***pctrls );
+
+extern int chain_init( void );
+
 LDAP_END_DECL
 
 #endif /* PROTO_LDAP_H */
index 4953060c76baae2bf6e43fa5bf981e54c9914ca8..bf78dec637e58b79092969fc217bbbfd33d17795 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -105,13 +105,11 @@ ldap_back_search(
        }
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                dontfreetext = 1;
                goto finish;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
        
 retry:
        rs->sr_err = ldap_search_ext( lc->lc_ld, op->o_req_ndn.bv_val,
@@ -274,9 +272,7 @@ fail:;
 finish:;
        send_ldap_result( op, rs );
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        if ( rs->sr_ctrls ) {
                ldap_controls_free( rs->sr_ctrls );
@@ -462,7 +458,7 @@ ldap_build_entry(
                                        attr->a_desc->ad_type->sat_syntax,
                                        attr->a_desc->ad_type->sat_equality,
                                        &attr->a_vals[i], &attr->a_nvals[i],
-                                       NULL /* op->o_tmpmemctx */ );
+                                       NULL );
 
                                if ( rc != LDAP_SUCCESS ) {
                                        BER_BVZERO( &attr->a_nvals[i] );
@@ -498,7 +494,6 @@ ldap_back_entry_get(
 {
        struct ldapconn *lc;
        int             rc = 1,
-                       is_oc,
                        do_not_cache;
        struct berval   bdn;
        LDAPMessage     *result = NULL,
@@ -508,6 +503,7 @@ ldap_back_entry_get(
        Connection      *oconn;
        SlapReply       rs;
        int             do_retry = 1;
+       LDAPControl     **ctrls = NULL;
 
        /* Tell getconn this is a privileged op */
        do_not_cache = op->o_do_not_cache;
@@ -524,9 +520,8 @@ ldap_back_entry_get(
        op->o_conn = oconn;
 
        if ( at ) {
-               is_oc = ( strcasecmp( "objectclass", at->ad_cname.bv_val ) == 0 );
-               if ( oc && !is_oc ) {
-                       gattr[0] = "objectclass";
+               if ( oc && at != slap_schema.si_ad_objectClass ) {
+                       gattr[0] = slap_schema.si_ad_objectClass->ad_cname.bv_val;
                        gattr[1] = at->ad_cname.bv_val;
                        gattr[2] = NULL;
 
@@ -547,9 +542,15 @@ ldap_back_entry_get(
                *ptr++ = '\0';
        }
 
+       ctrls = op->o_ctrls;
+       rc = ldap_back_proxy_authz_ctrl( lc, op, &rs, &ctrls );
+       if ( rc != LDAP_SUCCESS ) {
+               goto cleanup;
+       }
+       
 retry:
        rc = ldap_search_ext_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
-                               at ? gattr : NULL, 0, NULL, NULL, LDAP_NO_LIMIT,
+                               at ? gattr : NULL, 0, ctrls, NULL, LDAP_NO_LIMIT,
                                LDAP_NO_LIMIT, &result );
        if ( rc != LDAP_SUCCESS ) {
                if ( rc == LDAP_SERVER_DOWN && do_retry ) {
@@ -576,6 +577,8 @@ retry:
        }
 
 cleanup:
+       (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
+
        if ( result ) {
                ldap_msgfree( result );
        }
index dbed6f577b65410b1bb173477adbd69f8c14d2fc..e93dba2c89035feab94fad81b9b1507f2ac005cb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
index bffac07a5970f5be61cfb409d30be37b66380b68..8c12d9e06aed05040db6d06874ce948fea51b296 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 9bb32cd762d2c5bb639b4e1e1d0010c35c25e45f..6bc32c1f221c0ed4e13169a88f094e2b547929ae 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -55,6 +55,7 @@ ldbm_back_add(
                send_ldap_result( op, rs );
                return rs->sr_err;
        }
+       rs->sr_text = NULL;
 
 #ifdef LDBM_SUBENTRIES
        subentry = is_entry_subentry( op->oq_add.rs_e );
index 5dbd40daee9ab00bad203f2dff8e1ab66d7d59a5..e31a33b6cb932ece842389da5e07507ac2a0f6cc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 621e1d7bdd9d165513b51278928370cbad8cd583..b37b4aca4af531bda7a12d2244da6f58453d99a5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index bd53be5b5ba386c2ebee917ae9fd6395add77603..cb0282fdb729d1cf052af061f6eb245501c0c3ef 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7397f1f17d0c75b49a73b2d11faa8d17e8b929cc..dce317876a1ff38e561713b5a045f244f8f78f0c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -105,31 +105,16 @@ ldbm_back_bind(
 
        switch ( op->oq_bind.rb_method ) {
        case LDAP_AUTH_SIMPLE:
-               if ( ! access_allowed( op, e,
-                       password, NULL, ACL_AUTH, NULL ) )
-               {
-#if 1
-                       rc = LDAP_INVALID_CREDENTIALS;
-#else
-                       rc = LDAP_INSUFFICIENT_ACCESS;
-#endif
-                       goto return_results;
-               }
-
                if ( (a = attr_find( e->e_attrs, password )) == NULL ) {
                        /* stop front end from sending result */
-#if 1
                        rc = LDAP_INVALID_CREDENTIALS;
-#else
-                       rc = LDAP_INAPPROPRIATE_AUTH;
-#endif
                        goto return_results;
                }
 
-               if ( slap_passwd_check( op->o_conn,
-                       a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 )
+               if ( slap_passwd_check( op, e, a, &op->oq_bind.rb_cred,
+                                       &rs->sr_text ) != 0 )
                {
-                       /* stop front end from sending result */
+                       /* failure; stop front end from sending result */
                        rc = LDAP_INVALID_CREDENTIALS;
                        goto return_results;
                }
index 702a0f4532eb6e4eb9115218a899e0e32802ff57..4cc80c455b022063da98150f0bff2f5e1063736a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 67d8965baab1b4b9eb72845e0f528b81736da789..7029786dfe430bfe04cf682158a95bbc083c3601 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 936d26c244b243d1b69e87d767122bb98a5f6c5d..daa75b21634bc604a8cdd5b88520dc11d20c34ad 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cf92272b746968176abe36ce181b8c3cef23de54..e64ae11a35577919ac903f50f8ff2c868ff85c10 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e8cce87234e3c5b952bc047e503992f510561df8..74e655c14ed6e2c3de548e554648b15f49d3baf5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 81358859bf89d13d9410f24774a950cb738dcd55..7f1a4d5cb4d534dadedd5a4546c90271ad4009c0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -49,8 +49,6 @@ ldbm_back_delete(
 
        /* FIXME : dn2entry() should return non-glue entry */
        if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
-               BerVarray deref = NULL;
-
                Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n",
                        op->o_req_dn.bv_val, 0, 0);
 
@@ -62,18 +60,8 @@ ldbm_back_delete(
                        cache_return_entry_r( &li->li_cache, matched );
 
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                               }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                                       LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -82,9 +70,6 @@ ldbm_back_delete(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 49ed98a9948e49669786fb7f0952d539e1183fa0..ae9489a519c67a4e4745a0067a5df825a86108c6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1f89e890dc69c08663ecfed9911d63015a03285c..3227fbe73517b295cc99e688baac8fe2db143c7e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3a30deb50a0a2bcfdd9a370d645a035cc24b8b82..ca78f6271da50f304024d5c0fa283cf454d3ee7d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 74311bb8ec9019799c342db3d75f1a32f90d05df..fba307a2f04f44e027d33f8c961877f7a982d744 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index d9b24a6114f1a719f813af41fbd97ff2ebba6e07..2825e33d3a2e2caadbae284ca6594d4064ff9ae9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f63de5be9278b5024df06dd8ec2b6fc8873057d6..b5a7ec7fefeda11251d8f3da3e4fa36775ec8ca1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a5725c722021df28ece0d564bcb0611f8b97bf65..a062ead46a5b9866dd307e7789d4e10b4c7dffe2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a0406fa3ec926c571962ede4fbb1470a29de2fc0..7a7b837ff3cbe132120bbae7a656887f9d9e4759 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 25a151574528d7f999bea5de524661b4a5486880..424e621b16c35193caefa0ab906f11f918c883eb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1dd8aa4fa03cc40bc8c65c339cc4bafc1cb90632..f44e89a3a7c298790947fabb7f868923abe1e122 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5186567aa550cfbd98c7c0565a04314de0927f06..66745ee6db81f6021ed813bc2e1596d1e7a6f5a3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 1998-2001 Net Boolean Incorporated.
  * All rights reserved.
index 321bb12a291fec838dbe392fbecdf97e03057481..e4e41f93c674bb90ea78d00443025f02dcb41e99 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4754cf3c09d6529c5e96959944fae236f9693775..3e34178d209f796f1b97300d9e1dc52202a492e6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -249,7 +249,6 @@ ldbm_back_modify(
 
        /* FIXME: dn2entry() should return non-glue entry */
        if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
-               BerVarray deref = NULL;
                if ( matched != NULL ) {
                        rs->sr_matched = ch_strdup( matched->e_dn );
                        rs->sr_ref = is_entry_referral( matched )
@@ -257,18 +256,8 @@ ldbm_back_modify(
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                               }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                               LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                               &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -276,9 +265,6 @@ ldbm_back_modify(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
 
                rs->sr_ref = NULL;
index 5a6229f1bf7e46ddf2a03cd3bf6b15e9c7fa3a80..e9fd151fcc711fcd6d72ce043ca0b00ac08b9d8f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,6 @@ ldbm_back_modrdn(
        /* get entry with writer lock */
        /* FIXME: dn2entry() should return non-glue entry */
        if (( e == NULL  ) || ( !manageDSAit && e && is_entry_glue( e ))) {
-               BerVarray deref = NULL;
                if ( matched != NULL ) {
                        rs->sr_matched = strdup( matched->e_dn );
                        rs->sr_ref = is_entry_referral( matched )
@@ -85,18 +84,8 @@ ldbm_back_modrdn(
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                               }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                               LDAP_SCOPE_DEFAULT );
+                       rs->sr_ref = referral_rewrite( default_referral, NULL,
+                                               &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -105,9 +94,6 @@ ldbm_back_modrdn(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-               if ( deref != default_referral ) {
-                       ber_bvarray_free( deref );
-               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 723276db8ac2a64e55539edce21cefcec7f45079..aa1d3919631552c5ca1b319b84a83f79e5c1c3f5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index de927c72bd50462a57fc0be1647a3c14431dc8e2..b62c84bada086be09eabcd098c62493f1e59aa76 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f35dea97499082c9fc223f14471df61babfbbb23..f0794f34264a46667e16968c711a583f0481e48a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8f01f958dccb582a30391f52ebf2ace22f05afc1..8c1e8a40882cfce264a2d4c44a9d7e9851f57636 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@ ldbm_back_referrals(
     SlapReply  *rs )
 {
        struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
-       Entry *e, *matched;
+       Entry           *e, *matched;
+       int             rc = LDAP_SUCCESS;
 
        if( op->o_tag == LDAP_REQ_SEARCH ) {
                /* let search take care of itself */
@@ -55,36 +56,40 @@ ldbm_back_referrals(
                                "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
                                op->o_tag, op->o_req_dn.bv_val, rs->sr_matched );
 
-                       if( is_entry_referral( matched ) ) {
-                               rs->sr_err = LDAP_OTHER;
+                       if ( is_entry_referral( matched ) ) {
+                               rc = rs->sr_err = LDAP_OTHER;
                                rs->sr_ref = get_entry_referrals( op, matched );
                        }
 
                        cache_return_entry_r( &li->li_cache, matched );
 
                } else if ( default_referral != NULL ) {
-                       rs->sr_err = LDAP_OTHER;
+                       rc = rs->sr_err = LDAP_OTHER;
                        rs->sr_ref = referral_rewrite( default_referral,
                                NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
 
-               if( rs->sr_ref != NULL ) {
+               if ( rs->sr_ref != NULL ) {
                        /* send referrals */
-                       rs->sr_err = LDAP_REFERRAL;
-                       send_ldap_result( op, rs );
-                       ber_bvarray_free( rs->sr_ref );
+                       rc = rs->sr_err = LDAP_REFERRAL;
 
-               } else if ( rs->sr_err != LDAP_SUCCESS ) {
+               } else {
                        rs->sr_text = rs->sr_matched ? "bad referral object" : "bad default referral";
+               }
+
+               if ( rc != LDAP_SUCCESS ) {
                        send_ldap_result( op, rs );
                }
 
                if ( rs->sr_matched ) free( (char *)rs->sr_matched );
+               if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+               rs->sr_text = NULL;
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
-               return rs->sr_err;
+
+               return rc;
        }
 
        if ( is_entry_referral( e ) ) {
@@ -99,23 +104,24 @@ ldbm_back_referrals(
 
                rs->sr_matched = e->e_name.bv_val;
                if( rs->sr_ref != NULL ) {
-                       rs->sr_err = LDAP_REFERRAL;
-                       send_ldap_result( op, rs );
-
-                       ber_bvarray_free( rs->sr_ref );
+                       rc = rs->sr_err = LDAP_REFERRAL;
+                       rs->sr_text = NULL;
 
                } else {
-                       send_ldap_error( op, rs, LDAP_OTHER,
-                               "bad referral object" );
+                       rc = rs->sr_err = LDAP_OTHER;
+                       rs->sr_text = "bad referral object";
                }
+               send_ldap_result( op, rs );
 
-               if( refs != NULL ) ber_bvarray_free( refs );
+               if ( refs != NULL ) ber_bvarray_free( refs );
+               rs->sr_err = rc;
                rs->sr_ref = NULL;
+               rs->sr_text = NULL;
                rs->sr_matched = NULL;
        }
 
        cache_return_entry_r( &li->li_cache, e );
        ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
 
-       return rs->sr_err;
+       return rc;
 }
index 2b093706156433ac3046bbe5dcdc1e8b7270334c..3c09594ff134efd30a3e98ddcdac976418f063a9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -85,16 +85,25 @@ ldbm_back_search(
                struct berval matched_dn = BER_BVNULL;
 
                if ( matched != NULL ) {
-                       BerVarray erefs;
-                       ber_dupbv( &matched_dn, &matched->e_name );
+                       BerVarray erefs = NULL;
+                       
+                       if ( ! access_allowed( op, matched,
+                                               slap_schema.si_ad_entry,
+                                               NULL, ACL_DISCLOSE, NULL ) )
+                       {
+                               rs->sr_err = LDAP_NO_SUCH_OBJECT;
 
-                       erefs = is_entry_referral( matched )
-                               ? get_entry_referrals( op, matched )
-                               : NULL;
+                       } else {
+                               ber_dupbv( &matched_dn, &matched->e_name );
+
+                               erefs = is_entry_referral( matched )
+                                       ? get_entry_referrals( op, matched )
+                                       : NULL;
+                       }
 
                        cache_return_entry_r( &li->li_cache, matched );
 
-                       if( erefs ) {
+                       if ( erefs ) {
                                rs->sr_ref = referral_rewrite( erefs, &matched_dn,
                                        &op->o_req_dn, op->ors_scope );
 
@@ -115,17 +124,32 @@ ldbm_back_search(
                ber_memfree( matched_dn.bv_val );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
-               return LDAP_REFERRAL;
+               return rs->sr_err;
+       }
+
+       if ( ! access_allowed( op, e, slap_schema.si_ad_entry,
+                               NULL, ACL_DISCLOSE, NULL ) )
+       {
+               rs->sr_err = LDAP_NO_SUCH_OBJECT;
+
+               cache_return_entry_r( &li->li_cache, e );
+               ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
+
+               send_ldap_result( op, rs );
+               return rs->sr_err;
        }
 
-       if (!manageDSAit && is_entry_referral( e ) ) {
+       if ( !manageDSAit && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
-               struct berval matched_dn;
-               BerVarray erefs;
+               struct berval   matched_dn = BER_BVNULL;
+               BerVarray       erefs = NULL;
+
+               rs->sr_ref = NULL;
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "bad referral object";
 
                ber_dupbv( &matched_dn, &e->e_name );
                erefs = get_entry_referrals( op, e );
-               rs->sr_ref = NULL;
 
                cache_return_entry_r( &li->li_cache, e );
                ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
@@ -134,28 +158,25 @@ ldbm_back_search(
                        "ldbm_search: entry is referral\n",
                        0, 0, 0 );
 
-               if( erefs ) {
+               if ( erefs ) {
                        rs->sr_ref = referral_rewrite( erefs, &matched_dn,
                                &op->o_req_dn, op->ors_scope );
 
                        ber_bvarray_free( erefs );
+                       
+                       if ( rs->sr_ref ) {
+                               rs->sr_err = LDAP_REFERRAL;
+                               rs->sr_text = NULL;
+                       }
                }
 
                rs->sr_matched = matched_dn.bv_val;
-               if( rs->sr_ref ) {
-                       rs->sr_err = LDAP_REFERRAL;
-                       send_ldap_result( op, rs );
-                       ber_bvarray_free( rs->sr_ref );
-
-               } else {
-                       send_ldap_error( op, rs, LDAP_OTHER,
-                       "bad referral object" );
-               }
-
+               send_ldap_result( op, rs );
+               ber_bvarray_free( rs->sr_ref );
                ber_memfree( matched_dn.bv_val );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
-               return LDAP_OTHER;
+               return rs->sr_err;
        }
 
        if ( is_entry_alias( e ) ) {
index e9e9621af749d964cfebda53421d454bd62fe310..17f4571af1b4032951ba8e7d2adf6e1125cc2415 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 193bcb65420afd3669cc1658862a8c9ac2532a24..1292b4c858f6d802fb3169dfdeb77c1ca1b61a2a 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 0de1f0ba89d60f4761593f4bab5339312cde13b4..6f352696e030968441c5a5e46ccc721f7bc75bff 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 int
 meta_back_add( Operation *op, SlapReply *rs )
 {
-       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
-       struct metaconn *lc;
-       int i, candidate = -1;
-       Attribute *a;
-       LDAPMod **attrs;
-       struct berval mdn = BER_BVNULL, mapped;
-       dncookie dc;
+       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
+       struct metaconn *lc;
+       int             i, candidate = -1;
+       int             isupdate;
+       Attribute       *a;
+       LDAPMod         **attrs;
+       struct berval   mdn = BER_BVNULL, mapped;
+       dncookie        dc;
 
        Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n",
                        op->o_req_dn.bv_val, 0, 0 );
@@ -57,7 +58,7 @@ meta_back_add( Operation *op, SlapReply *rs )
 
        if ( !meta_back_dobind( lc, op )
                        || !meta_back_is_valid( lc, candidate ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }
@@ -65,7 +66,7 @@ meta_back_add( Operation *op, SlapReply *rs )
        /*
         * Rewrite the add dn, if needed
         */
-       dc.rwmap = &li->targets[ candidate ]->rwmap;
+       dc.rwmap = &li->targets[ candidate ]->mt_rwmap;
        dc.conn = op->o_conn;
        dc.rs = rs;
        dc.ctx = "addDN";
@@ -76,19 +77,20 @@ meta_back_add( Operation *op, SlapReply *rs )
        }
 
        /* Count number of attributes in entry */
-       for ( i = 1, a = op->oq_add.rs_e->e_attrs; a; i++, a = a->a_next );
+       for ( i = 1, a = op->ora_e->e_attrs; a; i++, a = a->a_next );
        
        /* Create array of LDAPMods for ldap_add() */
        attrs = ch_malloc( sizeof( LDAPMod * )*i );
 
-       for ( i = 0, a = op->oq_add.rs_e->e_attrs; a; a = a->a_next ) {
+       isupdate = be_shadow_update( op );
+       for ( i = 0, a = op->ora_e->e_attrs; a; a = a->a_next ) {
                int j;
 
-               if ( a->a_desc->ad_type->sat_no_user_mod  ) {
+               if ( !isupdate && a->a_desc->ad_type->sat_no_user_mod  ) {
                        continue;
                }
 
-               ldap_back_map( &li->targets[ candidate ]->rwmap.rwm_at,
+               ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_at,
                                &a->a_desc->ad_cname, &mapped, BACKLDAP_MAP );
                if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
                        continue;
@@ -106,8 +108,9 @@ meta_back_add( Operation *op, SlapReply *rs )
                 * to allow their use in ACLs at the back-ldap
                 * level.
                 */
-               if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid,
-                                       SLAPD_DN_SYNTAX ) == 0 ) {
+               if ( a->a_desc->ad_type->sat_syntax ==
+                               slap_schema.si_syn_distinguishedName )
+               {
                        (void)ldap_dnattr_rewrite( &dc, a->a_vals );
                }
 
@@ -121,15 +124,18 @@ meta_back_add( Operation *op, SlapReply *rs )
        }
        attrs[ i ] = NULL;
 
-       ldap_add_s( lc->conns[ candidate ].ld, mdn.bv_val, attrs );
+       (void)ldap_add_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
+                             attrs, NULL, NULL );
        for ( --i; i >= 0; --i ) {
                free( attrs[ i ]->mod_vals.modv_bvals );
                free( attrs[ i ] );
        }
        free( attrs );
-       if ( mdn.bv_val != op->oq_add.rs_e->e_dn ) {
+       if ( mdn.bv_val != op->ora_e->e_dn ) {
                free( mdn.bv_val );
+               BER_BVZERO( &mdn );
        }
+
        return meta_back_op_result( lc, op, rs );
 }
 
index eb38de3786cba0e05efe840ab3a36413d9d75c15..7528e06bbfe643e0c4f9d50716cc3288c007d61d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -91,7 +91,7 @@ meta_back_attribute(
        } /* else */
 
        candidate = meta_back_select_unique_candidate( li, ndn );
-       if ( candidate == -1 ) {
+       if ( candidate == META_TARGET_NONE ) {
                return 1;
        }
 
index 47d7351dcb6fcd8638a932a0977074d042ac9e37..cd82865fb9e23a52f94f5bde3d0ca9151545403a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -82,6 +82,9 @@ typedef struct dncookie {
 #endif
 } dncookie;
 
+#define META_BIND_NRETRIES     3
+#define META_BIND_TIMEOUT      1000
+
 int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
@@ -151,54 +154,48 @@ extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
 /* (end of) from back-ldap.h before rwm removal */
 
 struct metasingleconn {
-       int                     candidate;
+       int                     msc_candidate;
 #define        META_NOT_CANDIDATE      0
 #define        META_CANDIDATE          1
 #define        META_LAST_CONN          -1
        
-       LDAP                    *ld;
-       struct berval           bound_dn;
-       struct berval           cred;
-       int                     bound;
+       LDAP                    *msc_ld;
+       struct berval           msc_bound_ndn;
+       struct berval           msc_cred;
+       int                     msc_bound;
 #define META_UNBOUND           0
 #define META_BOUND             1
 #define META_ANONYMOUS         2
 };
 
-#define META_LAST(lsc)         ((lsc)->candidate == META_LAST_CONN)
+#define META_LAST(lsc)         ((lsc)->msc_candidate == META_LAST_CONN)
 
 struct metaconn {
-       struct slap_conn        *conn;
-       struct rewrite_info     *rwinfo;
+       struct slap_conn        *mc_conn;
+       struct rewrite_info     *mc_rwinfo;
        
        /*
         * means that the connection is bound; 
         * of course only one target actually is ...
         */
-       int             bound_target;
+       int                     mc_bound_target;
 #define META_BOUND_NONE                -1
 #define META_BOUND_ALL         -2
        /* supersedes the connection stuff */
-       struct metasingleconn *conns;
+       struct metasingleconn   *mc_conns;
 };
 
 struct metatarget {
-       char                    *uri;
-       struct berval           psuffix;        /* pretty suffix */
-       struct berval           suffix;         /* normalized suffix */
-       struct berval           binddn;
-       struct berval           bindpw;
+       char                    *mt_uri;
+       struct berval           mt_psuffix;             /* pretty suffix */
+       struct berval           mt_nsuffix;             /* normalized suffix */
+       struct berval           mt_binddn;
+       struct berval           mt_bindpw;
 
-       struct berval           pseudorootdn;
-       struct berval           pseudorootpw;
+       struct berval           mt_pseudorootdn;
+       struct berval           mt_pseudorootpw;
 
-#if 0
-       struct rewrite_info     *rwinfo;
-
-       struct ldapmap          oc_map;
-       struct ldapmap          at_map;
-#endif
-       struct ldaprwmap        rwmap;
+       struct ldaprwmap        mt_rwmap;
 };
 
 struct metadncache {
@@ -333,6 +330,7 @@ meta_dncache_dup(
                void                    *c2
 );
 
+#define META_TARGET_NONE       (-1)
 extern int
 meta_dncache_get_target(
                struct metadncache      *cache,
index c6aaa87cf38c21f20e14317cb920797902507f84..36dc7af36cc465959eb005b8119ba4009d566f67 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -57,9 +57,9 @@ meta_back_bind( Operation *op, SlapReply *rs )
        Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s",
                        op->o_req_dn.bv_val, "", "" );
 
-       if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op ) ) {
+       if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op ) ) {
                isroot = 1;
-               ber_dupbv( &op->oq_bind.rb_edn, be_root_dn( op->o_bd ) );
+               ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ) );
                op_type = META_OP_REQUIRE_ALL;
        }
        lc = meta_back_getconn( op, rs, op_type,
@@ -76,20 +76,20 @@ meta_back_bind( Operation *op, SlapReply *rs )
        /*
         * Each target is scanned ...
         */
-       lc->bound_target = META_BOUND_NONE;
+       lc->mc_bound_target = META_BOUND_NONE;
        ndnlen = op->o_req_ndn.bv_len;
        for ( i = 0; i < li->ntargets; i++ ) {
                int             lerr;
                struct berval   orig_dn = op->o_req_dn;
                struct berval   orig_ndn = op->o_req_ndn;
-               struct berval   orig_cred = op->oq_bind.rb_cred;
-               int             orig_method = op->oq_bind.rb_method;
+               struct berval   orig_cred = op->orb_cred;
+               int             orig_method = op->orb_method;
                
 
                /*
                 * Skip non-candidates
                 */
-               if ( lc->conns[ i ].candidate != META_CANDIDATE ) {
+               if ( lc->mc_conns[ i ].msc_candidate != META_CANDIDATE ) {
                        continue;
                }
 
@@ -107,29 +107,30 @@ meta_back_bind( Operation *op, SlapReply *rs )
                                        "", "", "" );
                }
 
-               if ( isroot && li->targets[ i ]->pseudorootdn.bv_val != NULL ) {
-                       op->o_req_dn = li->targets[ i ]->pseudorootdn;
-                       op->o_req_ndn = li->targets[ i ]->pseudorootdn;
-                       op->oq_bind.rb_cred = li->targets[ i ]->pseudorootpw;
-                       op->oq_bind.rb_method = LDAP_AUTH_SIMPLE;
+               if ( isroot && li->targets[ i ]->mt_pseudorootdn.bv_val != NULL ) {
+                       op->o_req_dn = li->targets[ i ]->mt_pseudorootdn;
+                       op->o_req_ndn = li->targets[ i ]->mt_pseudorootdn;
+                       op->orb_cred = li->targets[ i ]->mt_pseudorootpw;
+                       op->orb_method = LDAP_AUTH_SIMPLE;
                }
                
                lerr = meta_back_do_single_bind( lc, op, rs, i );
                if ( lerr != LDAP_SUCCESS ) {
                        rs->sr_err = lerr;
-                       ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
+                       ( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
+
                } else {
                        rc = LDAP_SUCCESS;
                }
 
                op->o_req_dn = orig_dn;
                op->o_req_ndn = orig_ndn;
-               op->oq_bind.rb_cred = orig_cred;
-               op->oq_bind.rb_method = orig_method;
+               op->orb_cred = orig_cred;
+               op->orb_method = orig_method;
        }
 
        if ( isroot ) {
-               lc->bound_target = META_BOUND_ALL;
+               lc->mc_bound_target = META_BOUND_ALL;
        }
 
        /*
@@ -172,17 +173,16 @@ meta_back_do_single_bind(
                int                     candidate
 )
 {
-       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
-       struct berval   mdn = BER_BVNULL;
-       ber_int_t       msgid;
-       dncookie        dc;
-       struct metasingleconn   *lsc = &lc->conns[ candidate ];
-       LDAPMessage     *res;
+       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
+       struct berval           mdn = BER_BVNULL;
+       dncookie                dc;
+       struct metasingleconn   *lsc = &lc->mc_conns[ candidate ];
+       int                     msgid;
        
        /*
         * Rewrite the bind dn if needed
         */
-       dc.rwmap = &li->targets[ candidate ]->rwmap;
+       dc.rwmap = &li->targets[ candidate ]->mt_rwmap;
        dc.conn = op->o_conn;
        dc.rs = rs;
        dc.ctx = "bindDN";
@@ -193,7 +193,7 @@ meta_back_do_single_bind(
        }
 
        if ( op->o_ctrls ) {
-               rs->sr_err = ldap_set_option( lsc->ld, 
+               rs->sr_err = ldap_set_option( lsc->msc_ld, 
                                LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        rs->sr_err = slap_map_api2result( rs );
@@ -204,31 +204,65 @@ meta_back_do_single_bind(
        /* FIXME: this fixes the bind problem right now; we need
         * to use the asynchronous version to get the "matched"
         * and more in case of failure ... */
-       rs->sr_err = ldap_sasl_bind_s(lsc->ld, mdn.bv_val,
-                       LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred,
-                       op->o_ctrls, NULL, NULL);
+       rs->sr_err = ldap_sasl_bind( lsc->msc_ld, mdn.bv_val,
+                       LDAP_SASL_SIMPLE, &op->orb_cred,
+                       op->o_ctrls, NULL, &msgid );
+       if ( rs->sr_err == LDAP_SUCCESS ) {
+               LDAPMessage     *res;
+               struct timeval  tv = { 0, 0 };
+               int             rc;
+               int             nretries = 0;
+
+               /*
+                * handle response!!!
+                */
+retry:;
+               switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
+               case 0:
+                       if ( ++nretries <= META_BIND_NRETRIES ) {
+                               ldap_pvt_thread_yield();
+                               tv.tv_sec = 0;
+                               tv.tv_usec = META_BIND_TIMEOUT;
+                               goto retry;
+                       }
+                       rs->sr_err = LDAP_BUSY;
+                       break;
+
+               case -1:
+                       ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
+                                       &rs->sr_err );
+                       break;
+
+               default:
+                       rc = ldap_parse_result( lsc->msc_ld, res, &rs->sr_err,
+                                       NULL, NULL, NULL, NULL, 1 );
+                       if ( rc != LDAP_SUCCESS ) {
+                               rs->sr_err = rc;
+                       }
+                       break;
+               }
+       }
+
        if ( rs->sr_err != LDAP_SUCCESS ) {
                rs->sr_err = slap_map_api2result( rs );
                goto return_results;
        }
 
-       /*
-        * FIXME: handle response!!!
-        */
-       if ( lsc->bound_dn.bv_val != NULL ) {
-               ber_memfree( lsc->bound_dn.bv_val );
+       if ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) {
+               ber_memfree( lsc->msc_bound_ndn.bv_val );
        }
-       ber_dupbv( &lsc->bound_dn, &op->o_req_dn );
-       lsc->bound = META_BOUND;
-       lc->bound_target = candidate;
+       ber_dupbv( &lsc->msc_bound_ndn, &op->o_req_dn );
+       lsc->msc_bound = META_BOUND;
+       lc->mc_bound_target = candidate;
 
        if ( li->savecred ) {
-               if ( lsc->cred.bv_val ) {
-                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
-                       ber_memfree( lsc->cred.bv_val );
+               if ( !BER_BVISNULL( &lsc->msc_cred ) ) {
+                       /* destroy sensitive data */
+                       memset( lsc->msc_cred.bv_val, 0, lsc->msc_cred.bv_len );
+                       ber_memfree( lsc->msc_cred.bv_val );
                }
-               ber_dupbv( &lsc->cred, &op->oq_bind.rb_cred );
-               ldap_set_rebind_proc( lsc->ld, meta_back_rebind, lsc );
+               ber_dupbv( &lsc->msc_cred, &op->orb_cred );
+               ldap_set_rebind_proc( lsc->msc_ld, meta_back_rebind, lsc );
        }
 
        if ( li->cache.ttl != META_DNCACHE_DISABLED
@@ -252,24 +286,25 @@ return_results:;
 int
 meta_back_dobind( struct metaconn *lc, Operation *op )
 {
-       struct metasingleconn *lsc;
-       int bound = 0, i;
+       struct metasingleconn   *lsc;
+       int                     bound = 0, i;
 
        /*
         * all the targets are bound as pseudoroot
         */
-       if ( lc->bound_target == META_BOUND_ALL ) {
+       if ( lc->mc_bound_target == META_BOUND_ALL ) {
                return 1;
        }
 
-       for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
+       for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
                int             rc;
                struct berval   cred = BER_BVC("");
+               int             msgid;
 
                /*
                 * Not a candidate or something wrong with this target ...
                 */
-               if ( lsc->ld == NULL ) {
+               if ( lsc->msc_ld == NULL ) {
                        continue;
                }
 
@@ -277,17 +312,17 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                 * If required, set controls
                 */
                if ( op->o_ctrls ) {
-                       if ( ldap_set_option( lsc->ld, LDAP_OPT_SERVER_CONTROLS,
+                       if ( ldap_set_option( lsc->msc_ld, LDAP_OPT_SERVER_CONTROLS,
                                        op->o_ctrls ) != LDAP_SUCCESS ) {
                                ( void )meta_clear_one_candidate( lsc, 1 );
                                continue;
                        }
                }
-       
+
                /*
                 * If the target is already bound it is skipped
                 */
-               if ( lsc->bound == META_BOUND && lc->bound_target == i ) {
+               if ( lsc->msc_bound == META_BOUND && lc->mc_bound_target == i ) {
                        ++bound;
                        continue;
                }
@@ -297,24 +332,60 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                 * (note: if the target was already bound, the anonymous
                 * bind clears the previous bind).
                 */
-               if ( lsc->bound_dn.bv_val ) {
-                       ber_memfree( lsc->bound_dn.bv_val );
-                       lsc->bound_dn.bv_val = NULL;
-                       lsc->bound_dn.bv_len = 0;
+               if ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) {
+                       ber_memfree( lsc->msc_bound_ndn.bv_val );
+                       BER_BVZERO( &lsc->msc_bound_ndn );
                }
                
                if ( /* FIXME: need li ... li->savecred && */ 
-                               lsc->cred.bv_val ) {
-                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
-                       ber_memfree( lsc->cred.bv_val );
-                       lsc->cred.bv_val = NULL;
-                       lsc->cred.bv_len = 0;
+                               !BER_BVISNULL( &lsc->msc_cred ) )
+               {
+                       /* destroy sensitive data */
+                       memset( lsc->msc_cred.bv_val, 0, lsc->msc_cred.bv_len );
+                       ber_memfree( lsc->msc_cred.bv_val );
+                       BER_BVZERO( &lsc->msc_cred );
+               }
+
+               rc = ldap_sasl_bind( lsc->msc_ld, "", LDAP_SASL_SIMPLE, &cred,
+                               op->o_ctrls, NULL, &msgid );
+               if ( rc == LDAP_SUCCESS ) {
+                       LDAPMessage     *res;
+                       struct timeval  tv = { 0, 0 };
+                       int             err;
+                       int             nretries = 0;
+
+                       /*
+                        * handle response!!!
+                        */
+retry:;
+                       switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
+                       case 0:
+                               if ( ++nretries <= META_BIND_NRETRIES ) {
+                                       ldap_pvt_thread_yield();
+                                       tv.tv_sec = 0;
+                                       tv.tv_usec = META_BIND_TIMEOUT;
+                                       goto retry;
+                               }
+
+                               rc = LDAP_BUSY;
+                               break;
+
+                       case -1:
+                               ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
+                                               &rc );
+                               break;
+
+                       default:
+                               rc = ldap_parse_result( lsc->msc_ld, res, &err,
+                                               NULL, NULL, NULL, NULL, 1 );
+                               if ( rc == LDAP_SUCCESS ) {
+                                       rc = err;
+                               }
+                               break;
+                       }
                }
 
-               rc = ldap_sasl_bind_s(lsc->ld, "", LDAP_SASL_SIMPLE, &cred,
-                               op->o_ctrls, NULL, NULL);
                if ( rc != LDAP_SUCCESS ) {
-                       
                        Debug( LDAP_DEBUG_ANY,
                                        "==>meta_back_dobind: (anonymous)"
                                        " bind failed"
@@ -332,7 +403,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        continue;
                } /* else */
                
-               lsc->bound = META_ANONYMOUS;
+               lsc->msc_bound = META_ANONYMOUS;
                ++bound;
        }
 
@@ -354,11 +425,11 @@ meta_back_is_valid( struct metaconn *lc, int candidate )
                return 0;
        }
 
-       for ( i = 0, lsc = lc->conns; !META_LAST(lsc) && i < candidate; 
+       for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ) && i < candidate; 
                        ++i, ++lsc );
        
-       if ( !META_LAST(lsc) ) {
-               return( lsc->ld != NULL );
+       if ( !META_LAST( lsc ) ) {
+               return ( lsc->msc_ld != NULL );
        }
 
        return 0;
@@ -374,10 +445,11 @@ static int
 meta_back_rebind( LDAP *ld, LDAP_CONST char *url, ber_tag_t request,
        ber_int_t msgid, void *params )
 {
-       struct metasingleconn *lc = params;
+       struct metasingleconn   *lsc = params;
 
-       return ldap_bind_s( ld, lc->bound_dn.bv_val, lc->cred.bv_val,
-                       LDAP_AUTH_SIMPLE );
+       return ldap_sasl_bind_s( ld, lsc->msc_bound_ndn.bv_val,
+                       LDAP_SASL_SIMPLE, &lsc->msc_cred,
+                       NULL, NULL, NULL );
 }
 
 /*
@@ -386,19 +458,21 @@ meta_back_rebind( LDAP *ld, LDAP_CONST char *url, ber_tag_t request,
 int
 meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs )
 {
-       int i, rerr = LDAP_SUCCESS;
-       struct metasingleconn *lsc;
-       char *rmsg = NULL;
-       char *rmatch = NULL;
-       int     free_rmsg = 0, free_rmatch = 0;
-
-       for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
-               char *msg = NULL;
-               char *match = NULL;
+       int                     i,
+                               rerr = LDAP_SUCCESS;
+       struct metasingleconn   *lsc;
+       char                    *rmsg = NULL;
+       char                    *rmatch = NULL;
+       int                     free_rmsg = 0,
+                               free_rmatch = 0;
+
+       for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
+               char    *msg = NULL;
+               char    *match = NULL;
 
                rs->sr_err = LDAP_SUCCESS;
 
-               ldap_get_option( lsc->ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err );
+               ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        /*
                         * better check the type of error. In some cases
@@ -406,9 +480,9 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs )
                         * success if at least one of the targets gave
                         * positive result ...
                         */
-                       ldap_get_option( lsc->ld,
+                       ldap_get_option( lsc->msc_ld,
                                        LDAP_OPT_ERROR_STRING, &msg );
-                       ldap_get_option( lsc->ld,
+                       ldap_get_option( lsc->msc_ld,
                                        LDAP_OPT_MATCHED_DN, &match );
                        rs->sr_err = slap_map_api2result( rs );
 
index df2e87cefd5aad8ae823bbe1c23d7460fa75c19a..a018588d9c83a3b6422f718508053cd2f3fc6f6b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -95,7 +95,8 @@ meta_back_count_candidates(
        assert( li->ntargets != 0 );
 
        for ( i = 0; i < li->ntargets; ++i ) {
-               if ( meta_back_is_candidate( &li->targets[ i ]->suffix, ndn ) ) {
+               if ( meta_back_is_candidate( &li->targets[ i ]->mt_nsuffix, ndn ) )
+               {
                        ++cnt;
                }
        }
@@ -131,7 +132,7 @@ meta_back_select_unique_candidate(
                struct berval           *ndn
 )
 {
-       int i;
+       int     i;
        
        switch ( meta_back_count_candidates( li, ndn ) ) {
        case 1:
@@ -139,16 +140,17 @@ meta_back_select_unique_candidate(
        case 0:
        default:
                return ( li->defaulttarget == META_DEFAULT_TARGET_NONE
-                               ? -1 : li->defaulttarget );
+                               ? META_TARGET_NONE : li->defaulttarget );
        }
 
        for ( i = 0; i < li->ntargets; ++i ) {
-               if ( meta_back_is_candidate( &li->targets[ i ]->suffix, ndn ) ) {
+               if ( meta_back_is_candidate( &li->targets[ i ]->mt_nsuffix, ndn ) )
+               {
                        return i;
                }
        }
 
-       return -1;
+       return META_TARGET_NONE;
 }
 
 /*
@@ -170,7 +172,7 @@ meta_clear_unused_candidates(
                if ( i == candidate ) {
                        continue;
                }
-               meta_clear_one_candidate( &lc->conns[ i ], reallyclean );
+               meta_clear_one_candidate( &lc->mc_conns[ i ], reallyclean );
        }
 
        return 0;
@@ -187,27 +189,25 @@ meta_clear_one_candidate(
                int                     reallyclean
 )
 {
-       lsc->candidate = META_NOT_CANDIDATE;
+       lsc->msc_candidate = META_NOT_CANDIDATE;
 
        if ( !reallyclean ) {
                return 0;
        }
 
-       if ( lsc->ld ) {
-               ldap_unbind( lsc->ld );
-               lsc->ld = NULL;
+       if ( lsc->msc_ld ) {
+               ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
+               lsc->msc_ld = NULL;
        }
 
-       if ( lsc->bound_dn.bv_val != NULL ) {
-               ber_memfree( lsc->bound_dn.bv_val );
-               lsc->bound_dn.bv_val = NULL;
-               lsc->bound_dn.bv_len = 0;
+       if ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) {
+               ber_memfree( lsc->msc_bound_ndn.bv_val );
+               BER_BVZERO( &lsc->msc_bound_ndn );
        }
 
-       if ( lsc->cred.bv_val != NULL ) {
-               ber_memfree( lsc->cred.bv_val );
-               lsc->cred.bv_val = NULL;
-               lsc->cred.bv_len = 0;
+       if ( !BER_BVISNULL( &lsc->msc_cred ) ) {
+               ber_memfree( lsc->msc_cred.bv_val );
+               BER_BVZERO( &lsc->msc_cred );
        }
 
        return 0;
index cd3b9b1fc06dbe1cd188ed4497a26675530eb032..9a808a9581cf21fae120b4c5ceb66210e8daed5f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 int
 meta_back_compare( Operation *op, SlapReply *rs )
 {
-       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
-       struct metaconn *lc;
-       struct metasingleconn *lsc;
-       char *match = NULL, *err = NULL;
-       struct berval mmatch = BER_BVNULL;
-       int candidates = 0, last = 0, i, count = 0, rc;
-               int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS;
-       int *msgid;
-       dncookie dc;
+       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
+       struct metaconn         *lc;
+       struct metasingleconn   *lsc;
+       char                    *match = NULL,
+                               *err = NULL;
+       struct berval           mmatch = BER_BVNULL;
+       int                     candidates = 0,
+                               last = 0,
+                               i,
+                               count = 0,
+                               rc,
+                                       cres = LDAP_SUCCESS,
+                               rres = LDAP_SUCCESS,
+                               *msgid;
+       dncookie                dc;
 
        lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE,
                        &op->o_req_ndn, NULL );
@@ -52,7 +58,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
        }
        
        if ( !meta_back_dobind( lc, op ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }
@@ -69,12 +75,12 @@ meta_back_compare( Operation *op, SlapReply *rs )
        dc.rs = rs;
        dc.ctx = "compareDN";
 
-       for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
+       for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
                struct berval mdn = BER_BVNULL;
-               struct berval mapped_attr = op->oq_compare.rs_ava->aa_desc->ad_cname;
-               struct berval mapped_value = op->oq_compare.rs_ava->aa_value;
+               struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
+               struct berval mapped_value = op->orc_ava->aa_value;
 
-               if ( lsc->candidate != META_CANDIDATE ) {
+               if ( lsc->msc_candidate != META_CANDIDATE ) {
                        msgid[ i ] = -1;
                        continue;
                }
@@ -82,7 +88,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
                /*
                 * Rewrite the compare dn, if needed
                 */
-               dc.rwmap = &li->targets[ i ]->rwmap;
+               dc.rwmap = &li->targets[ i ]->mt_rwmap;
 
                switch ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
                case LDAP_UNWILLING_TO_PERFORM:
@@ -96,9 +102,9 @@ meta_back_compare( Operation *op, SlapReply *rs )
                /*
                 * if attr is objectClass, try to remap the value
                 */
-               if ( op->oq_compare.rs_ava->aa_desc == slap_schema.si_ad_objectClass ) {
-                       ldap_back_map( &li->targets[ i ]->rwmap.rwm_oc,
-                                       &op->oq_compare.rs_ava->aa_value,
+               if ( op->orc_ava->aa_desc == slap_schema.si_ad_objectClass ) {
+                       ldap_back_map( &li->targets[ i ]->mt_rwmap.rwm_oc,
+                                       &op->orc_ava->aa_value,
                                        &mapped_value, BACKLDAP_MAP );
 
                        if ( mapped_value.bv_val == NULL || mapped_value.bv_val[0] == '\0' ) {
@@ -108,18 +114,18 @@ meta_back_compare( Operation *op, SlapReply *rs )
                 * else try to remap the attribute
                 */
                } else {
-                       ldap_back_map( &li->targets[ i ]->rwmap.rwm_at,
-                               &op->oq_compare.rs_ava->aa_desc->ad_cname,
+                       ldap_back_map( &li->targets[ i ]->mt_rwmap.rwm_at,
+                               &op->orc_ava->aa_desc->ad_cname,
                                &mapped_attr, BACKLDAP_MAP );
                        if ( mapped_attr.bv_val == NULL || mapped_attr.bv_val[0] == '\0' ) {
                                continue;
                        }
 
-                       if ( op->oq_compare.rs_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
+                       if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
                        {
                                dc.ctx = "compareAttrDN";
 
-                               switch ( ldap_back_dn_massage( &dc, &op->oq_compare.rs_ava->aa_value, &mapped_value ) )
+                               switch ( ldap_back_dn_massage( &dc, &op->orc_ava->aa_value, &mapped_value ) )
                                {
                                case LDAP_UNWILLING_TO_PERFORM:
                                        rc = 1;
@@ -136,23 +142,27 @@ meta_back_compare( Operation *op, SlapReply *rs )
                 * that returns determines the result; a constraint on unicity
                 * of the result ought to be enforced
                 */
-               msgid[ i ] = ldap_compare( lc->conns[ i ].ld, mdn.bv_val,
-                               mapped_attr.bv_val, mapped_value.bv_val );
+                rc = ldap_compare_ext( lc->mc_conns[ i ].msc_ld, mdn.bv_val,
+                               mapped_attr.bv_val, &mapped_value,
+                               NULL, NULL, &msgid[ i ] );
 
                if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                        free( mdn.bv_val );
-                       mdn.bv_val = NULL;
+                       BER_BVZERO( &mdn );
                }
 
-               if ( mapped_attr.bv_val != op->oq_compare.rs_ava->aa_desc->ad_cname.bv_val ) {
+               if ( mapped_attr.bv_val != op->orc_ava->aa_desc->ad_cname.bv_val ) {
                        free( mapped_attr.bv_val );
+                       BER_BVZERO( &mapped_attr );
                }
 
-               if ( mapped_value.bv_val != op->oq_compare.rs_ava->aa_value.bv_val ) {
+               if ( mapped_value.bv_val != op->orc_ava->aa_value.bv_val ) {
                        free( mapped_value.bv_val );
+                       BER_BVZERO( &mapped_value );
                }
 
-               if ( msgid[ i ] == -1 ) {
+               if ( rc != LDAP_SUCCESS ) {
+                       /* FIXME: what should we do with the error? */
                        continue;
                }
 
@@ -167,7 +177,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
                /*
                 * FIXME: should we check for abandon?
                 */
-               for ( i = 0, lsc = lc->conns; !META_LAST(lsc); lsc++, i++ ) {
+               for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
                        int             lrc;
                        LDAPMessage     *res = NULL;
 
@@ -175,7 +185,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
                                continue;
                        }
 
-                       lrc = ldap_result( lsc->ld, msgid[ i ],
+                       lrc = ldap_result( lsc->msc_ld, msgid[ i ],
                                        0, NULL, &res );
 
                        if ( lrc == 0 ) {
@@ -193,8 +203,16 @@ meta_back_compare( Operation *op, SlapReply *rs )
                                        rc = -1;
                                        goto finish;
                                }
+
+                               rc = ldap_parse_result( lsc->msc_ld, res,
+                                               &rs->sr_err,
+                                               NULL, NULL, NULL, NULL, 1 );
+                               if ( rc != LDAP_SUCCESS ) {
+                                       rres = rc;
+                                       rc = -1;
+                                       goto finish;
+                               }
                                
-                               rs->sr_err = ldap_result2error( lsc->ld, res, 1 );
                                switch ( rs->sr_err ) {
                                case LDAP_COMPARE_TRUE:
                                case LDAP_COMPARE_FALSE:
@@ -217,13 +235,13 @@ meta_back_compare( Operation *op, SlapReply *rs )
                                        if ( err != NULL ) {
                                                free( err );
                                        }
-                                       ldap_get_option( lsc->ld,
+                                       ldap_get_option( lsc->msc_ld,
                                                LDAP_OPT_ERROR_STRING, &err );
 
                                        if ( match != NULL ) {
                                                free( match );
                                        }
-                                       ldap_get_option( lsc->ld,
+                                       ldap_get_option( lsc->msc_ld,
                                                LDAP_OPT_MATCHED_DN, &match );
                                        
                                        last = i;
index aec82d070f22eeadd69ac74a57584589b2b99da6..1459cef1a6c4eb8cdf21302cb9e85131eb273fed 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -45,8 +45,8 @@ new_target( void )
                return NULL;
        }
 
-       lt->rwmap.rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
-       if ( lt->rwmap.rwm_rw == NULL ) {
+       lt->mt_rwmap.rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+       if ( lt->mt_rwmap.rwm_rw == NULL ) {
                free( lt );
                 return NULL;
        }
@@ -62,17 +62,17 @@ new_target( void )
                rargv[ 0 ] = "rewriteContext";
                rargv[ 1 ] = "searchFilter";
                rargv[ 2 ] = NULL;
-               rewrite_parse( lt->rwmap.rwm_rw, "<suffix massage>", 
+               rewrite_parse( lt->mt_rwmap.rwm_rw, "<suffix massage>", 
                                1, 2, rargv );
 
                rargv[ 0 ] = "rewriteContext";
                rargv[ 1 ] = "default";
                rargv[ 2 ] = NULL;
-               rewrite_parse( lt->rwmap.rwm_rw, "<suffix massage>", 
+               rewrite_parse( lt->mt_rwmap.rwm_rw, "<suffix massage>", 
                                1, 2, rargv );
        }
 
-       ldap_back_map_init( &lt->rwmap.rwm_at, &mapping );
+       ldap_back_map_init( &lt->mt_rwmap.rwm_at, &mapping );
 
        return lt;
 }
@@ -161,8 +161,8 @@ meta_back_db_config(
                dn.bv_val = ludp->lud_dn;
                dn.bv_len = strlen( ludp->lud_dn );
 
-               rc = dnPrettyNormal( NULL, &dn, &li->targets[ i ]->psuffix,
-                       &li->targets[ i ]->suffix, NULL );
+               rc = dnPrettyNormal( NULL, &dn, &li->targets[ i ]->mt_psuffix,
+                       &li->targets[ i ]->mt_nsuffix, NULL );
                if( rc != LDAP_SUCCESS ) {
                        fprintf( stderr, "%s: line %d: "
                                        "target '%s' DN is invalid\n",
@@ -183,9 +183,9 @@ meta_back_db_config(
                        }
                }
 
-               li->targets[ i ]->uri = ldap_url_list2urls( ludp );
+               li->targets[ i ]->mt_uri = ldap_url_list2urls( ludp );
                ldap_free_urllist( ludp );
-               if ( li->targets[ i ]->uri == NULL) {
+               if ( li->targets[ i ]->mt_uri == NULL) {
                        fprintf( stderr, "%s: line %d: no memory?\n",
                                        fname, lineno );
                        return( 1 );
@@ -206,7 +206,7 @@ meta_back_db_config(
                /*
                 * uri MUST be a branch of a suffix!
                 */
-               if ( select_backend( &li->targets[ i ]->suffix, 0, 0 ) == NULL ) {
+               if ( select_backend( &li->targets[ i ]->mt_nsuffix, 0, 0 ) == NULL ) {
                        fprintf( stderr,
        "%s: line %d: <naming context> of URI does not resolve to a backend"
        " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
@@ -322,7 +322,7 @@ meta_back_db_config(
 
                dn.bv_val = argv[ 1 ];
                dn.bv_len = strlen( argv[ 1 ] );
-               if ( dnNormalize( 0, NULL, NULL, &dn, &li->targets[ i ]->binddn,
+               if ( dnNormalize( 0, NULL, NULL, &dn, &li->targets[ i ]->mt_binddn,
                        NULL ) != LDAP_SUCCESS )
                {
                        fprintf( stderr, "%s: line %d: "
@@ -348,7 +348,7 @@ meta_back_db_config(
                            fname, lineno );
                        return 1;
                }
-               ber_str2bv( argv[ 1 ], 0L, 1, &li->targets[ i ]->bindpw );
+               ber_str2bv( argv[ 1 ], 0L, 1, &li->targets[ i ]->mt_bindpw );
                
        /* save bind creds for referral rebinds? */
        } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
@@ -382,7 +382,7 @@ meta_back_db_config(
                dn.bv_val = argv[ 1 ];
                dn.bv_len = strlen( argv[ 1 ] );
                if ( dnNormalize( 0, NULL, NULL, &dn,
-                       &li->targets[ i ]->pseudorootdn, NULL ) != LDAP_SUCCESS )
+                       &li->targets[ i ]->mt_pseudorootdn, NULL ) != LDAP_SUCCESS )
                {
                        fprintf( stderr, "%s: line %d: "
                                        "pseudoroot DN '%s' is invalid\n",
@@ -407,7 +407,7 @@ meta_back_db_config(
                            fname, lineno );
                        return 1;
                }
-               ber_str2bv( argv[ 1 ], 0L, 1, &li->targets[ i ]->pseudorootpw );
+               ber_str2bv( argv[ 1 ], 0L, 1, &li->targets[ i ]->mt_pseudorootpw );
        
        /* dn massaging */
        } else if ( strcasecmp( argv[ 0 ], "suffixmassage" ) == 0 ) {
@@ -492,7 +492,7 @@ meta_back_db_config(
                 * FIXME: no extra rewrite capabilities should be added
                 * to the database
                 */
-               return suffix_massage_config( li->targets[ i ]->rwmap.rwm_rw,
+               return suffix_massage_config( li->targets[ i ]->mt_rwmap.rwm_rw,
                                &pvnc, &nvnc, &prnc, &nrnc );
                
        /* rewrite stuff ... */
@@ -503,12 +503,12 @@ meta_back_db_config(
                        if ( strcasecmp( argv[0], "rewriteEngine" ) == 0 ) {
                                li->rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
                        }
-                       return rewrite_parse(li->rwinfo, fname, lineno,
-                                       argc, argv); 
+                       return rewrite_parse( li->rwinfo, fname, lineno,
+                                       argc, argv ); 
                }
                
-               return rewrite_parse( li->targets[ i ]->rwmap.rwm_rw, fname, lineno,
-                               argc, argv );
+               return rewrite_parse( li->targets[ i ]->mt_rwmap.rwm_rw,
+                               fname, lineno, argc, argv );
 
        /* objectclass/attribute mapping */
        } else if ( strcasecmp( argv[ 0 ], "map" ) == 0 ) {
@@ -521,8 +521,8 @@ meta_back_db_config(
                        return 1;
                }
 
-               return ldap_back_map_config( &li->targets[ i ]->rwmap.rwm_oc, 
-                               &li->targets[ i ]->rwmap.rwm_at,
+               return ldap_back_map_config( &li->targets[ i ]->mt_rwmap.rwm_oc, 
+                               &li->targets[ i ]->mt_rwmap.rwm_at,
                                fname, lineno, argc, argv );
        /* anything else */
        } else {
index 00f1d9e9612fafed8de176e53758cf70037547ba..78fe9b4ccfd69bd89551aa2964cf6579544ed555 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -53,7 +53,7 @@ meta_back_conn_cmp(
        struct metaconn *lc1 = ( struct metaconn * )c1;
         struct metaconn *lc2 = ( struct metaconn * )c2;
        
-       return SLAP_PTRCMP( lc1->conn, lc2->conn );
+       return SLAP_PTRCMP( lc1->mc_conn, lc2->mc_conn );
 }
 
 /*
@@ -71,7 +71,7 @@ meta_back_conn_dup(
        struct metaconn *lc1 = ( struct metaconn * )c1;
        struct metaconn *lc2 = ( struct metaconn * )c2;
 
-       return( ( lc1->conn == lc2->conn ) ? -1 : 0 );
+       return( ( lc1->mc_conn == lc2->mc_conn ) ? -1 : 0 );
 }
 
 /*
@@ -87,15 +87,15 @@ ravl_print( Avlnode *root, int depth )
                return;
        }
        
-       ravl_print( root->avl_right, depth+1 );
+       ravl_print( root->avl_right, depth + 1 );
        
        for ( i = 0; i < depth; i++ ) {
                printf( "    " );
        }
 
-       printf( "c(%d) %d\n", ( ( struct metaconn * )root->avl_data )->conn->c_connid, root->avl_bf );
+       printf( "c(%d) %d\n", ( ( struct metaconn * )root->avl_data )->mc_conn->c_connid, root->avl_bf );
        
-       ravl_print( root->avl_left, depth+1 );
+       ravl_print( root->avl_left, depth + 1 );
 }
 
 static void
@@ -136,23 +136,21 @@ metaconn_alloc( int ntargets )
        /*
         * make it a null-terminated array ...
         */
-       lc->conns = ch_calloc( sizeof( struct metasingleconn ), ntargets+1 );
-       if ( lc->conns == NULL ) {
+       lc->mc_conns = ch_calloc( sizeof( struct metasingleconn ), ntargets+1 );
+       if ( lc->mc_conns == NULL ) {
                free( lc );
                return NULL;
        }
-       lc->conns[ ntargets ].candidate = META_LAST_CONN;
+       lc->mc_conns[ ntargets ].msc_candidate = META_LAST_CONN;
 
        for ( ; ntargets-- > 0; ) {
-               lc->conns[ ntargets ].ld = NULL;
-               lc->conns[ ntargets ].bound_dn.bv_val = NULL;
-               lc->conns[ ntargets ].bound_dn.bv_len = 0;
-               lc->conns[ ntargets ].cred.bv_val = NULL;
-               lc->conns[ ntargets ].cred.bv_len = 0;
-               lc->conns[ ntargets ].bound = META_UNBOUND;
+               lc->mc_conns[ ntargets ].msc_ld = NULL;
+               BER_BVZERO( &lc->mc_conns[ ntargets ].msc_bound_ndn );
+               BER_BVZERO( &lc->mc_conns[ ntargets ].msc_cred );
+               lc->mc_conns[ ntargets ].msc_bound = META_UNBOUND;
        }
 
-       lc->bound_target = META_BOUND_NONE;
+       lc->mc_bound_target = META_BOUND_NONE;
 
        return lc;
 }
@@ -171,8 +169,8 @@ metaconn_free(
                return;
        }
        
-       if ( lc->conns ) {
-               ch_free( lc->conns );
+       if ( lc->mc_conns ) {
+               ch_free( lc->mc_conns );
        }
 
        free( lc );
@@ -198,14 +196,14 @@ init_one_conn(
        /*
         * Already init'ed
         */
-       if ( lsc->ld != NULL ) {
+       if ( lsc->msc_ld != NULL ) {
                return LDAP_SUCCESS;
        }
        
        /*
         * Attempts to initialize the connection to the target ds
         */
-       rs->sr_err = ldap_initialize( &lsc->ld, lt->uri );
+       rs->sr_err = ldap_initialize( &lsc->msc_ld, lt->mt_uri );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                return slap_map_api2result( rs );
        }
@@ -215,32 +213,33 @@ init_one_conn(
         * bound with a particular version, then so can we.
         */
        vers = op->o_conn->c_protocol;
-       ldap_set_option( lsc->ld, LDAP_OPT_PROTOCOL_VERSION, &vers );
+       ldap_set_option( lsc->msc_ld, LDAP_OPT_PROTOCOL_VERSION, &vers );
        /* FIXME: configurable? */
-       ldap_set_option(lsc->ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON);
+       ldap_set_option( lsc->msc_ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON );
 
        /*
         * Set the network timeout if set
         */
        if (li->network_timeout != 0){
-               struct timeval network_timeout;
+               struct timeval  network_timeout;
 
                network_timeout.tv_usec = 0;
                network_timeout.tv_sec = li->network_timeout;
 
-               ldap_set_option( lsc->ld, LDAP_OPT_NETWORK_TIMEOUT, (void *) &network_timeout);
+               ldap_set_option( lsc->msc_ld, LDAP_OPT_NETWORK_TIMEOUT,
+                               (void *)&network_timeout );
        }
 
        /*
         * Sets a cookie for the rewrite session
         */
-       ( void )rewrite_session_init( lt->rwmap.rwm_rw, op->o_conn );
+       ( void )rewrite_session_init( lt->mt_rwmap.rwm_rw, op->o_conn );
 
        /*
-        * If the connection dn is not null, an attempt to rewrite it is made
+        * If the connection DN is not null, an attempt to rewrite it is made
         */
        if ( op->o_conn->c_dn.bv_len != 0 ) {
-               dc.rwmap = &lt->rwmap;
+               dc.rwmap = &lt->mt_rwmap;
                dc.conn = op->o_conn;
                dc.rs = rs;
                dc.ctx = "bindDN";
@@ -249,28 +248,29 @@ init_one_conn(
                 * Rewrite the bind dn if needed
                 */
                if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn,
-                                       &lsc->bound_dn) ) {
+                                       &lsc->msc_bound_ndn ) )
+               {
                        send_ldap_result( op, rs );
                        return rs->sr_err;
                }
 
                /* copy the DN idf needed */
-               if ( lsc->bound_dn.bv_val == op->o_conn->c_dn.bv_val ) {
-                       ber_dupbv( &lsc->bound_dn, &op->o_conn->c_dn );
+               if ( lsc->msc_bound_ndn.bv_val == op->o_conn->c_dn.bv_val ) {
+                       ber_dupbv( &lsc->msc_bound_ndn, &op->o_conn->c_dn );
                }
 
-               assert( lsc->bound_dn.bv_val );
+               assert( lsc->msc_bound_ndn.bv_val );
 
        } else {
-               ber_str2bv( "", 0, 1, &lsc->bound_dn );
+               ber_str2bv( "", 0, 1, &lsc->msc_bound_ndn );
        }
 
-       lsc->bound = META_UNBOUND;
+       lsc->msc_bound = META_UNBOUND;
 
        /*
         * The candidate is activated
         */
-       lsc->candidate = META_CANDIDATE;
+       lsc->msc_candidate = META_CANDIDATE;
        return LDAP_SUCCESS;
 }
 
@@ -295,12 +295,14 @@ meta_back_getconn(
                int             *candidate )
 {
        struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
-       struct metaconn *lc, lc_curr;
-       int cached = -1, i = -1, err = LDAP_SUCCESS;
-       int new_conn = 0;
+       struct metaconn *lc, lc_curr;
+       int             cached = META_TARGET_NONE,
+                       i = META_TARGET_NONE,
+                       err = LDAP_SUCCESS,
+                       new_conn = 0;
 
        /* Searches for a metaconn in the avl tree */
-       lc_curr.conn = op->o_conn;
+       lc_curr.mc_conn = op->o_conn;
        ldap_pvt_thread_mutex_lock( &li->conn_mutex );
        lc = (struct metaconn *)avl_find( li->conntree, 
                (caddr_t)&lc_curr, meta_back_conn_cmp );
@@ -309,10 +311,37 @@ meta_back_getconn(
        /* Looks like we didn't get a bind. Open a new session... */
        if ( !lc ) {
                lc = metaconn_alloc( li->ntargets );
-               lc->conn = op->o_conn;
+               lc->mc_conn = op->o_conn;
                new_conn = 1;
        }
 
+       /*
+        * require all connections ...
+        */
+       if ( op_type == META_OP_REQUIRE_ALL ) {
+               for ( i = 0; i < li->ntargets; i++ ) {
+
+                       /*
+                        * The target is activated; if needed, it is
+                        * also init'd
+                        */
+                       int lerr = init_one_conn( op, rs, li->targets[ i ],
+                                       &lc->mc_conns[ i ] );
+                       if ( lerr != LDAP_SUCCESS ) {
+                               
+                               /*
+                                * FIXME: in case one target cannot
+                                * be init'd, should the other ones
+                                * be tried?
+                                */
+                               ( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
+                               err = lerr;
+                               continue;
+                       }
+               }
+               goto done;
+       }
+       
        /*
         * looks in cache, if any
         */
@@ -326,14 +355,14 @@ meta_back_getconn(
                 * tries to get a unique candidate
                 * (takes care of default target 
                 */
-               if ( i < 0 ) {
+               if ( i == META_TARGET_NONE ) {
                        i = meta_back_select_unique_candidate( li, ndn );
                }
 
                /*
                 * if any is found, inits the connection
                 */
-               if ( i < 0 ) {
+               if ( i == META_TARGET_NONE ) {
                        if ( new_conn ) {
                                metaconn_free( lc );
                        }
@@ -343,8 +372,8 @@ meta_back_getconn(
                }
                                
                Debug( LDAP_DEBUG_CACHE,
-       "==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s",
-                               i, ndn->bv_val, "" );
+       "==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n",
+                               i, ndn->bv_val, 0 );
 
                /*
                 * Clear all other candidates
@@ -357,7 +386,7 @@ meta_back_getconn(
                 * sends the appropriate result.
                 */
                err = init_one_conn( op, rs, li->targets[ i ],
-                               &lc->conns[ i ] );
+                               &lc->mc_conns[ i ] );
                if ( err != LDAP_SUCCESS ) {
                
                        /*
@@ -365,7 +394,7 @@ meta_back_getconn(
                         * be init'd, should the other ones
                         * be tried?
                         */
-                       ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
+                       ( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
                        if ( new_conn ) {
                                metaconn_free( lc );
                        }
@@ -376,38 +405,14 @@ meta_back_getconn(
                        *candidate = i;
                }
 
-       /*
-        * require all connections ...
-        */
-       } else if (op_type == META_OP_REQUIRE_ALL) {
-               for ( i = 0; i < li->ntargets; i++ ) {
-
-                       /*
-                        * The target is activated; if needed, it is
-                        * also init'd
-                        */
-                       int lerr = init_one_conn( op, rs, li->targets[ i ],
-                                       &lc->conns[ i ] );
-                       if ( lerr != LDAP_SUCCESS ) {
-                               
-                               /*
-                                * FIXME: in case one target cannot
-                                * be init'd, should the other ones
-                                * be tried?
-                                */
-                               ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
-                               err = lerr;
-                               continue;
-                       }
-               }
-
        /*
         * if no unique candidate ...
         */
        } else {
                for ( i = 0; i < li->ntargets; i++ ) {
                        if ( i == cached 
-               || meta_back_is_candidate( &li->targets[ i ]->suffix, ndn ) ) {
+                               || meta_back_is_candidate( &li->targets[ i ]->mt_nsuffix, ndn ) )
+                       {
 
                                /*
                                 * The target is activated; if needed, it is
@@ -415,7 +420,7 @@ meta_back_getconn(
                                 */
                                int lerr = init_one_conn( op, rs,
                                                li->targets[ i ],
-                                               &lc->conns[ i ] );
+                                               &lc->mc_conns[ i ] );
                                if ( lerr != LDAP_SUCCESS ) {
                                
                                        /*
@@ -423,7 +428,7 @@ meta_back_getconn(
                                         * be init'd, should the other ones
                                         * be tried?
                                         */
-                                       ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
+                                       ( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
                                        err = lerr;
                                        continue;
                                }
@@ -431,6 +436,7 @@ meta_back_getconn(
                }
        }
 
+done:;
        /* clear out init_one_conn non-fatal errors */
        rs->sr_err = LDAP_SUCCESS;
        rs->sr_text = NULL;
@@ -451,8 +457,8 @@ meta_back_getconn(
                ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
 
                Debug( LDAP_DEBUG_TRACE,
-                       "=>meta_back_getconn: conn %ld inserted\n%s%s",
-                       lc->conn->c_connid, "", "" );
+                       "=>meta_back_getconn: conn %ld inserted\n",
+                       lc->mc_conn->c_connid, 0, 0 );
                
                /*
                 * Err could be -1 in case a duplicate metaconn is inserted
@@ -463,10 +469,11 @@ meta_back_getconn(
                        metaconn_free( lc );
                        return NULL;
                }
+
        } else {
                Debug( LDAP_DEBUG_TRACE,
-                       "=>meta_back_getconn: conn %ld fetched\n%s%s",
-                       lc->conn->c_connid, "", "" );
+                       "=>meta_back_getconn: conn %ld fetched\n",
+                       lc->mc_conn->c_connid, 0, 0 );
        }
        
        return lc;
index 18973f0c28d5159ce233d7700b61cbc870deb05b..13f8f527d982cf26f2365026d785872d4ee9fc1c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -47,9 +47,14 @@ meta_back_delete( Operation *op, SlapReply *rs )
                return -1;
        }
        
-       if ( !meta_back_dobind( lc, op )
-                       || !meta_back_is_valid( lc, candidate ) ) {
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                return -1;
        }
@@ -57,7 +62,7 @@ meta_back_delete( Operation *op, SlapReply *rs )
        /*
         * Rewrite the compare dn, if needed
         */
-       dc.rwmap = &li->targets[ candidate ]->rwmap;
+       dc.rwmap = &li->targets[ candidate ]->mt_rwmap;
        dc.conn = op->o_conn;
        dc.rs = rs;
        dc.ctx = "deleteDN";
@@ -67,10 +72,12 @@ meta_back_delete( Operation *op, SlapReply *rs )
                return -1;
        }
 
-       ldap_delete_s( lc->conns[ candidate ].ld, mdn.bv_val );
+       (void)ldap_delete_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
+                       NULL, NULL );
 
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
+               BER_BVZERO( &mdn );
        }
        
        return meta_back_op_result( lc, op, rs );
index dbdc0fdef2991c2409d9ee2f5552a77f7ee5c395..c1020c73409aeff4c88886e7a3120476ac345474 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -96,7 +96,7 @@ meta_dncache_get_target(
 {
        struct metadncacheentry tmp_entry, *entry;
        time_t curr_time;
-       int target = -1;
+       int target = META_TARGET_NONE;
 
        assert( cache );
        assert( ndn );
@@ -115,6 +115,7 @@ meta_dncache_get_target(
                 */
                if ( cache->ttl < 0 ) { 
                        target = entry->target;
+
                } else {
 
                        /*
index c32bf61427077c9ba67d2e23c3efad0e1ab8591e..cf4bf52c9f97d7a9965fd06bd4076df8e1e51f82 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -112,7 +112,7 @@ meta_back_group(
        } /* else: do the search */
 
        candidate = meta_back_select_unique_candidate( li, gr_ndn );
-       if ( candidate == -1 ) {
+       if ( candidate == META_TARGET_NONE ) {
                goto cleanup;
        }
 
index 40196421d55792052e1d33623c6395ec8177eede..e7883ce14738fb4077c9eda321983e02961997d3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -110,22 +110,23 @@ conn_free(
        void *v_lc
 )
 {
-       struct metaconn *lc = v_lc;
-       struct metasingleconn *lsc;
+       struct metaconn         *lc = v_lc;
+       struct metasingleconn   *lsc;
 
-       for ( lsc = lc->conns; !META_LAST(lsc); lsc++ ) {
-               if ( lsc->ld != NULL ) {
-                       ldap_unbind( lsc->ld );
+       for ( lsc = lc->mc_conns; !META_LAST( lsc ); lsc++ ) {
+               if ( lsc->msc_ld != NULL ) {
+                       ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
                }
-               if ( lsc->bound_dn.bv_val ) {
-                       ber_memfree( lsc->bound_dn.bv_val );
+               if ( !BER_BVISNULL( &lsc->msc_bound_ndn ) ) {
+                       ber_memfree( lsc->msc_bound_ndn.bv_val );
                }
-               if ( lsc->cred.bv_val ) {
-                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
-                       ber_memfree( lsc->cred.bv_val );
+               if ( !BER_BVISNULL( &lsc->msc_cred ) ) {
+                       /* destroy sensitive data */
+                       memset( lsc->msc_cred.bv_val, 0, lsc->msc_cred.bv_len );
+                       ber_memfree( lsc->msc_cred.bv_val );
                }
        }
-       free( lc->conns );
+       free( lc->mc_conns );
        free( lc );
 }
 
@@ -143,34 +144,34 @@ target_free(
                struct metatarget *lt
 )
 {
-       if ( lt->uri ) {
-               free( lt->uri );
+       if ( lt->mt_uri ) {
+               free( lt->mt_uri );
        }
-       if ( lt->psuffix.bv_val ) {
-               free( lt->psuffix.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_psuffix ) ) {
+               free( lt->mt_psuffix.bv_val );
        }
-       if ( lt->suffix.bv_val ) {
-               free( lt->suffix.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_nsuffix ) ) {
+               free( lt->mt_nsuffix.bv_val );
        }
-       if ( lt->binddn.bv_val ) {
-               free( lt->binddn.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_binddn ) ) {
+               free( lt->mt_binddn.bv_val );
        }
-       if ( lt->bindpw.bv_val ) {
-               free( lt->bindpw.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_bindpw ) ) {
+               free( lt->mt_bindpw.bv_val );
        }
-       if ( lt->pseudorootdn.bv_val ) {
-               free( lt->pseudorootdn.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_pseudorootdn ) ) {
+               free( lt->mt_pseudorootdn.bv_val );
        }
-       if ( lt->pseudorootpw.bv_val ) {
-               free( lt->pseudorootpw.bv_val );
+       if ( !BER_BVISNULL( &lt->mt_pseudorootpw ) ) {
+               free( lt->mt_pseudorootpw.bv_val );
        }
-       if ( lt->rwmap.rwm_rw ) {
-               rewrite_info_delete( &lt->rwmap.rwm_rw );
+       if ( lt->mt_rwmap.rwm_rw ) {
+               rewrite_info_delete( &lt->mt_rwmap.rwm_rw );
        }
-       avl_free( lt->rwmap.rwm_oc.remap, NULL );
-       avl_free( lt->rwmap.rwm_oc.map, mapping_free );
-       avl_free( lt->rwmap.rwm_at.remap, NULL );
-       avl_free( lt->rwmap.rwm_at.map, mapping_free );
+       avl_free( lt->mt_rwmap.rwm_oc.remap, NULL );
+       avl_free( lt->mt_rwmap.rwm_oc.map, mapping_free );
+       avl_free( lt->mt_rwmap.rwm_at.remap, NULL );
+       avl_free( lt->mt_rwmap.rwm_at.map, mapping_free );
 }
 
 int
index a76c5f0f856f92ddc1418dbaa69fd2937966ff12..a607369b7edbd2c5db1ad829f2dcb95fb3285e91 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ mapping_cmp ( const void *c1, const void *c2 )
        struct ldapmapping *map2 = (struct ldapmapping *)c2;
        int rc = map1->src.bv_len - map2->src.bv_len;
        if (rc) return rc;
-       return ( strcasecmp(map1->src.bv_val, map2->src.bv_val) );
+       return ( strcasecmp( map1->src.bv_val, map2->src.bv_val ) );
 }
 
 int
@@ -79,7 +79,7 @@ mapping_dup ( void *c1, void *c2 )
        struct ldapmapping *map1 = (struct ldapmapping *)c1;
        struct ldapmapping *map2 = (struct ldapmapping *)c2;
 
-       return( ( strcasecmp(map1->src.bv_val, map2->src.bv_val) == 0 ) ? -1 : 0 );
+       return ( ( strcasecmp( map1->src.bv_val, map2->src.bv_val ) == 0 ) ? -1 : 0 );
 }
 
 void
@@ -116,23 +116,25 @@ ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
        Avlnode *tree;
        struct ldapmapping *mapping, fmapping;
 
-       if (remap == BACKLDAP_REMAP)
+       if ( remap == BACKLDAP_REMAP ) {
                tree = map->remap;
-       else
+       } else {
                tree = map->map;
+       }
 
-       bv->bv_len = 0;
-       bv->bv_val = NULL;
+       BER_BVZERO( bv );
        fmapping.src = *s;
        mapping = (struct ldapmapping *)avl_find( tree, (caddr_t)&fmapping, mapping_cmp );
-       if (mapping != NULL) {
-               if ( mapping->dst.bv_val )
+       if ( mapping != NULL ) {
+               if ( !BER_BVISNULL( &mapping->dst ) ) {
                        *bv = mapping->dst;
+               }
                return;
        }
 
-       if (!map->drop_missing)
+       if ( !map->drop_missing ) {
                *bv = *s;
+       }
 
        return;
 }
@@ -149,28 +151,29 @@ ldap_back_map_attrs(
        char **na;
        struct berval mapped;
 
-       if (an == NULL) {
+       if ( an == NULL ) {
                *mapped_attrs = NULL;
                return LDAP_SUCCESS;
        }
 
-       for (i = 0; an[i].an_name.bv_val; i++) {
-               /*  */
-       }
+       for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ )
+               /*  */ ;
 
        na = (char **)ch_calloc( i + 1, sizeof(char *) );
-       if (na == NULL) {
+       if ( na == NULL ) {
                *mapped_attrs = NULL;
                return LDAP_NO_MEMORY;
        }
 
-       for (i = j = 0; an[i].an_name.bv_val; i++) {
-               ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
-               if (mapped.bv_val != NULL && mapped.bv_val != '\0')
+       for ( i = j = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
+               ldap_back_map( at_map, &an[i].an_name, &mapped, remap );
+               if ( !BER_BVISNULL( &mapped ) && !BER_BVISEMPTY( &mapped ) ) {
                        na[j++] = mapped.bv_val;
+               }
        }
-       if (j == 0 && i != 0)
+       if ( j == 0 && i != 0 ) {
                na[j++] = LDAP_NO_ATTRS;
+       }
        na[j] = NULL;
 
        *mapped_attrs = na;
@@ -190,12 +193,12 @@ map_attr_value(
        int                     freeval = 0;
 
        ldap_back_map( &dc->rwmap->rwm_at, &ad->ad_cname, mapped_attr, remap );
-       if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0') {
+       if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
                /*
                 * FIXME: are we sure we need to search oc_map if at_map fails?
                 */
                ldap_back_map( &dc->rwmap->rwm_oc, &ad->ad_cname, mapped_attr, remap );
-               if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0' ) {
+               if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
                        *mapped_attr = ad->ad_cname;
                }
        }
@@ -228,7 +231,7 @@ map_attr_value(
 
        } else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {
                ldap_back_map( &dc->rwmap->rwm_oc, value, &vtmp, remap );
-               if ( vtmp.bv_val == NULL || vtmp.bv_val[0] == '\0' ) {
+               if ( BER_BVISNULL( &vtmp ) || BER_BVISEMPTY( &vtmp ) ) {
                        vtmp = *value;
                }
                
@@ -341,13 +344,13 @@ ldap_back_int_filter_map_rewrite(
 
                /* cannot be a DN ... */
 
-               fstr->bv_len = atmp.bv_len + ( sizeof("(=*)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 128 );
+               fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
+               fstr->bv_val = malloc( fstr->bv_len + 128 ); /* FIXME: why 128 ? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        atmp.bv_val );
 
-               if ( f->f_sub_initial.bv_val != NULL ) {
+               if ( !BER_BVISNULL( &f->f_sub_initial ) ) {
                        len = fstr->bv_len;
 
                        filter_escape_value( &f->f_sub_initial, &vtmp );
@@ -363,7 +366,7 @@ ldap_back_int_filter_map_rewrite(
                }
 
                if ( f->f_sub_any != NULL ) {
-                       for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) {
+                       for ( i = 0; !BER_BVISNULL( &f->f_sub_any[i] ); i++ ) {
                                len = fstr->bv_len;
                                filter_escape_value( &f->f_sub_any[i], &vtmp );
 
@@ -377,7 +380,7 @@ ldap_back_int_filter_map_rewrite(
                        }
                }
 
-               if ( f->f_sub_final.bv_val != NULL ) {
+               if ( !BER_BVISNULL( &f->f_sub_final ) ) {
                        len = fstr->bv_len;
 
                        filter_escape_value( &f->f_sub_final, &vtmp );
@@ -401,7 +404,7 @@ ldap_back_int_filter_map_rewrite(
                        return -1;
                }
 
-               fstr->bv_len = atmp.bv_len + ( sizeof("(=*)") - 1 );
+               fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
                fstr->bv_val = malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
@@ -411,8 +414,8 @@ ldap_back_int_filter_map_rewrite(
        case LDAP_FILTER_AND:
        case LDAP_FILTER_OR:
        case LDAP_FILTER_NOT:
-               fstr->bv_len = sizeof("(%)") - 1;
-               fstr->bv_val = malloc( fstr->bv_len + 128 );
+               fstr->bv_len = STRLENOF( "(%)" );
+               fstr->bv_val = malloc( fstr->bv_len + 128 );    /* FIXME: why 128? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
                        f->f_choice == LDAP_FILTER_AND ? '&' :
@@ -446,24 +449,22 @@ ldap_back_int_filter_map_rewrite(
                        }
 
                } else {
-                       atmp.bv_len = 0;
-                       atmp.bv_val = "";
-                       
+                       BER_BVSTR( &atmp, "" );
                        filter_escape_value( &f->f_mr_value, &vtmp );
                }
-                       
 
+               /* FIXME: cleanup (less ?: operators...) */
                fstr->bv_len = atmp.bv_len +
-                       ( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) +
-                       ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) +
-                       vtmp.bv_len + ( sizeof("(:=)") - 1 );
+                       ( f->f_mr_dnattrs ? STRLENOF( ":dn" ) : 0 ) +
+                       ( !BER_BVISEMPTY( &f->f_mr_rule_text ) ? f->f_mr_rule_text.bv_len + 1 : 0 ) +
+                       vtmp.bv_len + ( STRLENOF( "(:=)" ) );
                fstr->bv_val = malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
                        atmp.bv_val,
                        f->f_mr_dnattrs ? ":dn" : "",
-                       f->f_mr_rule_text.bv_len ? ":" : "",
-                       f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "",
+                       !BER_BVISEMPTY( &f->f_mr_rule_text ) ? ":" : "",
+                       !BER_BVISEMPTY( &f->f_mr_rule_text ) ? f->f_mr_rule_text.bv_val : "",
                        vtmp.bv_val );
                ber_memfree( vtmp.bv_val );
                } break;
@@ -523,6 +524,7 @@ ldap_back_filter_map_rewrite(
        case REWRITE_REGEXEC_OK:
                if ( !BER_BVISNULL( fstr ) ) {
                        fstr->bv_len = strlen( fstr->bv_val );
+
                } else {
                        *fstr = ftmp;
                }
@@ -579,6 +581,14 @@ ldap_back_referral_result_rewrite(
                        continue;
                }
 
+               /* FIXME: URLs like "ldap:///dc=suffix" if passed
+                * thru ldap_url_parse() and ldap_url_desc2str()
+                * get rewritten as "ldap:///dc=suffix??base";
+                * we don't want this to occur... */
+               if ( ludp->lud_scope == LDAP_SCOPE_BASE ) {
+                       ludp->lud_scope = LDAP_SCOPE_DEFAULT;
+               }
+
                ber_str2bv( ludp->lud_dn, 0, 0, &olddn );
                
                rc = ldap_back_dn_massage( dc, &olddn, &dn );
@@ -608,7 +618,8 @@ ldap_back_referral_result_rewrite(
                                newurl = ldap_url_desc2str( ludp );
                                if ( newurl == NULL ) {
                                        /* FIXME: leave attr untouched
-                                        * even if ldap_url_desc2str failed... */
+                                        * even if ldap_url_desc2str failed...
+                                        */
                                        break;
                                }
 
@@ -642,10 +653,13 @@ ldap_dnattr_rewrite(
        struct berval   bv;
        int             i, last;
 
-       for ( last = 0; a_vals[last].bv_val != NULL; last++ );
+       assert( a_vals != NULL );
+
+       for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ )
+               ;
        last--;
 
-       for ( i = 0; a_vals[i].bv_val != NULL; i++ ) {
+       for ( i = 0; !BER_BVISNULL( &a_vals[i] ); i++ ) {
                switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
@@ -654,17 +668,16 @@ ldap_dnattr_rewrite(
                         * it should be when searching (e.g. ACLs).
                         */
                        ch_free( a_vals[i].bv_val );
-                       if (last > i ) {
+                       if ( last > i ) {
                                a_vals[i] = a_vals[last];
                        }
-                       a_vals[last].bv_len = 0;
-                       a_vals[last].bv_val = NULL;
+                       BER_BVZERO( &a_vals[last] );
                        last--;
                        break;
 
                default:
                        /* leave attr untouched if massage failed */
-                       if ( bv.bv_val && bv.bv_val != a_vals[i].bv_val ) {
+                       if ( !BER_BVISNULL( &bv ) && bv.bv_val != a_vals[i].bv_val ) {
                                ch_free( a_vals[i].bv_val );
                                a_vals[i] = bv;
                        }
@@ -684,10 +697,13 @@ ldap_dnattr_result_rewrite(
        struct berval   bv;
        int             i, last;
 
-       for ( last = 0; a_vals[last].bv_val; last++ );
+       assert( a_vals != NULL );
+
+       for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ )
+               ;
        last--;
 
-       for ( i = 0; a_vals[i].bv_val; i++ ) {
+       for ( i = 0; !BER_BVISNULL( &a_vals[i] ); i++ ) {
                switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
@@ -705,7 +721,7 @@ ldap_dnattr_result_rewrite(
 
                default:
                        /* leave attr untouched if massage failed */
-                       if ( bv.bv_val && a_vals[i].bv_val != bv.bv_val ) {
+                       if ( !BER_BVISNULL( &bv ) && a_vals[i].bv_val != bv.bv_val ) {
                                LBER_FREE( a_vals[i].bv_val );
                                a_vals[i] = bv;
                        }
index 8071a4141c5d1e97fe7b54c0106b503204e098b8..77e92da1455e791ed06a2c48168e3c4c19a2dc12 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
 int
 meta_back_modify( Operation *op, SlapReply *rs )
 {
-       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
-       struct metaconn         *lc;
-       int                     rc = 0;
-       LDAPMod                 **modv = NULL;
-       LDAPMod                 *mods = NULL;
-       Modifications           *ml;
-       int                     candidate = -1, i;
-       struct berval           mdn = BER_BVNULL;
-       struct berval           mapped;
-       dncookie                dc;
+       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
+       struct metaconn *lc;
+       int             rc = 0;
+       LDAPMod         **modv = NULL;
+       LDAPMod         *mods = NULL;
+       Modifications   *ml;
+       int             candidate = -1, i;
+       int             isupdate;
+       struct berval   mdn = BER_BVNULL;
+       struct berval   mapped;
+       dncookie        dc;
 
        lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
                        &op->o_req_ndn, &candidate );
@@ -52,9 +53,14 @@ meta_back_modify( Operation *op, SlapReply *rs )
                goto cleanup;
        }
        
-       if ( !meta_back_dobind( lc, op )
-                       || !meta_back_is_valid( lc, candidate ) ) {
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                rc = -1;
                goto cleanup;
        }
@@ -62,7 +68,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
        /*
         * Rewrite the modify dn, if needed
         */
-       dc.rwmap = &li->targets[ candidate ]->rwmap;
+       dc.rwmap = &li->targets[ candidate ]->mt_rwmap;
        dc.conn = op->o_conn;
        dc.rs = rs;
        dc.ctx = "modifyDN";
@@ -72,7 +78,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
                goto cleanup;
        }
 
-       for ( i = 0, ml = op->oq_modify.rs_modlist; ml; i++ ,ml = ml->sml_next )
+       for ( i = 0, ml = op->orm_modlist; ml; i++ ,ml = ml->sml_next )
                ;
 
        mods = ch_malloc( sizeof( LDAPMod )*i );
@@ -89,18 +95,27 @@ meta_back_modify( Operation *op, SlapReply *rs )
        }
 
        dc.ctx = "modifyAttrDN";
-       for ( i = 0, ml = op->oq_modify.rs_modlist; ml; ml = ml->sml_next ) {
-               int j;
+       isupdate = be_shadow_update( op );
+       for ( i = 0, ml = op->orm_modlist; ml; ml = ml->sml_next ) {
+               int     j, is_oc = 0;
 
-               if ( ml->sml_desc->ad_type->sat_no_user_mod  ) {
+               if ( !isupdate && ml->sml_desc->ad_type->sat_no_user_mod  ) {
                        continue;
                }
 
-               ldap_back_map( &li->targets[ candidate ]->rwmap.rwm_at,
-                               &ml->sml_desc->ad_cname, &mapped,
-                               BACKLDAP_MAP );
-               if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
-                       continue;
+               if ( ml->sml_desc == slap_schema.si_ad_objectClass 
+                               || ml->sml_desc == slap_schema.si_ad_structuralObjectClass )
+               {
+                       is_oc = 1;
+                       mapped = ml->sml_desc->ad_cname;
+
+               } else {
+                       ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_at,
+                                       &ml->sml_desc->ad_cname, &mapped,
+                                       BACKLDAP_MAP );
+                       if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) {
+                               continue;
+                       }
                }
 
                modv[ i ] = &mods[ i ];
@@ -112,18 +127,45 @@ meta_back_modify( Operation *op, SlapReply *rs )
                 * to allow their use in ACLs at the back-ldap
                 * level.
                 */
-               if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid,
-                                       SLAPD_DN_SYNTAX ) == 0 ) {
-                       ( void )ldap_dnattr_rewrite( &dc, ml->sml_values );
-               }
-
-               if ( ml->sml_values != NULL ){
-                       for (j = 0; ml->sml_values[ j ].bv_val; j++);
-                       mods[ i ].mod_bvalues = (struct berval **)ch_malloc((j+1) *
-                               sizeof(struct berval *));
-                       for (j = 0; ml->sml_values[ j ].bv_val; j++)
-                               mods[ i ].mod_bvalues[ j ] = &ml->sml_values[j];
-                       mods[ i ].mod_bvalues[ j ] = NULL;
+               if ( ml->sml_values != NULL ) {
+                       if ( is_oc ) {
+                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ )
+                                       ;
+                               mods[ i ].mod_bvalues =
+                                       (struct berval **)ch_malloc( ( j + 1 ) *
+                                       sizeof( struct berval * ) );
+                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ ) {
+                                       ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_oc,
+                                                       &ml->sml_values[ j ],
+                                                       &mapped, BACKLDAP_MAP );
+                                       if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) )
+                                       {
+                                               continue;
+                                       }
+                                       mods[ i ].mod_bvalues[ j ] = &mapped;
+                               }
+                               mods[ i ].mod_bvalues[ j ] = NULL;
+
+                       } else {
+                               if ( ml->sml_desc->ad_type->sat_syntax ==
+                                               slap_schema.si_syn_distinguishedName )
+                               {
+                                       ( void )ldap_dnattr_rewrite( &dc, ml->sml_values );
+                                       if ( ml->sml_values == NULL ) {
+                                               continue;
+                                       }
+                               }
+
+                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ )
+                                       ;
+                               mods[ i ].mod_bvalues =
+                                       (struct berval **)ch_malloc( ( j + 1 ) *
+                                       sizeof( struct berval * ) );
+                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ ) {
+                                       mods[ i ].mod_bvalues[ j ] = &ml->sml_values[ j ];
+                               }
+                               mods[ i ].mod_bvalues[ j ] = NULL;
+                       }
 
                } else {
                        mods[ i ].mod_bvalues = NULL;
@@ -133,27 +175,28 @@ meta_back_modify( Operation *op, SlapReply *rs )
        }
        modv[ i ] = 0;
 
-       ldap_modify_s( lc->conns[ candidate ].ld, mdn.bv_val, modv );
+       rs->sr_err = ldap_modify_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
+                       modv, NULL, NULL );
 
 cleanup:;
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
+               BER_BVZERO( &mdn );
        }
        if ( modv != NULL ) {
-               for ( i = 0; modv[ i ]; i++) {
+               for ( i = 0; modv[ i ]; i++ ) {
                        free( modv[ i ]->mod_bvalues );
                }
        }
        free( mods );
        free( modv );
-       
-       if ( rc == 0 ) {
-               return meta_back_op_result( lc, op, rs ) == LDAP_SUCCESS
-                       ? 0 : 1;
-       } /* else */
 
+       if ( rc != -1 ) {
+               return meta_back_op_result( lc, op, rs );
+       }
+       
        send_ldap_result( op, rs );
 
-       return rc;
+       return rs->sr_err;
 }
 
index f1907323996106cdfd3ac352639f9373102f9048..d4ea67f895d2c9c950488f354fbfb1666df4cd2c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -49,9 +49,16 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
                goto cleanup;
        }
 
-       if ( !meta_back_dobind( lc, op ) 
-                       || !meta_back_is_valid( lc, candidate ) ) {
+       assert( candidate != META_TARGET_NONE );
+
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                rc = -1;
                goto cleanup;
        }
@@ -59,11 +66,11 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
        dc.conn = op->o_conn;
        dc.rs = rs;
 
-       if ( op->oq_modrdn.rs_newSup ) {
+       if ( op->orr_newSup ) {
                int nsCandidate, version = LDAP_VERSION3;
 
                nsCandidate = meta_back_select_unique_candidate( li,
-                               op->oq_modrdn.rs_nnewSup );
+                               op->orr_nnewSup );
 
                if ( nsCandidate != candidate ) {
                        /*
@@ -79,19 +86,20 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
                         * FIXME: is this the correct return code?
                         */
                        rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                       rs->sr_text = "cross-target rename not supported";
                        rc = -1;
                        goto cleanup;
                }
 
-               ldap_set_option( lc->conns[ nsCandidate ].ld,
+               ldap_set_option( lc->mc_conns[ nsCandidate ].msc_ld,
                                LDAP_OPT_PROTOCOL_VERSION, &version );
 
                /*
                 * Rewrite the new superior, if defined and required
                 */
-               dc.rwmap = &li->targets[ nsCandidate ]->rwmap;
+               dc.rwmap = &li->targets[ nsCandidate ]->mt_rwmap;
                dc.ctx = "newSuperiorDN";
-               if ( ldap_back_dn_massage( &dc, op->oq_modrdn.rs_newSup, &mnewSuperior ) ) {
+               if ( ldap_back_dn_massage( &dc, op->orr_newSup, &mnewSuperior ) ) {
                        rc = -1;
                        goto cleanup;
                }
@@ -100,26 +108,30 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
        /*
         * Rewrite the modrdn dn, if required
         */
-       dc.rwmap = &li->targets[ candidate ]->rwmap;
+       dc.rwmap = &li->targets[ candidate ]->mt_rwmap;
        dc.ctx = "modrDN";
        if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
                rc = -1;
                goto cleanup;
        }
 
-       ldap_rename2_s( lc->conns[ candidate ].ld, mdn.bv_val,
-                       op->oq_modrdn.rs_newrdn.bv_val,
+       rc = ldap_rename_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
+                       op->orr_newrdn.bv_val,
                        mnewSuperior.bv_val,
-                       op->oq_modrdn.rs_deleteoldrdn );
+                       op->orr_deleteoldrdn,
+                       NULL, NULL ) != LDAP_SUCCESS;
 
 cleanup:;
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
+               BER_BVZERO( &mdn );
        }
        
-       if ( mnewSuperior.bv_val != NULL 
-                       && mnewSuperior.bv_val != op->oq_modrdn.rs_newSup->bv_val ) {
+       if ( !BER_BVISNULL( &mnewSuperior )
+                       && mnewSuperior.bv_val != op->orr_newSup->bv_val )
+       {
                free( mnewSuperior.bv_val );
+               BER_BVZERO( &mnewSuperior );
        }
 
        if ( rc == 0 ) {
@@ -128,7 +140,7 @@ cleanup:;
        } /* else */
 
        send_ldap_result( op, rs );
-       return rc;
 
+       return rc;
 }
 
index 9538223ad68f8db639b9e9558992e797e06f50af..871062e4755b6c5235d73a33438e491ea71df07d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
index 68883a0e4bd99c287c1313c91e071a5635f5194d..cd2c3f7bc6f34c00831d4df8b8b35145e32b0d90 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -78,7 +78,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        }
 
        if ( !meta_back_dobind( lc, op ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }
@@ -99,7 +99,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        /*
         * Inits searches
         */
-       for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
+       for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
                struct berval   realbase = op->o_req_dn;
                int             realscope = op->ors_scope;
                ber_len_t       suffixlen = 0;
@@ -107,31 +107,31 @@ meta_back_search( Operation *op, SlapReply *rs )
                struct berval   mfilter = BER_BVNULL;
                char            **mapped_attrs = NULL;
 
-               if ( lsc->candidate != META_CANDIDATE ) {
+               if ( lsc->msc_candidate != META_CANDIDATE ) {
                        msgid[ i ] = -1;
                        continue;
                }
 
                /* should we check return values? */
                if ( op->ors_deref != -1 ) {
-                       ldap_set_option( lsc->ld, LDAP_OPT_DEREF,
+                       ldap_set_option( lsc->msc_ld, LDAP_OPT_DEREF,
                                        ( void * )&op->ors_deref);
                }
                if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
-                       ldap_set_option( lsc->ld, LDAP_OPT_TIMELIMIT,
+                       ldap_set_option( lsc->msc_ld, LDAP_OPT_TIMELIMIT,
                                        ( void * )&op->ors_tlimit);
                }
                if ( op->ors_slimit != SLAP_NO_LIMIT ) {
-                       ldap_set_option( lsc->ld, LDAP_OPT_SIZELIMIT,
+                       ldap_set_option( lsc->msc_ld, LDAP_OPT_SIZELIMIT,
                                        ( void * )&op->ors_slimit);
                }
 
-               dc.rwmap = &li->targets[ i ]->rwmap;
+               dc.rwmap = &li->targets[ i ]->mt_rwmap;
 
                /*
                 * modifies the base according to the scope, if required
                 */
-               suffixlen = li->targets[ i ]->suffix.bv_len;
+               suffixlen = li->targets[ i ]->mt_nsuffix.bv_len;
                if ( suffixlen > op->o_req_ndn.bv_len ) {
                        switch ( op->ors_scope ) {
                        case LDAP_SCOPE_SUBTREE:
@@ -141,9 +141,9 @@ meta_back_search( Operation *op, SlapReply *rs )
                                 * illegal bases may be turned into 
                                 * the suffix of the target.
                                 */
-                               if ( dnIsSuffix( &li->targets[ i ]->suffix,
+                               if ( dnIsSuffix( &li->targets[ i ]->mt_nsuffix,
                                                &op->o_req_ndn ) ) {
-                                       realbase = li->targets[ i ]->suffix;
+                                       realbase = li->targets[ i ]->mt_nsuffix;
                                        is_scope++;
 
                                } else {
@@ -157,17 +157,17 @@ meta_back_search( Operation *op, SlapReply *rs )
 
                        case LDAP_SCOPE_ONELEVEL:
                        {
-                               struct berval   rdn = li->targets[ i ]->suffix;
+                               struct berval   rdn = li->targets[ i ]->mt_nsuffix;
                                rdn.bv_len -= op->o_req_ndn.bv_len + STRLENOF( "," );
                                if ( dnIsOneLevelRDN( &rdn )
-                                               && dnIsSuffix( &li->targets[ i ]->suffix, &op->o_req_ndn ) )
+                                               && dnIsSuffix( &li->targets[ i ]->mt_nsuffix, &op->o_req_ndn ) )
                                {
                                        /*
                                         * if there is exactly one level,
                                         * make the target suffix the new
                                         * base, and make scope "base"
                                         */
-                                       realbase = li->targets[ i ]->suffix;
+                                       realbase = li->targets[ i ]->mt_nsuffix;
                                        realscope = LDAP_SCOPE_BASE;
                                        is_scope++;
                                        break;
@@ -242,7 +242,7 @@ meta_back_search( Operation *op, SlapReply *rs )
                /*
                 * Maps required attributes
                 */
-               rc = ldap_back_map_attrs( &li->targets[ i ]->rwmap.rwm_at,
+               rc = ldap_back_map_attrs( &li->targets[ i ]->mt_rwmap.rwm_at,
                                op->ors_attrs, BACKLDAP_MAP,
                                &mapped_attrs );
                if ( rc != LDAP_SUCCESS ) {
@@ -256,26 +256,28 @@ meta_back_search( Operation *op, SlapReply *rs )
                /*
                 * Starts the search
                 */
-               msgid[ i ] = ldap_search( lsc->ld, mbase.bv_val, realscope,
-                               mfilter.bv_val, mapped_attrs,
-                               op->ors_attrsonly ); 
+               rc = ldap_search_ext( lsc->msc_ld,
+                               mbase.bv_val, realscope, mfilter.bv_val,
+                               mapped_attrs, op->ors_attrsonly,
+                               NULL, NULL,
+                               NULL, op->ors_slimit, &msgid[ i ] ); 
                if ( mapped_attrs ) {
                        free( mapped_attrs );
                        mapped_attrs = NULL;
                }
                if ( mfilter.bv_val != op->ors_filterstr.bv_val ) {
                        free( mfilter.bv_val );
-                       mfilter.bv_val = NULL;
+                       BER_BVZERO( &mfilter );
                }
                if ( mbase.bv_val != realbase.bv_val ) {
                        free( mbase.bv_val );
-                       mbase.bv_val = NULL;
+                       BER_BVZERO( &mbase );
                }
 
-               if ( msgid[ i ] == -1 ) {
+               if ( rc != LDAP_SUCCESS ) {
                        continue;
                }
-
+               
                ++candidates;
 
 new_candidate:;
@@ -301,13 +303,13 @@ new_candidate:;
                /* check for abandon */
                ab = op->o_abandon;
 
-               for ( i = 0, lsc = lc->conns; !META_LAST(lsc); lsc++, i++ ) {
+               for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
                        if ( msgid[ i ] == -1 ) {
                                continue;
                        }
                        
                        if ( ab ) {
-                               ldap_abandon( lsc->ld, msgid[ i ] );
+                               ldap_abandon_ext( lsc->msc_ld, msgid[ i ], NULL, NULL );
                                rc = 0;
                                break;
                        }
@@ -327,7 +329,7 @@ new_candidate:;
                         * get a LDAP_TIMELIMIT_EXCEEDED from
                         * one of them ...
                         */
-                       rc = ldap_result( lsc->ld, msgid[ i ],
+                       rc = ldap_result( lsc->msc_ld, msgid[ i ],
                                        0, &tv, &res );
 
                        if ( rc == 0 ) {
@@ -339,6 +341,7 @@ new_candidate:;
                                continue;
 
                        } else if ( rc == -1 ) {
+really_bad:;
                                /* something REALLY bad happened! */
                                ( void )meta_clear_unused_candidates( li,
                                                lc, -1, 0 );
@@ -354,7 +357,7 @@ new_candidate:;
                                goto finish;
 
                        } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
-                               e = ldap_first_entry( lsc->ld, res );
+                               e = ldap_first_entry( lsc->msc_ld, res );
                                meta_send_entry( op, rs, lc, i, e );
 
                                ldap_msgfree( res );
@@ -380,7 +383,7 @@ new_candidate:;
                                char            **references = NULL;
                                int             cnt;
 
-                               rc = ldap_parse_reference( lsc->ld, res,
+                               rc = ldap_parse_reference( lsc->msc_ld, res,
                                                &references, &rs->sr_ctrls, 1 );
                                res = NULL;
 
@@ -429,20 +432,25 @@ new_candidate:;
                                }
 
                        } else {
-                               rs->sr_err = ldap_result2error( lsc->ld,
-                                               res, 1 );
+                               if ( ldap_parse_result( lsc->msc_ld, res,
+                                                       &rs->sr_err,
+                                                       NULL, NULL, NULL, NULL, 1 ) )
+                               {
+                                       res = NULL;
+                                       goto really_bad;
+                               }
                                res = NULL;
 
                                sres = slap_map_api2result( rs );
                                if ( err != NULL ) {
                                        free( err );
                                }
-                               ldap_get_option( lsc->ld,
+                               ldap_get_option( lsc->msc_ld,
                                                LDAP_OPT_ERROR_STRING, &err );
                                if ( match.bv_val != NULL ) {
                                        free( match.bv_val );
                                }
-                               ldap_get_option( lsc->ld,
+                               ldap_get_option( lsc->msc_ld,
                                                LDAP_OPT_MATCHED_DN, &match.bv_val );
 
                                Debug( LDAP_DEBUG_ANY,
@@ -468,8 +476,9 @@ new_candidate:;
 
                if ( gotit == 0 ) {
                        tv.tv_sec = 0;
-                        tv.tv_usec = 100000;
+                        tv.tv_usec = 100000;   /* 0.1 s */
                         ldap_pvt_thread_yield();
+
                } else {
                        tv.tv_sec = 0;
                        tv.tv_usec = 0;
@@ -492,7 +501,7 @@ new_candidate:;
        if ( candidate_match == initial_candidates
                        && match.bv_val != NULL && *match.bv_val ) {
                dc.ctx = "matchedDN";
-               dc.rwmap = &li->targets[ last ]->rwmap;
+               dc.rwmap = &li->targets[ last ]->mt_rwmap;
 
                if ( ldap_back_dn_massage( &dc, &match, &mmatch ) ) {
                        mmatch.bv_val = NULL;
@@ -565,7 +574,7 @@ meta_send_entry(
        /*
         * Rewrite the dn of the result, if needed
         */
-       dc.rwmap = &li->targets[ target ]->rwmap;
+       dc.rwmap = &li->targets[ target ]->mt_rwmap;
        dc.conn = op->o_conn;
        dc.rs = rs;
        dc.ctx = "searchResult";
@@ -602,7 +611,7 @@ meta_send_entry(
        while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
                int             last = 0;
 
-               ldap_back_map( &li->targets[ target ]->rwmap.rwm_at, 
+               ldap_back_map( &li->targets[ target ]->mt_rwmap.rwm_at, 
                                &a, &mapped, BACKLDAP_REMAP );
                if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
                        continue;
@@ -644,7 +653,7 @@ meta_send_entry(
 
                if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR 
                                || attr->a_vals == NULL ) {
-                       attr->a_vals = &slap_dummy_bv;
+                       attr->a_vals = (struct berval *)&slap_dummy_bv;
 
                } else if ( attr->a_desc == slap_schema.si_ad_objectClass
                                || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) {
@@ -652,7 +661,7 @@ meta_send_entry(
                        for ( last = 0; attr->a_vals[ last ].bv_val; ++last );
 
                        for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
-                               ldap_back_map( &li->targets[ target ]->rwmap.rwm_oc,
+                               ldap_back_map( &li->targets[ target ]->mt_rwmap.rwm_oc,
                                                bv, &mapped, BACKLDAP_REMAP );
                                if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
                                        free( bv->bv_val );
@@ -681,7 +690,8 @@ meta_send_entry(
                 * everything pass thru the ldap backend.
                 */
                } else if ( attr->a_desc->ad_type->sat_syntax ==
-                               slap_schema.si_syn_distinguishedName ) {
+                               slap_schema.si_syn_distinguishedName )
+               {
                        ldap_dnattr_result_rewrite( &dc, attr->a_vals );
 
                } else if ( attr->a_desc == slap_schema.si_ad_ref ) {
index 05e4ca21834fcb76777008b4e0090e82a2b89f04..8f051d835db97dcb8239e3a58c58bbbbfaa76677 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -68,8 +68,10 @@ ldap_back_dn_massage(
 {
        int rc = 0;
 
-       switch (rewrite_session( dc->rwmap->rwm_rw, dc->ctx, (dn->bv_len ? dn->bv_val : ""), dc->conn, 
-                               &res->bv_val )) {
+       switch ( rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
+                               ( dn->bv_len ? dn->bv_val : "" ),
+                               dc->conn, &res->bv_val ) )
+       {
        case REWRITE_REGEXEC_OK:
                if ( res->bv_val != NULL ) {
                        res->bv_len = strlen( res->bv_val );
index 8f219c7640fe304cd90749738619ef89f302b8f2..40350141c9db3570b59056c68b2332c6af269ad3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -38,13 +38,14 @@ meta_back_conn_destroy(
 )
 {
        struct metainfo *li = ( struct metainfo * )be->be_private;
-       struct metaconn *lc, lc_curr;
+       struct metaconn *lc,
+                       lc_curr = { 0 };
 
        Debug( LDAP_DEBUG_TRACE,
-               "=>meta_back_conn_destroy: fetching conn %ld\n%s%s",
-               conn->c_connid, "", "" );
+               "=>meta_back_conn_destroy: fetching conn %ld\n",
+               conn->c_connid, 0, 0 );
        
-       lc_curr.conn = conn;
+       lc_curr.mc_conn = conn;
        
        ldap_pvt_thread_mutex_lock( &li->conn_mutex );
        lc = avl_delete( &li->conntree, ( caddr_t )&lc_curr,
@@ -55,22 +56,22 @@ meta_back_conn_destroy(
                int i;
                
                Debug( LDAP_DEBUG_TRACE,
-                       "=>meta_back_conn_destroy: destroying conn %ld\n%s%s",
-                       lc->conn->c_connid, "", "" );
+                       "=>meta_back_conn_destroy: destroying conn %ld\n",
+                       lc->mc_conn->c_connid, 0, 0 );
                
                /*
                 * Cleanup rewrite session
                 */
                for ( i = 0; i < li->ntargets; ++i ) {
-                       if ( lc->conns[ i ].ld == NULL ) {
+                       if ( lc->mc_conns[ i ].msc_ld == NULL ) {
                                continue;
                        }
 
-                       rewrite_session_delete( li->targets[ i ]->rwmap.rwm_rw, conn );
-                       meta_clear_one_candidate( &lc->conns[ i ], 1 );
+                       rewrite_session_delete( li->targets[ i ]->mt_rwmap.rwm_rw, conn );
+                       meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
                }
 
-               free( lc->conns );
+               free( lc->mc_conns );
                free( lc );
        }
 
index 3d14f33318707357f9628ed297f380d39be68cce..46fd66b0da7efeed02df0825c81216ed8f266c6c 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e1e8bcad7dd8d483a5c69865c868c6353304c543..dc7d4cf2fb20bfff137ca28a232dfc8012c77de4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 8bfe6c03755929398d6521c3f81822fb81bfbcc2..d21582179102b764b365c610a81afb0f8b72abc4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 17afa9475317ca19a1a631e92febe92cc1086726..ddb73decd905b8c4e19b843db5f8f70d4467215d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index e501fc116e85f796b3ba3d862704d80c5ee39135..db827438c6f08f78954e6462d56a6514e7d9b4e0 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index adc5674484a6e6107da919e0fba9507dddae5e04..f0264507c775a57fdfce127309f6fbaf55e4dd6b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index e8c5d15d0a627dd181457de6ea634ff212ffdfc0..40d0a58b91a8121f5901fde17b4f64c9a50093a9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -217,6 +217,8 @@ monitor_subsys_conn_update(
                }
                a->a_vals[ 0 ].bv_len = len;
                AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
+
+               /* FIXME: touch modifyTimestamp? */
        }
 
        return( 0 );
index 67285793ffe24cc3f9caffc4397c24f077b79d36..1312d891a58004555e0986fccdd0a26d0821eb88 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 91fba840c315bec348de6d0c2947a9fe0e03301d..3c2b4ebf1c793b217cffae1f9c5d4cc4d253dbb3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index d00405d40a01b45d8ae7910a423906ab9cbbfca7..437815779cbd87a62caf26c0bdf4cffc7685cdb2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 4fe5b7790c2b36b4cf2b61e49a513ab01541fe8b..d94954e8d021c26c391aa08d1bff99fec9e0798a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 4d3df1b06163c1c076303da6d275e0a4f27bb87d..8ab11949e983ede6f3d2c68d8b7fffed83b1d9cc 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -148,7 +148,9 @@ monitor_subsys_log_modify(
                Modification    *mod = &ml->sml_mod;
 
                /*
-                * accept all operational attributes
+                * accept all operational attributes;
+                * this includes modifersName and modifyTimestamp
+                * if lastmod is "on"
                 */
                if ( is_at_operational( mod->sm_desc->ad_type ) ) {
                        ( void ) attr_delete( &e->e_attrs, mod->sm_desc );
index 87619844400ba9e6950adc135a97dc20d5960017..9368f27338916ba9797ed59c7f14ca14df41882e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 570fddf49a8f170000c610a7cc121be0a0a53298..8ce09525d3b6a4d18bab52a14c6ad8046e8c2703 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -215,6 +215,8 @@ monitor_subsys_ops_update(
        UI2BV( &a->a_vals[ 0 ], nCompleted );
        ldap_pvt_mp_clear( nCompleted );
 
+       /* FIXME: touch modifyTimestamp? */
+
        return( 0 );
 }
 
index f63cc9e8308a64a4f23eeeda9cecd9487a496f39..2437b5f23009201ed216b3ba287859472fd23fcb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 9eaa5876ec739a72dc3329c36a9c6ec93eeae89c..b90fc8a2b0a0623758370bf45effe0aee8293e9c 100644 (file)
@@ -1,7 +1,7 @@
 /* overlay.c - deals with overlay subsystem */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index b1fc59293ee6b805eb8081a8ca3fa7ba002f6126..eb0d8422ab7c28ff40a50173ad7ecccbdbdf48dd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index c2cfc94bd640358e6a0139746c00d3e68048daea..150484689779004774a3ea9239b0657ad904eb71 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -217,6 +217,8 @@ monitor_subsys_rww_update(
        AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
        a->a_vals[ 0 ].bv_len = len;
 
+       /* FIXME: touch modifyTimestamp? */
+
        return( 0 );
 }
 
index 3105cb00649aa47a2d3b4c7e5321194d6bb428f9..9bbe61ce03cbafb58757bbbe90b5555b6493f241 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
index 3d8b9a0ded54294819549eb1531f6e22eda67f2a..b7ba178f55a3685d4ab9f979134a5d010f5bfbaa 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -201,6 +201,8 @@ monitor_subsys_sent_update(
        UI2BV( &a->a_vals[ 0 ], n );
        ldap_pvt_mp_clear( n );
 
+       /* FIXME: touch modifyTimestamp? */
+
        return 0;
 }
 
index 4e588aefe8dd240d91e18f0c64a411a0568cf45e..83ba5ce522c99f8ee54c50ed3c7ebad6f29e6709 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -197,6 +197,8 @@ monitor_subsys_thread_update(
        a->a_vals[ 0 ].bv_len = len;
        AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
 
+       /* FIXME: touch modifyTimestamp? */
+
        return( 0 );
 }
 
index c7820d311ce5ba8c1ba5cfd17f434577d87f33e1..016b233613861db5dcb254d36bdbe762cc59092d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -224,6 +224,8 @@ monitor_subsys_time_update(
 
                assert( len == a->a_vals[ 0 ].bv_len );
                AC_MEMCPY( a->a_vals[ 0 ].bv_val, tmbuf, len );
+
+               /* FIXME: touch modifyTimestamp? */
        }
 
        return( 0 );
index 0c5b9df8a1862e72c25f3f7b6860fc8fafb34a95..bab4e2695cd9c2708aefd97155a98969412dbba7 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 2b3a12612c4bd8fa38fbd83a98d903aca8492faa..5093d23edfc42ad830de19ed6a63a2ec04872f2f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #include "slap.h"
 
-/*
- * former external.h
- */
-
-extern BI_init                 null_back_initialize;
-
-extern BI_db_init              null_back_db_init;
-extern BI_db_destroy           null_back_db_destroy;
-extern BI_db_config            null_back_db_config;
-
-extern BI_op_bind              null_back_bind;
-extern BI_op_search            null_back_search;
-extern BI_op_compare           null_back_compare;
-extern BI_op_modify            null_back_modify;
-extern BI_op_modrdn            null_back_modrdn;
-extern BI_op_add               null_back_add;
-extern BI_op_delete            null_back_delete;
-
 struct null_info {
        int bind_allowed;
 };
 
-int
+static int
 null_back_bind( Operation *op, SlapReply *rs )
 {
        struct null_info *ni = (struct null_info *) op->o_bd->be_private;
 
        if ( ni->bind_allowed ) {
                /* front end will send result on success (0) */
-               return 0;
+               return LDAP_SUCCESS;
        }
 
        rs->sr_err = LDAP_INVALID_CREDENTIALS;
        send_ldap_result( op, rs );
 
-       return 1;
+       return rs->sr_err;
 }
 
 /* add, delete, modify, modrdn, search */
-int
+static int
 null_back_success( Operation *op, SlapReply *rs )
 {
        rs->sr_err = LDAP_SUCCESS;
@@ -73,7 +55,7 @@ null_back_success( Operation *op, SlapReply *rs )
 }
 
 /* compare */
-int
+static int
 null_back_false( Operation *op, SlapReply *rs )
 {
        rs->sr_err = LDAP_COMPARE_FALSE;
@@ -81,12 +63,12 @@ null_back_false( Operation *op, SlapReply *rs )
        return 0;
 }
 
-int
+static int
 null_back_db_config(
        BackendDB       *be,
        const char      *fname,
-       int                     lineno,
-       int                     argc,
+       int             lineno,
+       int             argc,
        char            **argv )
 {
        struct null_info *ni = (struct null_info *) be->be_private;
@@ -115,8 +97,7 @@ null_back_db_config(
        return 0;
 }
 
-
-int
+static int
 null_back_db_init( BackendDB *be )
 {
        struct null_info *ni;
@@ -127,10 +108,8 @@ null_back_db_init( BackendDB *be )
        return 0;
 }
 
-int
-null_back_db_destroy(
-    Backend    *be
-)
+static int
+null_back_db_destroy( Backend *be )
 {
        free( be->be_private );
        return 0;
@@ -138,9 +117,7 @@ null_back_db_destroy(
 
 
 int
-null_back_initialize(
-    BackendInfo        *bi
-)
+null_back_initialize( BackendInfo *bi )
 {
        bi->bi_open = 0;
        bi->bi_close = 0;
index 0cdf61d86c4cc94ba3e3c05fe8aa2b9a4c95d0bb..f60db2b4fa76991ef523d187503867282aebcca5 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 49805309367182acc118ad5f5d41463ca8634de3..7f508c4cc86f58178b5ccfa53821be51c1d5d42c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 65f59c363aa11c9502c4e5a6ec288611f510dc90..5337cd523764184ad75f0c9e760bde15cf958826 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 11401770a60bd066a06da06f202c7a61cd7321da..e57dae399dc1fe7aaeff040076fdbcf963478b2d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7c62a22fe8d1b3676f375eb8ab1979ffb416b187..cf42f7a85e6c61e381b51da5a7202a4b194aa903 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 239a1ba67b3d6547a519b72511b79d461e2feb8b..cfb55531e505e5fb1b2078cdcf3eca324e7975ad 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 888957b71d966a1c0bc69de3b770375ccdf1167c..f510e35a86ceb5c5d5391ce2fef1ba197f9c06ff 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## Portions Copyright 1999 John C. Quillan.
 ## All rights reserved.
 ##
index 4788da3af83f7a5141a1e4a2664bdf661e26b4a8..bfe158fe5ef8c0b4dbbcdb71470d07274ef341ea 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## Portions Copyright 1999 John C. Quillan.
 ## All rights reserved.
 ##
index 8a89f8948dfbcc55eb80e9ee3391ae939a116021..5d690c80220321468feeaa9e3d4fb5f19fe6c606 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 6ce59fea27d232abe8e104f3e9e88bc0034ba18e..08cf585d9568f3ce58ffa4c5c574a362e7fc41c7 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f0c33c139be79bb3055516aaabf57bb087b9451a..46665b08c97a8a85a686537982852f94d6e96f50 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index d4773a49e0923c4a153da1ffad7cdc4ea898b3a4..9a462acfb4b5a2987f7082ed2848cbd01147e5f4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 15f45115613de4930623582d2a90911701a5cd3d..75ade4a965105621ee06793e2653fbbb1a589bbe 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 8b40a3e79d3d7c046527be198e059b76c95a059e..a330b21d8471b995caa4b11c86abfad1a6393beb 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 63e774440e5979d4c8e9993da937218fdb0d35ba..0a4f45567ac2d7bc6672a01d794d845fda728930 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 2100744022cb2ad6f0ceae110fb342adc5dda771..fef6b782a9bda0338a8d53e6504017a52812d2dc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index a29565b455df63cb22845a46a91a8893fb12859e..2776277e51f5c4f8404bba01030b7c580d27a9c8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index a378bd1a23910493d1fab7a1d56eabb108a6d40d..46364d181b10fde642dbb647ca3839377f60df26 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 4609889959d66a48762117ba1ad3ad8e36e4f786..9ce7de45400d6628d16be4f5c580ef47d611ae90 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 55c6e233a4132d9d32ffc3cf10914ca21f2785ee..1d9b6b963324879c07ad5b341b50be832b4930f8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 69d0076b7742b450f6b3b85e9764cc1c646a4e6f..33d48225538bfc1264cd6ba772b0315cdc97e6fd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 John C. Quillan.
  * Portions Copyright 2002 myinternet Limited.
  * All rights reserved.
index 0190a8da1a38d06fe4b558f1dfd314699cf3ad5b..da7ae25508205be2bd98bb199cd4cd9acefa4b85 100644 (file)
@@ -1,7 +1,7 @@
 # Makefile.in for back-relay
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 43b86f68fe2f2dbde5958d02e2f1caffe69e795f..6a324ad1a869aa04359e1dce59b521a7d8059637 100644 (file)
@@ -1,7 +1,7 @@
 /* back-relay.h - relay backend header file */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 3c0c703ec714c0a105c29cbc7a4377573371a100..56cd2b98ecbd7e79a6bafedfc59131ecc18bd820 100644 (file)
@@ -1,7 +1,7 @@
 /* config.c - relay backend configuration file routine */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 0692a15fb3649eb3d5f3890da446ae1b107edb7a..9cb0a91a756a5cc6016a65c4e0d2fc1db52f019d 100644 (file)
@@ -1,7 +1,7 @@
 /* init.c - initialize relay backend */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 4b6912ee7ae5090817b6f65f9f777b449b603e98..e6c6e0834a84e3256b964b81ea460be3c61f1966 100644 (file)
@@ -1,7 +1,7 @@
 /* op.c - relay backend operations */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 729b3c8d2c3353987ae96160e91264b6bda9c9c3..ddc2e0e0b3dd1d14602dd6d16c6e06961a6b4b0c 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index b8e94e7cbc2aaa37ea7d5c05f2b47c71128a1e54..79f3326a071ed83990bac1640bfad2f58fb94166 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index d1d02296bcfdea920ddca21f342ea6f9b763c5cd..120ed0e9ceb0354c635775837e8d3956ef18e221 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1cb32fb7173056d98371dfa06a09baa1fc55002a..e59cca3a1bd6c8890ebd4c359e3a5991fbd9d3ae 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a1cc76124753d2e8bc7d77546b786d95393ca23d..f69a864236d6573beb7366152cd6c51ee76dae43 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 39e3f15f6408609a22f4b1047c9fae5e7d02e23e..467d95f6d695c7bb87cade78052dd5a3b8ffca16 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ae292f9686e92a100cd6baed9e0ce28b0f3a4e5c..8721efb082b5882f7fa457f5c4be382769e94af1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 70bd8fb25719f104ecad0d7211646e1ed53ce6be..a85bd20a9b68328c5c354b3ded0b7dac37bf6ed9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ed146897d80fe783f1c0203b045116fc62b3bb59..828abc2b5c4802594ef5e53e47c62c8ffd91cac8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6dbd811e912a15682361aafab3e2341f1b2acc80..f74aabef194cee91749864eb5c8bd92019322750 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 20154181c48111129942116e6e56f932020733b3..6388f17f6d3a9a388978beacedf486a968bea7fb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 632ffba056df9e22c6b13f42b7981c7493ec0724..5488a81ba2b7a27ed2a5d78b352376fa9d254f5e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f73679faa7b923b98b8f453ae8657cece7a7d6a2..56cf0019bbedad327adb547f8e9c5e14999b527b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 75bc9d5e741e5de53ebf561deb67fdb9b08105bf..a0467a1b4f6ee97e299569c684e179ec7428a451 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 17dc9bb6c50c61eb44eba9d56ba85f499b960a39..1dd5a4416d777b81e8bc4d1fce5ae87f9bfcaa46 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 2c77f8e09b871aed82d6c8af4043795b5d6d3fee..ff0151f218d23f9583721d0da9c623d1a0aee034 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index c10cffd748c00d3f475ac2685e5e01948c4e5c27..0987ac22e09162de5b6618c433256d3b18b758d7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 1a1c230598eae6c9bd21593ca6bae42a5eb1954c..410038e92397ab4d9accfef11f1a38825787f6a6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fe32d8bd34b72566a635c22badd33427f9f61ae4..77d117b182e71917ad38204beb2b8c7b6a1763cb 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 75b3e0ecd01a6094425770e3bb0a0b5cf2e0e192..1e46866dd826daaa56582f299cb6f33e0e7ba12d 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,9 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati and Mark Adamson.
+
  */
 
 #include "portable.h"
  * - operational attributes
  * - empty attributes
  */
+#define backsql_opattr_skip(ad) \
+       (is_at_operational( (ad)->ad_type ) && (ad) != slap_schema.si_ad_ref )
 #define        backsql_attr_skip(ad, vals) \
        ( \
                ( (ad) == slap_schema.si_ad_objectClass \
                                && (vals) && BER_BVISNULL( &((vals)[ 1 ]) ) ) \
-               || is_at_operational( (ad)->ad_type ) \
+               || backsql_opattr_skip( (ad) ) \
                || ( (vals) && BER_BVISNULL( &((vals)[ 0 ]) ) ) \
        )
 
@@ -57,7 +63,7 @@ backsql_modify_delete_all_values(
 {
        backsql_info    *bi = (backsql_info *)op->o_bd->be_private;
        RETCODE         rc;
-       SQLHSTMT        asth;
+       SQLHSTMT        asth = SQL_NULL_HSTMT;
        BACKSQL_ROW_NTS row;
 
        assert( at );
@@ -138,10 +144,10 @@ backsql_modify_delete_all_values(
                /* first parameter no, parameter order */
                SQLUSMALLINT            pno, po;
                /* procedure return code */
-               int                     prc;
+               int                     prc = LDAP_SUCCESS;
                
                for ( i = 0; i < row.ncols; i++ ) {
-                       SQLHSTMT        sth;
+                       SQLHSTMT        sth = SQL_NULL_HSTMT;
                        ber_len_t       col_len;
                        
                        rc = backsql_Prepare( dbh, &sth, at->bam_delete_proc, 0 );
@@ -248,19 +254,33 @@ backsql_modify_delete_all_values(
                                pno + 2 - po, row.cols[ i ],
                                at->bam_delete_proc );
                        rc = SQLExecute( sth );
-                       if ( rc != SQL_SUCCESS ) {
+                       if ( rc == SQL_SUCCESS && prc == LDAP_SUCCESS ) {
+                               rs->sr_err = LDAP_SUCCESS;
+
+                       } else {
                                Debug( LDAP_DEBUG_TRACE,
                                        "   backsql_modify_delete_all_values(): "
                                        "delete_proc "
-                                       "execution failed\n",
-                                       0, 0, 0 );
-                               backsql_PrintErrors( bi->sql_db_env,
-                                               dbh, sth, rc );
-
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+                                       "execution failed (rc=%d, prc=%d)\n",
+                                       rc, prc, 0 );
+                               if ( prc != LDAP_SUCCESS ) {
+                                       /* SQL procedure executed fine 
+                                        * but returned an error */
+                                       rs->sr_err = BACKSQL_SANITIZE_ERROR( prc );
+                                       rs->sr_text = op->ora_e->e_name.bv_val;
                                        SQLFreeStmt( sth, SQL_DROP );
-                                       rs->sr_text = "SQL-backend error";
-                                       return rs->sr_err = LDAP_OTHER;
+                                       return rs->sr_err;
+
+                               } else {
+                                       backsql_PrintErrors( bi->sql_db_env, dbh,
+                                                       sth, rc );
+                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) 
+                                       {
+                                               rs->sr_err = LDAP_OTHER;
+                                               rs->sr_text = op->ora_e->e_name.bv_val;
+                                               SQLFreeStmt( sth, SQL_DROP );
+                                               return rs->sr_err;
+                                       }
                                }
                        }
                        SQLFreeStmt( sth, SQL_DROP );
@@ -283,7 +303,7 @@ backsql_modify_internal(
 {
        backsql_info    *bi = (backsql_info*)op->o_bd->be_private;
        RETCODE         rc;
-       SQLHSTMT        sth;
+       SQLHSTMT        sth = SQL_NULL_HSTMT;
        Modifications   *ml;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_modify_internal(): "
@@ -298,7 +318,7 @@ backsql_modify_internal(
 #if 0
                /* NOTE: some day we'll have to pass 
                 * the normalized values as well */
-               BerVarray               nvalues;
+               BerVarray               sm_nvalues;
 #endif
                backsql_at_map_rec      *at = NULL;
                struct berval           *at_val;
@@ -306,7 +326,7 @@ backsql_modify_internal(
                /* first parameter position, parameter order */
                SQLUSMALLINT            pno, po;
                /* procedure return code */
-               int                     prc;
+               int                     prc = LDAP_SUCCESS;
                
                ad = ml->sml_mod.sm_desc;
                sm_op = ( ml->sml_mod.sm_op & LDAP_MOD_OP );
@@ -388,7 +408,7 @@ backsql_modify_internal(
 
                                goto add_only;
                        }
-                       
+
 del_all:
                        rs->sr_err = backsql_modify_delete_all_values( op, rs, dbh, e_id, at );
                        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -578,6 +598,7 @@ add_only:;
                                        !BER_BVISNULL( at_val );
                                        i++, at_val++ )
                        {
+                               prc = LDAP_SUCCESS;
                                rc = backsql_Prepare( dbh, &sth, at->bam_delete_proc, 0 );
                                if ( rc != SQL_SUCCESS ) {
                                        Debug( LDAP_DEBUG_TRACE,
@@ -667,19 +688,34 @@ add_only:;
                                        "executing \"%s\"\n", 
                                        at->bam_delete_proc, 0, 0 );
                                rc = SQLExecute( sth );
-                               if ( rc != SQL_SUCCESS ) {
+                               if ( rc == SQL_SUCCESS && prc == LDAP_SUCCESS )
+                               {
+                                       rs->sr_err = LDAP_SUCCESS;
+                                       
+                               } else {
                                        Debug( LDAP_DEBUG_TRACE,
                                                "   backsql_modify_internal(): "
                                                "delete_proc execution "
-                                               "failed\n", 0, 0, 0 );
-                                       backsql_PrintErrors( bi->sql_db_env,
-                                                       dbh, sth, rc );
-
-                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               SQLFreeStmt( sth, SQL_DROP );
-                                               rs->sr_err = LDAP_OTHER;
-                                               rs->sr_text = "SQL-backend error";
+                                               "failed (rc=%d, prc=%d)\n",
+                                               rc, prc, 0 );
+
+                                       if ( prc != LDAP_SUCCESS ) {
+                                               /* SQL procedure executed fine
+                                                * but returned an error */
+                                               rs->sr_err = BACKSQL_SANITIZE_ERROR( prc );
+                                               rs->sr_text = at->bam_ad->ad_cname.bv_val;
                                                goto done;
+                                               
+                                       } else {
+                                               backsql_PrintErrors( bi->sql_db_env,
+                                                               dbh, sth, rc );
+                                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) )
+                                               {
+                                                       SQLFreeStmt( sth, SQL_DROP );
+                                                       rs->sr_err = LDAP_OTHER;
+                                                       rs->sr_text = at->bam_ad->ad_cname.bv_val;
+                                                       goto done;
+                                               }
                                        }
                                }
                                SQLFreeStmt( sth, SQL_DROP );
@@ -724,12 +760,8 @@ backsql_add_attr(
        struct berval           *at_val;
        unsigned long           i;
        RETCODE                 rc;
-       /* first parameter #, parameter order */
-       SQLUSMALLINT            pno, po;
-       /* procedure return code */
-       int                     prc;
        SQLUSMALLINT            currpos;
-       SQLHSTMT                sth;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
 
        at_rec = backsql_ad2at( oc, at->a_desc ); 
   
@@ -737,7 +769,7 @@ backsql_add_attr(
                Debug( LDAP_DEBUG_TRACE, "   backsql_add_attr(\"%s\"): "
                        "attribute \"%s\" is not registered "
                        "in objectclass \"%s\"\n",
-                       op->oq_add.rs_e->e_name.bv_val,
+                       op->ora_e->e_name.bv_val,
                        at->a_desc->ad_cname.bv_val,
                        BACKSQL_OC_NAME( oc ) );
 
@@ -755,7 +787,7 @@ backsql_add_attr(
                        "add procedure is not defined "
                        "for attribute \"%s\" "
                        "of structuralObjectClass \"%s\"\n",
-                       op->oq_add.rs_e->e_name.bv_val,
+                       op->ora_e->e_name.bv_val,
                        at->a_desc->ad_cname.bv_val,
                        BACKSQL_OC_NAME( oc ) );
 
@@ -772,7 +804,11 @@ backsql_add_attr(
                        !BER_BVISNULL( at_val );
                        i++, at_val = &at->a_vals[ i ] )
        {
-               char logbuf[] = "val[18446744073709551615UL], id=18446744073709551615UL";
+               /* procedure return code */
+               int             prc = LDAP_SUCCESS;
+               /* first parameter #, parameter order */
+               SQLUSMALLINT    pno, po;
+               char            logbuf[] = "val[18446744073709551615UL], id=18446744073709551615UL";
                
                /*
                 * Do not deal with the objectClass that is used
@@ -871,21 +907,35 @@ backsql_add_attr(
                                i, new_keyval );
                Debug( LDAP_DEBUG_TRACE, "   backsql_add_attr(\"%s\"): "
                        "executing \"%s\" %s\n", 
-                       op->oq_add.rs_e->e_name.bv_val,
+                       op->ora_e->e_name.bv_val,
                        at_rec->bam_add_proc, logbuf );
 #endif
                rc = SQLExecute( sth );
-               if ( rc != SQL_SUCCESS ) {
+               if ( rc == SQL_SUCCESS && prc == LDAP_SUCCESS ) {
+                       rs->sr_err = LDAP_SUCCESS;
+
+               } else {
                        Debug( LDAP_DEBUG_TRACE,
                                "   backsql_add_attr(\"%s\"): "
-                               "add_proc execution failed\n", 
-                               op->oq_add.rs_e->e_name.bv_val, 0, 0 );
-                       backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-
-                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+                               "add_proc execution failed (rc=%d, prc=%d)\n", 
+                               op->ora_e->e_name.bv_val, rc, prc );
+                       if ( prc != LDAP_SUCCESS ) {
+                               /* SQL procedure executed fine
+                                * but returned an error */
+                               rs->sr_err = BACKSQL_SANITIZE_ERROR( prc );
+                               rs->sr_text = op->ora_e->e_name.bv_val;
                                SQLFreeStmt( sth, SQL_DROP );
-                               rs->sr_text = "SQL-backend error";
-                               return rs->sr_err = LDAP_OTHER;
+                               return rs->sr_err;
+
+                       } else {
+                               backsql_PrintErrors( bi->sql_db_env, dbh,
+                                               sth, rc );
+                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = op->ora_e->e_name.bv_val;
+                                       SQLFreeStmt( sth, SQL_DROP );
+                                       return rs->sr_err;
+                               }
                        }
                }
                SQLFreeStmt( sth, SQL_DROP );
@@ -898,17 +948,20 @@ int
 backsql_add( Operation *op, SlapReply *rs )
 {
        backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
-       SQLHDBC                 dbh;
-       SQLHSTMT                sth;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        unsigned long           new_keyval = 0;
        RETCODE                 rc;
        backsql_oc_map_rec      *oc = NULL;
-       backsql_entryID         parent_id = BACKSQL_ENTRYID_INIT;
-       Entry                   p;
+       backsql_srch_info       bsi = { 0 };
+       Entry                   p = { 0 }, *e = NULL;
        Attribute               *at,
                                *at_objectClass = NULL;
+       struct berval           scname = BER_BVNULL;
        struct berval           pdn;
        struct berval           realdn = BER_BVNULL;
+       int                     colnum;
+       slap_mask_t             mask;
 
 #ifdef BACKSQL_SYNCPROV
        /*
@@ -930,43 +983,77 @@ backsql_add( Operation *op, SlapReply *rs )
 #endif /* BACKSQL_SYNCPROV */
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_add(\"%s\")\n",
-                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val, 0, 0 );
 
        /* check schema */
        if ( global_schemacheck ) {
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
 
-               rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e,
+               rs->sr_err = entry_schema_check( op->o_bd, op->ora_e,
                                NULL,
                                &rs->sr_text, textbuf, sizeof( textbuf ) );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                                "entry failed schema check -- aborting\n",
-                               op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                               op->ora_e->e_name.bv_val, 0, 0 );
+                       e = NULL;
                        goto done;
                }
        }
 
-       /* search structural objectClass */
-       for ( at = op->oq_add.rs_e->e_attrs; at != NULL; at = at->a_next ) {
+       /* search structuralObjectClass */
+       for ( at = op->ora_e->e_attrs; at != NULL; at = at->a_next ) {
                if ( at->a_desc == slap_schema.si_ad_structuralObjectClass ) {
                        break;
                }
        }
 
        /* there must exist */
-       assert( at != NULL );
+       if ( at == NULL ) {
+               char            buf[ SLAP_TEXT_BUFLEN ];
+               const char      *text;
+
+               /* search structuralObjectClass */
+               for ( at = op->ora_e->e_attrs; at != NULL; at = at->a_next ) {
+                       if ( at->a_desc == slap_schema.si_ad_objectClass ) {
+                               break;
+                       }
+               }
+
+               if ( at == NULL ) {
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                               "no objectClass\n",
+                               op->ora_e->e_name.bv_val, 0, 0 );
+                       rs->sr_err = LDAP_OBJECT_CLASS_VIOLATION;
+                       e = NULL;
+                       goto done;
+               }
+
+               rs->sr_err = structural_class( at->a_vals, &scname, NULL,
+                               &text, buf, sizeof( buf ) );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                               "%s (%d)\n",
+                               op->ora_e->e_name.bv_val, text, rs->sr_err );
+                       e = NULL;
+                       goto done;
+               }
+
+       } else {
+               scname = at->a_vals[0];
+       }
 
        /* I guess we should play with sub/supertypes to find a suitable oc */
-       oc = backsql_name2oc( bi, &at->a_vals[0] );
+       oc = backsql_name2oc( bi, &scname );
 
        if ( oc == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "cannot map structuralObjectClass \"%s\" -- aborting\n",
-                       op->oq_add.rs_e->e_name.bv_val,
-                       at->a_vals[0].bv_val, 0 );
+                       op->ora_e->e_name.bv_val,
+                       scname.bv_val, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "operation not permitted within namingContext";
+               e = NULL;
                goto done;
        }
 
@@ -974,10 +1061,11 @@ backsql_add( Operation *op, SlapReply *rs )
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "create procedure is not defined "
                        "for structuralObjectClass \"%s\" - aborting\n",
-                       op->oq_add.rs_e->e_name.bv_val,
-                       at->a_vals[0].bv_val, 0 );
+                       op->ora_e->e_name.bv_val,
+                       scname.bv_val, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "operation not permitted within namingContext";
+               e = NULL;
                goto done;
 
        } else if ( BACKSQL_CREATE_NEEDS_SELECT( bi )
@@ -986,10 +1074,11 @@ backsql_add( Operation *op, SlapReply *rs )
                        "create procedure needs select procedure, "
                        "but none is defined for structuralObjectClass \"%s\" "
                        "- aborting\n",
-                       op->oq_add.rs_e->e_name.bv_val,
-                       at->a_vals[0].bv_val, 0 );
+                       op->ora_e->e_name.bv_val,
+                       scname.bv_val, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "operation not permitted within namingContext";
+               e = NULL;
                goto done;
        }
 
@@ -997,114 +1086,94 @@ backsql_add( Operation *op, SlapReply *rs )
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "could not get connection handle - exiting\n", 
-                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val, 0, 0 );
                rs->sr_text = ( rs->sr_err == LDAP_OTHER )
                        ?  "SQL-backend error" : NULL;
+               e = NULL;
                goto done;
        }
 
        /*
         * Check if entry exists
+       *
+        * NOTE: backsql_api_dn2odbc() is called explicitly because
+        * we need the mucked DN to pass it to the create procedure.
         */
-       realdn = op->oq_add.rs_e->e_name;
+       realdn = op->ora_e->e_name;
        if ( backsql_api_dn2odbc( op, rs, &realdn ) ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "backsql_api_dn2odbc(\"%s\") failed\n", 
-                       op->oq_add.rs_e->e_name.bv_val, realdn.bv_val, 0 );
+                       op->ora_e->e_name.bv_val, realdn.bv_val, 0 );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
-       rs->sr_err = backsql_dn2id( op, rs, NULL, dbh, &realdn, 0 );
+       rs->sr_err = backsql_dn2id( op, rs, dbh, &realdn, NULL, 0, 0 );
        if ( rs->sr_err == LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "entry exists\n",
-                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val, 0, 0 );
                rs->sr_err = LDAP_ALREADY_EXISTS;
+               e = op->ora_e;
                goto done;
        }
 
        /*
         * Get the parent dn and see if the corresponding entry exists.
         */
-       if ( be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname ) ) {
+       if ( be_issuffix( op->o_bd, &op->ora_e->e_nname ) ) {
                pdn = slap_empty_bv;
 
        } else {
-               dnParent( &op->oq_add.rs_e->e_nname, &pdn );
+               dnParent( &op->ora_e->e_nname, &pdn );
        }
 
-       rs->sr_err = backsql_dn2id( op, rs, &parent_id, dbh, &pdn, 1 );
+       /*
+        * Get the parent
+        */
+       bsi.bsi_e = &p;
+       rs->sr_err = backsql_init_search( &bsi, &pdn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs,
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
        if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
-                       "could not lookup parent entry for new record \"%s\"\n",
-                       op->oq_add.rs_e->e_name.bv_val, pdn.bv_val, 0 );
-
-               if ( rs->sr_err != LDAP_NO_SUCH_OBJECT ) {
-                       goto done;
-               }
-
-               /*
-                * no parent!
-                *  if not attempting to add entry at suffix or with parent ""
-                */
-               if ( ( ( !be_isroot( op ) && !be_shadow_update( op ) )
-                       || !BER_BVISEMPTY( &pdn ) ) && !is_entry_glue( op->oq_add.rs_e )
-                       && !BACKSQL_ALLOW_ORPHANS( bi ) )
-               {
-                       Debug( LDAP_DEBUG_TRACE, "   backsql_add: %s denied\n",
-                               BER_BVISEMPTY( &pdn ) ? "suffix" : "entry at root",
-                               0, 0 );
-                       /*
-                        * Look for matched
-                        */
-                       while ( 1 ) {
-                               struct berval   dn;
-                               char            *matched = NULL;
-       
-                               dn = pdn;
-                               dnParent( &dn, &pdn );
-       
-                               /*
-                                * Empty DN ("") defaults to LDAP_SUCCESS
-                                */
-                               rs->sr_err = backsql_dn2id( op, rs, NULL, dbh, &pdn, 1 );
-                               switch ( rs->sr_err ) {
-                               case LDAP_NO_SUCH_OBJECT:
-                                       if ( !BER_BVISEMPTY( &pdn ) ) {
-                                               break;
-                                       }
-                                       /* fail over to next case */
-                                       
-                               case LDAP_SUCCESS:
-                                       matched = pdn.bv_val;
-                                       /* fail over to next case */
-       
-                               default:
-                                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
-                                       rs->sr_matched = matched;
-                                       goto done;
-                               } 
-                       }
-               } else {
-
-#ifdef BACKSQL_ARBITRARY_KEY
-                       ber_str2bv( "SUFFIX", 0, 1, &parent_id.eid_id );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-                       parent_id.eid_id = 0;
-#endif /* ! BACKSQL_ARBITRARY_KEY */
-                       rs->sr_err = LDAP_SUCCESS;
-               }
+               Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
+                       "could not retrieve addDN parent "
+                       "\"%s\" ID - %s matched=\"%s\"\n", 
+                       pdn.bv_val,
+                       rs->sr_err == LDAP_REFERRAL ? "referral" : "no such entry",
+                       rs->sr_matched ? rs->sr_matched : "(null)" );
+               e = &p;
+               goto done;
        }
 
        /* check "children" pseudo-attribute access to parent */
-       p.e_attrs = NULL;
-       p.e_name = pdn;
-       dnParent( &op->oq_add.rs_e->e_nname, &p.e_nname );
        if ( !access_allowed( op, &p, slap_schema.si_ad_children,
-                               NULL, ACL_WRITE, NULL ) ) {
+                               NULL, ACL_WRITE, NULL ) )
+       {
                rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               e = &p;
+               goto done;
+       }
+
+       if ( get_assert( op ) &&
+               ( test_filter( op, op->oq_add.rs_e, get_assertion( op ) )
+                       != LDAP_COMPARE_TRUE ) )
+       {
+               rs->sr_err = LDAP_ASSERTION_FAILED;
+               e = op->ora_e;
+               goto done;
+       }
+
+       if ( !access_allowed_mask( op, op->ora_e,
+                               slap_schema.si_ad_entry,
+                               NULL, ACL_WRITE, NULL, &mask ) )
+       {
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               e = op->ora_e;
                goto done;
        }
 
@@ -1114,48 +1183,73 @@ backsql_add( Operation *op, SlapReply *rs )
         * the id of the added row; otherwise the procedure
         * is expected to return the id as the first column of a select
         */
-
-       rc = SQLAllocStmt( dbh, &sth );
+       rc = backsql_Prepare( dbh, &sth, oc->bom_create_proc, 0 );
        if ( rc != SQL_SUCCESS ) {
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
+       colnum = 1;
        if ( BACKSQL_IS_ADD( oc->bom_expect_return ) ) {
                rc = backsql_BindParamInt( sth, 1, SQL_PARAM_OUTPUT, &new_keyval );
                if ( rc != SQL_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                               "   backsql_add_attr(): "
-                               "error binding keyval parameter for objectClass %s\n",
-                               oc->bom_oc->soc_cname.bv_val, 0, 0 );
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                               "error binding keyval parameter "
+                               "for objectClass %s\n",
+                               op->ora_e->e_name.bv_val,
+                               oc->bom_oc->soc_cname.bv_val, 0 );
                        backsql_PrintErrors( bi->sql_db_env, dbh, 
                                sth, rc );
                        SQLFreeStmt( sth, SQL_DROP );
 
                        rs->sr_text = "SQL-backend error";
                        rs->sr_err = LDAP_OTHER;
+                       e = NULL;
                        goto done;
                }
+               colnum++;
+       }
+
+       if ( oc->bom_create_hint ) {
+               at = attr_find( op->ora_e->e_attrs, oc->bom_create_hint );
+               if ( at && at->a_vals ) {
+                       backsql_BindParamStr( sth, colnum, SQL_PARAM_INPUT,
+                                       at->a_vals[0].bv_val,
+                                       at->a_vals[0].bv_len );
+                       Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
+                                       "create_proc hint: param = '%s'\n",
+                                       at->a_vals[0].bv_val, 0, 0 );
+
+               } else {
+                       backsql_BindParamStr( sth, colnum, SQL_PARAM_INPUT,
+                                       "", 0 );
+                       Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
+                                       "create_proc hint (%s) not avalable\n",
+                                       oc->bom_create_hint->ad_cname.bv_val,
+                                       0, 0 );
+               }
+               colnum++;
        }
 
        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): executing \"%s\"\n",
-               op->oq_add.rs_e->e_name.bv_val, oc->bom_create_proc, 0 );
-       rc = SQLExecDirect( sth, oc->bom_create_proc, SQL_NTS );
+               op->ora_e->e_name.bv_val, oc->bom_create_proc, 0 );
+       rc = SQLExecute( sth );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "create_proc execution failed\n",
-                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc);
                SQLFreeStmt( sth, SQL_DROP );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
-       if ( op->o_noop ) {
-               SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
-       }
+       /* FIXME: after SQLExecute(), the row is already inserted
+        * (at least with PostgreSQL and unixODBC); needs investigation */
 
        if ( !BACKSQL_IS_ADD( oc->bom_expect_return ) ) {
                SWORD           ncols;
@@ -1163,17 +1257,20 @@ backsql_add( Operation *op, SlapReply *rs )
 
                if ( BACKSQL_CREATE_NEEDS_SELECT( bi ) ) {
                        SQLFreeStmt( sth, SQL_DROP );
-                       rc = SQLAllocStmt( dbh, &sth );
+
+                       rc = backsql_Prepare( dbh, &sth, oc->bom_create_keyval, 0 );
                        if ( rc != SQL_SUCCESS ) {
                                rs->sr_err = LDAP_OTHER;
                                rs->sr_text = "SQL-backend error";
+                               e = NULL;
                                goto done;
                        }
 
-                       rc = SQLExecDirect( sth, oc->bom_create_keyval, SQL_NTS );
+                       rc = SQLExecute( sth );
                        if ( rc != SQL_SUCCESS ) {
                                rs->sr_err = LDAP_OTHER;
                                rs->sr_text = "SQL-backend error";
+                               e = NULL;
                                goto done;
                        }
                }
@@ -1186,21 +1283,23 @@ backsql_add( Operation *op, SlapReply *rs )
                if ( rc != SQL_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                                "create_proc result evaluation failed\n",
-                               op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                               op->ora_e->e_name.bv_val, 0, 0 );
                        backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
                        rs->sr_err = LDAP_OTHER;
                        rs->sr_text = "SQL-backend error";
+                       e = NULL;
                        goto done;
 
                } else if ( ncols != 1 ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                                "create_proc result is bogus (ncols=%d)\n",
-                               op->oq_add.rs_e->e_name.bv_val, ncols, 0 );
+                               op->ora_e->e_name.bv_val, ncols, 0 );
                        backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
                        rs->sr_err = LDAP_OTHER;
                        rs->sr_text = "SQL-backend error";
+                       e = NULL;
                        goto done;
                }
 
@@ -1232,11 +1331,12 @@ backsql_add( Operation *op, SlapReply *rs )
                if ( value_len <= 0 ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                                "create_proc result is empty?\n",
-                               op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                               op->ora_e->e_name.bv_val, 0, 0 );
                        backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
                        rs->sr_err = LDAP_OTHER;
                        rs->sr_text = "SQL-backend error";
+                       e = NULL;
                        goto done;
                }
        }
@@ -1245,118 +1345,99 @@ backsql_add( Operation *op, SlapReply *rs )
 
        Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                "create_proc returned keyval=%ld\n",
-               op->oq_add.rs_e->e_name.bv_val, new_keyval, 0 );
-
-       for ( at = op->oq_add.rs_e->e_attrs; at != NULL; at = at->a_next ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_add(): "
-                       "adding attribute \"%s\"\n", 
-                       at->a_desc->ad_cname.bv_val, 0, 0 );
-
-               /*
-                * Skip:
-                * - the first occurrence of objectClass, which is used
-                *   to determine how to build the SQL entry (FIXME ?!?)
-                * - operational attributes
-                * - empty attributes (FIXME ?!?)
-                */
-               if ( backsql_attr_skip( at->a_desc, at->a_vals ) ) {
-                       continue;
-               }
-
-               if ( at->a_desc == slap_schema.si_ad_objectClass ) {
-                       at_objectClass = at;
-                       continue;
-               }
-
-               rs->sr_err = backsql_add_attr( op, rs, dbh, oc, at, new_keyval );
-               if ( rs->sr_err != LDAP_SUCCESS ) {
-                       goto done;
-               }
-       }
+               op->ora_e->e_name.bv_val, new_keyval, 0 );
 
-       rc = backsql_Prepare( dbh, &sth, bi->sql_insentry_query, 0 );
+       rc = backsql_Prepare( dbh, &sth, bi->sql_insentry_stmt, 0 );
        if ( rc != SQL_SUCCESS ) {
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
        
        rc = backsql_BindParamBerVal( sth, 1, SQL_PARAM_INPUT, &realdn );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_add_attr(): "
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "error binding DN parameter for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val,
+                       oc->bom_oc->soc_cname.bv_val, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
        rc = backsql_BindParamInt( sth, 2, SQL_PARAM_INPUT, &oc->bom_id );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_add_attr(): "
-                       "error binding objectClass ID parameter for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                       "error binding objectClass ID parameter "
+                       "for objectClass %s\n",
+                       op->ora_e->e_name.bv_val,
+                       oc->bom_oc->soc_cname.bv_val, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
-       rc = backsql_BindParamID( sth, 3, SQL_PARAM_INPUT, &parent_id.eid_id );
+       rc = backsql_BindParamID( sth, 3, SQL_PARAM_INPUT, &bsi.bsi_base_id.eid_id );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_add_attr(): "
-                       "error binding parent ID parameter for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                       "error binding parent ID parameter "
+                       "for objectClass %s\n",
+                       op->ora_e->e_name.bv_val,
+                       oc->bom_oc->soc_cname.bv_val, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
        rc = backsql_BindParamInt( sth, 4, SQL_PARAM_INPUT, &new_keyval );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_add_attr(): "
-                       "error binding entry ID parameter for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                       "error binding entry ID parameter "
+                       "for objectClass %s\n",
+                       op->ora_e->e_name.bv_val,
+                       oc->bom_oc->soc_cname.bv_val, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
        Debug( LDAP_DEBUG_TRACE, "   backsql_add(): executing \"%s\" for dn \"%s\"\n",
-                       bi->sql_insentry_query, op->oq_add.rs_e->e_name.bv_val, 0 );
+                       bi->sql_insentry_stmt, op->ora_e->e_name.bv_val, 0 );
 #ifdef BACKSQL_ARBITRARY_KEY
        Debug( LDAP_DEBUG_TRACE, "                  for oc_map_id=%ld, "
-                       "parent_id=%s, keyval=%ld\n",
-                       oc->bom_id, parent_id.eid_id.bv_val, new_keyval );
+                       "p_id=%s, keyval=%ld\n",
+                       oc->bom_id, bsi.bsi_base_id.eid_id.bv_val, new_keyval );
 #else /* ! BACKSQL_ARBITRARY_KEY */
        Debug( LDAP_DEBUG_TRACE, "                  for oc_map_id=%ld, "
-                       "parent_id=%ld, keyval=%ld\n",
-                       oc->bom_id, parent_id.eid_id, new_keyval );
+                       "p_id=%ld, keyval=%ld\n",
+                       oc->bom_id, bsi.bsi_base_id.eid_id, new_keyval );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
        rc = SQLExecute( sth );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
                        "could not insert ldap_entries record\n",
-                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+                       op->ora_e->e_name.bv_val, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
                
                /*
@@ -1365,28 +1446,61 @@ backsql_add( Operation *op, SlapReply *rs )
                SQLFreeStmt( sth, SQL_DROP );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
-       /* FIXME: need ldap_entries.id of newly added entry */
-       if ( at_objectClass ) {
-               rs->sr_err = backsql_add_attr( op, rs, dbh, oc, at_objectClass, new_keyval );
+       SQLFreeStmt( sth, SQL_DROP );
+
+       for ( at = op->ora_e->e_attrs; at != NULL; at = at->a_next ) {
+               Debug( LDAP_DEBUG_TRACE, "   backsql_add(): "
+                       "adding attribute \"%s\"\n", 
+                       at->a_desc->ad_cname.bv_val, 0, 0 );
+
+               /*
+                * Skip:
+                * - the first occurrence of objectClass, which is used
+                *   to determine how to build the SQL entry (FIXME ?!?)
+                * - operational attributes
+                * - empty attributes (FIXME ?!?)
+                */
+               if ( backsql_attr_skip( at->a_desc, at->a_vals ) ) {
+                       continue;
+               }
+
+               if ( at->a_desc == slap_schema.si_ad_objectClass ) {
+                       at_objectClass = at;
+                       continue;
+               }
+
+               rs->sr_err = backsql_add_attr( op, rs, dbh, oc, at, new_keyval );
                if ( rs->sr_err != LDAP_SUCCESS ) {
+                       e = op->ora_e;
                        goto done;
                }
        }
 
-       SQLFreeStmt( sth, SQL_DROP );
+       if ( at_objectClass ) {
+               rs->sr_err = backsql_add_attr( op, rs, dbh, oc,
+                               at_objectClass, new_keyval );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       e = op->ora_e;
+                       goto done;
+               }
+       }
 
 done:;
        /*
         * Commit only if all operations succeed
         */
-       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
-               SQLTransact( SQL_NULL_HENV, dbh, SQL_COMMIT );
+       if ( sth != SQL_NULL_HSTMT ) {
+               SQLUSMALLINT    CompletionType = SQL_ROLLBACK;
 
-       } else {
-               SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
+               if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+                       CompletionType = SQL_COMMIT;
+               }
+
+               SQLTransact( SQL_NULL_HENV, dbh, CompletionType );
        }
 
        /*
@@ -1400,22 +1514,61 @@ done:;
         * in deleting that row.
         */
 
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       if ( e != NULL ) {
+               int     disclose = 1;
+
+               if ( e == op->ora_e && !ACL_GRANT( mask, ACL_DISCLOSE ) ) {
+                       /* mask already collected */
+                       disclose = 0;
+
+               } else if ( e == &p && !access_allowed( op, &p,
+                                       slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       disclose = 0;
+               }
+
+               if ( disclose == 0 ) {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+               }
+       }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
        send_ldap_result( op, rs );
 
        if ( !BER_BVISNULL( &realdn )
-                       && realdn.bv_val != op->oq_add.rs_e->e_name.bv_val )
+                       && realdn.bv_val != op->ora_e->e_name.bv_val )
        {
                ch_free( realdn.bv_val );
        }
-       if ( !BER_BVISNULL( &parent_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &parent_id, 0 );
+
+       if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &p.e_nname ) ) {
+               entry_clean( &p );
        }
 
        Debug( LDAP_DEBUG_TRACE, "<==backsql_add(\"%s\"): %d \"%s\"\n",
-                       op->oq_add.rs_e->e_name.bv_val,
+                       op->ora_e->e_name.bv_val,
                        rs->sr_err,
                        rs->sr_text ? rs->sr_text : "" );
 
-       return ( ( rs->sr_err == LDAP_SUCCESS ) ? op->o_noop : 1 );
+       rs->sr_text = NULL;
+       rs->sr_matched = NULL;
+       if ( rs->sr_ref ) {
+               ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+       }
+
+       return rs->sr_err;
 }
 
index d5730d826b7f68b99baef3a2ed5d589d0bf48e91..e4584c3ebfd655da2d22171cd4e3a7ff13d91f9a 100644 (file)
@@ -1,7 +1,8 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -29,7 +31,7 @@
 static backsql_api *backsqlapi;
 
 int
-backsql_api_config( backsql_info *bi, const char *name )
+backsql_api_config( backsql_info *bi, const char *name, int argc, char *argv[] )
 {
        backsql_api     *ba;
 
@@ -42,6 +44,14 @@ backsql_api_config( backsql_info *bi, const char *name )
 
                        ba2 = ch_malloc( sizeof( backsql_api ) );
                        *ba2 = *ba;
+
+                       if ( ba2->ba_config ) {
+                               if ( ( *ba2->ba_config )( ba2, argc, argv ) ) {
+                                       ch_free( ba2 );
+                                       return 1;
+                               }
+                       }
+                       
                        ba2->ba_next = bi->sql_api;
                        bi->sql_api = ba2;
                        return 0;
@@ -51,12 +61,35 @@ backsql_api_config( backsql_info *bi, const char *name )
        return 1;
 }
 
+int
+backsql_api_destroy( backsql_info *bi )
+{
+       backsql_api     *ba;
+
+       assert( bi );
+
+       ba = bi->sql_api;
+
+       if ( ba == NULL ) {
+               return 0;
+       }
+
+       for ( ; ba; ba = ba->ba_next ) {
+               if ( ba->ba_destroy ) {
+                       (void)( *ba->ba_destroy )( ba );
+               }
+       }
+
+       return 0;
+}
+
 int
 backsql_api_register( backsql_api *ba )
 {
        backsql_api     *ba2;
 
        assert( ba );
+       assert( ba->ba_private == NULL );
 
        if ( ba->ba_name == NULL ) {
                fprintf( stderr, "API module has no name\n" );
index cb6250733c01c286a88fb61d683a2c5a12e89d3c..80794716864cf1707d6fd5f8f53958bc37657700 100644 (file)
@@ -1,9 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Mararati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -17,9 +18,8 @@
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
  * by OpenLDAP Software.  Additional significant contributors include
- *    Pierangelo Mararati
+ * Pierangelo Masarati and Mark Adamson.
  */
-
 /*
  * The following changes have been addressed:
  *      
  *   - check how to allow multiple operations with one statement, to remove
  *     BACKSQL_REALLOC_STMT from modify.c (a more recent unixODBC lib?)
  */
+/*
+ * Improvements submitted by (ITS#3432)
+ *
+ * 1. id_query.patch           applied (with changes)
+ * 2. shortcut.patch           applied (reworked)
+ * 3. create_hint.patch                applied
+ * 4. count_query.patch                applied (reworked)
+ * 5. returncodes.patch                applied (with sanity checks)
+ * 6. connpool.patch           under evaluation
+ * 7. modoc.patch              under evaluation (requires
+ *                             manageDSAit and "manage"
+ *                             access privileges)
+ * 8. miscfixes.patch          applied (reworked; other
+ *                             operations need to load the
+ *                             entire entry for ACL purposes;
+ *                             see ITS#3480, now fixed)
+ *
+ * original description:
+
+         Changes that were made to the SQL backend.
+
+The patches were made against 2.2.18 and can be applied individually,
+but would best be applied in the numerical order of the file names.
+A synopsis of each patch is given here:
+
+
+1. Added an option to set SQL query for the "id_query" operation.
+
+2. Added an option to the SQL backend called "use_subtree_shortcut".
+When a search is performed, the SQL query includes a WHERE clause
+which says the DN must be "LIKE %<searchbase>".  The LIKE operation
+can be slow in an RDBM. This shortcut option says that if the
+searchbase of the LDAP search is the root DN of the SQL backend,
+and thus all objects will match the LIKE operator, do not include
+the "LIKE %<searchbase>" clause in the SQL query (it is replaced
+instead by the always true "1=1" clause to keep the "AND"'s 
+working correctly).  This option is off by default, and should be
+turned on only if all objects to be found in the RDBM are under the
+same root DN. Multiple backends working within the same RDBM table
+space would encounter problems. LDAP searches whose searchbase are
+not at the root DN will bypass this shortcut and employ the LIKE 
+clause.
+
+3. Added a "create_hint" column to ldap_oc_mappings table. Allows
+taking the value of an attr named in "create_hint" and passing it to
+the create_proc procedure.  This is necessary for when an objectClass's
+table is partition indexed by some indexing column and thus the value
+in that indexing column cannot change after the row is created. The
+value for the indexed column is passed into the create_proc, which
+uses it to fill in the indexed column as the new row is created.
+
+4. When loading the values of an attribute, the count(*) of the number
+of values is fetched first and memory is allocated for the array of
+values and normalized values. The old system of loading the values one
+by one and running realloc() on the array of values and normalized
+values each time was badly fragmenting memory. The array of values and
+normalized values would be side by side in memory, and realloc()'ing
+them over and over would force them to leapfrog each other through all
+of available memory. Attrs with a large number of values could not be
+loaded without crashing the slapd daemon.
+
+5. Added code to interpret the value returned by stored procedures
+which have expect_return set. Returned value is interpreted as an LDAP
+return code. This allows the distinction between the SQL failing to
+execute and the SQL running to completion and returning an error code
+which can indicate a policy violation.
+
+6. Added RDBM connection pooling. Once an operation is finished the
+connection to the RDBM is returned to a pool rather than closing.
+Allows the next operation to skip the initialization and authentication
+phases of contacting the RDBM. Also, if licensing with ODBC places
+a limit on the number of connections, an LDAP thread can block waiting
+for another thread to finish, so that no LDAP errors are returned
+for having more LDAP connections than allowed RDBM connections. An
+RDBM connection which receives an SQL error is marked as "tainted"
+so that it will be closed rather than returned to the pool.
+  Also, RDBM connections must be bound to a given LDAP connection AND
+operation number, and NOT just the connection number.  Asynchronous
+LDAP clients can have multiple simultaneous LDAP operations which
+should not share the same RDBM connection.  A given LDAP operation can
+even make multiple SQL operations (e.g. a BIND operation which
+requires SASL to perform an LDAP search to convert the SASL ID to an
+LDAP DN), so each RDBM connection now has a refcount that must reach
+zero before the connection is returned to the free pool.
+
+7. Added ability to change the objectClass of an object. Required 
+considerable work to copy all attributes out of old object and into
+new object.  Does a schema check before proceeding.  Creates a new
+object, fills it in, deletes the old object, then changes the 
+oc_map_id and keyval of the entry in the "ldap_entries" table.
+
+8.  Generic fixes. Includes initializing pointers before they
+get used in error branch cases, pointer checks before dereferencing,
+resetting a return code to success after a COMPARE op, sealing
+memory leaks, and in search.c, changing some of the "1=1" tests to
+"2=2", "3=3", etc so that when reading slapd trace output, the 
+location in the source code where the x=x test was added to the SQL
+can be easily distinguished.
+ */
 
 #ifndef __BACKSQL_H__
 #define __BACKSQL_H__
 
-#include "sql-types.h"
+/* former sql-types.h */
+#include <sql.h>
+#include <sqlext.h>
+
+typedef struct {
+       SWORD           ncols;
+       BerVarray       col_names;
+       UDWORD          *col_prec;
+       char            **cols;
+       SQLINTEGER      *value_len;
+} BACKSQL_ROW_NTS;
 
 /*
  * Better use the standard length of 8192 (as of slap.h)?
  */
 #undef BACKSQL_TRACE
 
+/*
+ * define if using MS SQL and workaround needed (see sql-wrap.c)
+ */
+#undef BACKSQL_MSSQL_WORKAROUND
+
+/*
+ * define to enable values counting for attributes
+ */
+#define BACKSQL_COUNTQUERY
+
+/*
+ * define to enable prettification/validation of values
+ */
+#define BACKSQL_PRETTY_VALIDATE
+
 /*
  * define to enable varchars as unique keys in user tables
  *
  */
 typedef struct backsql_api {
        char                    *ba_name;
+       int                     (*ba_config)( struct backsql_api *self, int argc, char *argv[] );
+       int                     (*ba_destroy)( struct backsql_api *self );
+
        int                     (*ba_dn2odbc)( Operation *op, SlapReply *rs, struct berval *dn );
        int                     (*ba_odbc2dn)( Operation *op, SlapReply *rs, struct berval *dn );
-       struct backsql_api *ba_next;
+
+       void                    *ba_private;
+       struct backsql_api      *ba_next;
 } backsql_api;
 
 /*
@@ -175,24 +304,25 @@ typedef struct backsql_oc_map_rec {
        /*
         * Structure of corresponding LDAP objectClass definition
         */
-       ObjectClass     *bom_oc;
+       ObjectClass             *bom_oc;
 #define BACKSQL_OC_NAME(ocmap) ((ocmap)->bom_oc->soc_cname.bv_val)
        
-       struct berval   bom_keytbl;
-       struct berval   bom_keycol;
+       struct berval           bom_keytbl;
+       struct berval           bom_keycol;
        /* expected to return keyval of newly created entry */
-       char            *bom_create_proc;
+       char                    *bom_create_proc;
        /* in case create_proc does not return the keyval of the newly
         * created row */
-       char            *bom_create_keyval;
+       char                    *bom_create_keyval;
        /* supposed to expect keyval as parameter and delete 
         * all the attributes as well */
-       char            *bom_delete_proc;
+       char                    *bom_delete_proc;
        /* flags whether delete_proc is a function (whether back-sql 
         * should bind first parameter as output for return code) */
-       int             bom_expect_return;
-       unsigned long   bom_id;
-       Avlnode         *bom_attrs;
+       int                     bom_expect_return;
+       unsigned long           bom_id;
+       Avlnode                 *bom_attrs;
+       AttributeDescription    *bom_create_hint;
 } backsql_oc_map_rec;
 
 /*
@@ -221,6 +351,9 @@ typedef struct backsql_at_map_rec {
        /* for optimization purposes attribute load query 
         * is preconstructed from parts on schemamap load time */
        char            *bam_query;
+#ifdef BACKSQL_COUNTQUERY
+       char            *bam_countquery;
+#endif /* BACKSQL_COUNTQUERY */
        /* following flags are bitmasks (first bit used for add_proc, 
         * second - for delete_proc) */
        /* order of parameters for procedures above; 
@@ -241,14 +374,14 @@ typedef struct backsql_at_map_rec {
  * (currently broken) */
 /* #define     BACKSQL_UPPERCASE_FILTER */
 
-#define        BACKSQL_AT_CANUPPERCASE(at)     ((at)->bam_sel_expr_u.bv_val)
+#define        BACKSQL_AT_CANUPPERCASE(at)     ( !BER_BVISNULL( &(at)->bam_sel_expr_u ) )
 
 /* defines to support bitmasks above */
 #define BACKSQL_ADD    0x1
 #define BACKSQL_DEL    0x2
 
-#define BACKSQL_IS_ADD(x)      ( BACKSQL_ADD & (x) )
-#define BACKSQL_IS_DEL(x)      ( BACKSQL_DEL & (x) )
+#define BACKSQL_IS_ADD(x)      ( ( BACKSQL_ADD & (x) ) == BACKSQL_ADD )
+#define BACKSQL_IS_DEL(x)      ( ( BACKSQL_DEL & (x) ) == BACKSQL_DEL )
 
 #define BACKSQL_NCMP(v1,v2)    ber_bvcmp((v1),(v2))
 
@@ -261,8 +394,18 @@ typedef struct berbuf {
        ber_len_t       bb_len;
 } BerBuffer;
 
-#define BB_NULL                { { 0, NULL }, 0 }
-
+#define BB_NULL                { BER_BVNULL, 0 }
+
+/* the function must collect the entry associated to nbase */
+#define BACKSQL_ISF_GET_ID     0x1U
+#define BACKSQL_ISF_GET_ENTRY  ( 0x2U | BACKSQL_ISF_GET_ID )
+#define BACKSQL_ISF_MATCHED    0x4U
+#define BACKSQL_IS_GET_ID(f) \
+       ( ( (f) & BACKSQL_ISF_GET_ID ) == BACKSQL_ISF_GET_ID )
+#define BACKSQL_IS_GET_ENTRY(f) \
+       ( ( (f) & BACKSQL_ISF_GET_ENTRY ) == BACKSQL_ISF_GET_ENTRY )
+#define BACKSQL_IS_MATCHED(f) \
+       ( ( (f) & BACKSQL_ISF_MATCHED ) == BACKSQL_ISF_MATCHED )
 typedef struct backsql_srch_info {
        Operation               *bsi_op;
        SlapReply               *bsi_rs;
@@ -276,8 +419,13 @@ typedef struct backsql_srch_info {
 #define BSQL_SF_FILTER_ENTRYUUID       0x0020U
 #define BSQL_SF_FILTER_ENTRYCSN                0x0040U
 #define BSQL_SF_RETURN_ENTRYUUID       (BSQL_SF_FILTER_ENTRYUUID << 8)
+#define        BSQL_ISF(bsi, f)                ( ( (bsi)->bsi_flags & f ) == f )
+#define        BSQL_ISF_ALL_USER(bsi)          BSQL_ISF(bsi, BSQL_SF_ALL_USER)
+#define        BSQL_ISF_ALL_OPER(bsi)          BSQL_ISF(bsi, BSQL_SF_ALL_OPER)
+#define        BSQL_ISF_ALL_ATTRS(bsi)         BSQL_ISF(bsi, BSQL_SF_ALL_ATTRS)
 
        struct berval           *bsi_base_ndn;
+       int                     bsi_use_subtree_shortcut;
        backsql_entryID         bsi_base_id;
        int                     bsi_scope;
 /* BACKSQL_SCOPE_BASE_LIKE can be set by API in ors_scope
@@ -313,7 +461,7 @@ typedef struct backsql_srch_info {
 /*
  * Backend private data structure
  */
-typedef struct {
+typedef struct backsql_info {
        char            *sql_dbhost;
        int             sql_dbport;
        char            *sql_dbuser;
@@ -329,10 +477,10 @@ typedef struct {
        struct berval   sql_children_cond;
        char            *sql_oc_query,
                        *sql_at_query;
-       char            *sql_insentry_query,
-                       *sql_delentry_query,
-                       *sql_delobjclasses_query,
-                       *sql_delreferrals_query;
+       char            *sql_insentry_stmt,
+                       *sql_delentry_stmt,
+                       *sql_renentry_stmt,
+                       *sql_delobjclasses_stmt;
        char            *sql_id_query;
        char            *sql_has_children_query;
 
@@ -343,9 +491,10 @@ typedef struct {
        struct berval   sql_upper_func_open;
        struct berval   sql_upper_func_close;
        BerVarray       sql_concat_func;
-
        struct berval   sql_strcast_func;
 
+       AttributeName   *sql_anlist;
+
        unsigned int    sql_flags;
 #define        BSQLF_SCHEMA_LOADED             0x0001
 #define        BSQLF_UPPER_NEEDS_CAST          0x0002
@@ -355,25 +504,40 @@ typedef struct {
 #define BSQLF_DONTCHECK_LDAPINFO_DN_RU 0x0020
 #define BSQLF_USE_REVERSE_DN           0x0040
 #define BSQLF_ALLOW_ORPHANS            0x0080
+#define BSQLF_USE_SUBTREE_SHORTCUT     0x0100
+#define BSQLF_FETCH_ALL_USERATTRS      0x0200
+#define BSQLF_FETCH_ALL_OPATTRS                0x0400
+#define        BSQLF_FETCH_ALL_ATTRS           (BSQLF_FETCH_ALL_USERATTRS|BSQLF_FETCH_ALL_OPATTRS)
+
+#define BACKSQL_ISF(si, f) \
+       (((si)->sql_flags & f) == f)
 
 #define        BACKSQL_SCHEMA_LOADED(si) \
-       ((si)->sql_flags & BSQLF_SCHEMA_LOADED)
+       BACKSQL_ISF(si, BSQLF_SCHEMA_LOADED)
 #define BACKSQL_UPPER_NEEDS_CAST(si) \
-       ((si)->sql_flags & BSQLF_UPPER_NEEDS_CAST)
+       BACKSQL_ISF(si, BSQLF_UPPER_NEEDS_CAST)
 #define BACKSQL_CREATE_NEEDS_SELECT(si) \
-       ((si)->sql_flags & BSQLF_CREATE_NEEDS_SELECT)
+       BACKSQL_ISF(si, BSQLF_CREATE_NEEDS_SELECT)
 #define BACKSQL_FAIL_IF_NO_MAPPING(si) \
-       ((si)->sql_flags & BSQLF_FAIL_IF_NO_MAPPING)
+       BACKSQL_ISF(si, BSQLF_FAIL_IF_NO_MAPPING)
 #define BACKSQL_HAS_LDAPINFO_DN_RU(si) \
-       ((si)->sql_flags & BSQLF_HAS_LDAPINFO_DN_RU)
+       BACKSQL_ISF(si, BSQLF_HAS_LDAPINFO_DN_RU)
 #define BACKSQL_DONTCHECK_LDAPINFO_DN_RU(si) \
-       ((si)->sql_flags & BSQLF_DONTCHECK_LDAPINFO_DN_RU)
+       BACKSQL_ISF(si, BSQLF_DONTCHECK_LDAPINFO_DN_RU)
 #define BACKSQL_USE_REVERSE_DN(si) \
-       ((si)->sql_flags & BSQLF_USE_REVERSE_DN)
+       BACKSQL_ISF(si, BSQLF_USE_REVERSE_DN)
 #define BACKSQL_CANUPPERCASE(si) \
        (!BER_BVISNULL( &(si)->sql_upper_func ))
 #define BACKSQL_ALLOW_ORPHANS(si) \
-       ((si)->sql_flags & BSQLF_ALLOW_ORPHANS)
+       BACKSQL_ISF(si, BSQLF_ALLOW_ORPHANS)
+#define BACKSQL_USE_SUBTREE_SHORTCUT(si) \
+       BACKSQL_ISF(si, BSQLF_USE_SUBTREE_SHORTCUT)
+#define BACKSQL_FETCH_ALL_USERATTRS(si) \
+       BACKSQL_ISF(si, BSQLF_FETCH_ALL_USERATTRS)
+#define BACKSQL_FETCH_ALL_OPATTRS(si) \
+       BACKSQL_ISF(si, BSQLF_FETCH_ALL_OPATTRS)
+#define BACKSQL_FETCH_ALL_ATTRS(si) \
+       BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS)
 
        Entry           *sql_baseObject;
 #ifdef BACKSQL_ARBITRARY_KEY
@@ -382,7 +546,7 @@ typedef struct {
 #define        BACKSQL_IS_BASEOBJECT_ID(id)    (bvmatch((id), &backsql_baseObject_bv))
 #else /* ! BACKSQL_ARBITRARY_KEY */
 #define BACKSQL_BASEOBJECT_ID          0
-#define BACKSQL_BASEOBJECT_IDSTR       "0"
+#define BACKSQL_BASEOBJECT_IDSTR       LDAP_XSTRING(BACKSQL_BASEOBJECT_ID)
 #define BACKSQL_BASEOBJECT_KEYVAL      0
 #define        BACKSQL_IS_BASEOBJECT_ID(id)    (*(id) == BACKSQL_BASEOBJECT_ID)
 #endif /* ! BACKSQL_ARBITRARY_KEY */
@@ -404,7 +568,16 @@ typedef struct {
 #define BACKSQL_AVL_STOP               0
 #define BACKSQL_AVL_CONTINUE           1
 
-#endif /* __BACKSQL_H__ */
-
+/* see ldap.h for the meaning of the macros and of the values */
+#define BACKSQL_LEGAL_ERROR( rc ) \
+       ( LDAP_RANGE( (rc), 0x00, 0x0e ) \
+         || LDAP_ATTR_ERROR( (rc) ) \
+         || LDAP_NAME_ERROR( (rc) ) \
+         || LDAP_SECURITY_ERROR( (rc) ) \
+         || LDAP_SERVICE_ERROR( (rc) ) \
+         || LDAP_UPDATE_ERROR( (rc) ) )
+#define BACKSQL_SANITIZE_ERROR( rc ) \
+       ( BACKSQL_LEGAL_ERROR( (rc) ) ? (rc) : LDAP_OTHER )
 
+#endif /* __BACKSQL_H__ */
 
index c775280a9bf1a3ecb6983f35c686565e231d69b0..5817d06af60eaaa9b1fc0dea4fd214ef3385a267 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
 int 
 backsql_bind( Operation *op, SlapReply *rs )
 {
-       SQLHDBC                 dbh;
-       AttributeDescription    *password = slap_schema.si_ad_userPassword;
-       Entry                   *e, user_entry;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
+       Entry                   e = { 0 };
        Attribute               *a;
-       backsql_srch_info       bsi;
+       backsql_srch_info       bsi = { 0 };
        AttributeName           anlist[2];
        int                     rc;
  
@@ -43,7 +44,7 @@ backsql_bind( Operation *op, SlapReply *rs )
                ber_dupbv( &op->oq_bind.rb_edn, be_root_dn( op->o_bd ) );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_bind() root bind\n", 
                                0, 0, 0 );
-               return 0;
+               return LDAP_SUCCESS;
        }
 
        ber_dupbv( &op->oq_bind.rb_edn, &op->o_req_ndn );
@@ -52,7 +53,7 @@ backsql_bind( Operation *op, SlapReply *rs )
                rs->sr_err = LDAP_STRONG_AUTH_NOT_SUPPORTED;
                rs->sr_text = "authentication method not supported"; 
                send_ldap_result( op, rs );
-               return 1;
+               return rs->sr_err;
        }
 
        /*
@@ -66,72 +67,58 @@ backsql_bind( Operation *op, SlapReply *rs )
 
                rs->sr_text = ( rs->sr_err == LDAP_OTHER )
                        ? "SQL-backend error" : NULL;
-               send_ldap_result( op, rs );
-               return 1;
+               goto error_return;
        }
 
-       anlist[0].an_name = password->ad_cname;
-       anlist[0].an_desc = password;
+       anlist[0].an_name = slap_schema.si_ad_userPassword->ad_cname;
+       anlist[0].an_desc = slap_schema.si_ad_userPassword;
        anlist[1].an_name.bv_val = NULL;
 
+       bsi.bsi_e = &e;
        rc = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
-                       -1, -1, -1, NULL, dbh, op, rs, anlist,
-                       ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs, anlist,
+                       BACKSQL_ISF_GET_ENTRY );
        if ( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
                        "could not retrieve bindDN ID - no such entry\n", 
                        0, 0, 0 );
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
-               send_ldap_result( op, rs );
-               return 1;
-       }
-
-       bsi.bsi_e = &user_entry;
-       rc = backsql_id2entry( &bsi, &bsi.bsi_base_id );
-       if ( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
-                       "error %d in backsql_id2entry() "
-                       "- auth failed\n", rc, 0, 0 );
-               rs->sr_err = LDAP_INVALID_CREDENTIALS;
                goto error_return;
        }
-       e = &user_entry;
 
-       if ( ! access_allowed( op, e, password, NULL, ACL_AUTH, NULL ) ) {
-#if 1
-               rs->sr_err = LDAP_INVALID_CREDENTIALS;
-#else
-               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-#endif
-               goto error_return;
-       }
-
-       a = attr_find( e->e_attrs, password );
+       a = attr_find( e.e_attrs, slap_schema.si_ad_userPassword );
        if ( a == NULL ) {
-#if 1
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
-#else
-               rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
-#endif
                goto error_return;
        }
 
-       if ( slap_passwd_check( op->o_conn, a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 ) {
+       if ( slap_passwd_check( op, &e, a, &op->oq_bind.rb_cred,
+                               &rs->sr_text ) != 0 )
+       {
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
                goto error_return;
        }
 
 error_return:;
        if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &e.e_nname ) ) {
+               entry_clean( &e );
+       }
+
+       if ( bsi.bsi_attrs != NULL ) {
+               op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
        }
 
-       if ( rs->sr_err ) {
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
-               return 1;
        }
        
-       Debug(LDAP_DEBUG_TRACE,"<==backsql_bind()\n",0,0,0);
-       return 0;
+       Debug( LDAP_DEBUG_TRACE,"<==backsql_bind()\n", 0, 0, 0 );
+
+       return rs->sr_err;
 }
  
index d091def078deaa790054c9dee7ec04b73e93f80d..4783714f148bd393ec4e1f429d5c9d1822911dc0 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
 int
 backsql_compare( Operation *op, SlapReply *rs )
 {
-       SQLHDBC                 dbh;
-       Entry                   *e = NULL, user_entry;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
+       Entry                   e = { 0 };
        Attribute               *a = NULL;
-       backsql_srch_info       bsi;
+       backsql_srch_info       bsi = { 0 };
        int                     rc;
+       int                     manageDSAit = get_manageDSAit( op );
        AttributeName           anlist[2];
 
-       user_entry.e_name.bv_val = NULL;
-       user_entry.e_name.bv_len = 0;
-       user_entry.e_nname.bv_val = NULL;
-       user_entry.e_nname.bv_len = 0;
-       user_entry.e_attrs = NULL;
        Debug( LDAP_DEBUG_TRACE, "==>backsql_compare()\n", 0, 0, 0 );
 
        rs->sr_err = backsql_get_db_conn( op, &dbh );
-       if (!dbh) {
+       if ( !dbh ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
                        "could not get connection handle - exiting\n",
                        0, 0, 0 );
@@ -55,22 +52,62 @@ backsql_compare( Operation *op, SlapReply *rs )
                goto return_results;
        }
 
-       memset( &anlist[0], 0, 2 * sizeof( AttributeName ) );
-       anlist[0].an_name = op->oq_compare.rs_ava->aa_desc->ad_cname;
-       anlist[0].an_desc = op->oq_compare.rs_ava->aa_desc;
+       anlist[ 0 ].an_name = op->oq_compare.rs_ava->aa_desc->ad_cname;
+       anlist[ 0 ].an_desc = op->oq_compare.rs_ava->aa_desc;
+       BER_BVZERO( &anlist[ 1 ].an_name );
 
        /*
-        * Try to get attr as dynamic operational
+        * Get the entry
         */
+       bsi.bsi_e = &e;
+       rc = backsql_init_search( &bsi, &op->o_req_ndn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs, anlist,
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+       switch ( rc ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               /* fallthru */
+
+       default:
+               Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
+                       "could not retrieve compareDN ID - no such entry\n", 
+                       0, 0, 0 );
+               goto return_results;
+       }
+
+       if ( get_assert( op ) &&
+                       ( test_filter( op, &e, get_assertion( op ) )
+                         != LDAP_COMPARE_TRUE ) )
+       {
+               rs->sr_err = LDAP_ASSERTION_FAILED;
+               goto return_results;
+       }
+
        if ( is_at_operational( op->oq_compare.rs_ava->aa_desc->ad_type ) ) {
                SlapReply       nrs = { 0 };
+               Attribute       **ap;
 
-               user_entry.e_attrs = NULL;
-               user_entry.e_name = op->o_req_dn;
-               user_entry.e_nname = op->o_req_ndn;
+               for ( ap = &e.e_attrs; *ap; ap = &(*ap)->a_next )
+                       ;
 
                nrs.sr_attrs = anlist;
-               nrs.sr_entry = &user_entry;
+               nrs.sr_entry = &e;
                nrs.sr_attr_flags = SLAP_OPATTRS_NO;
                nrs.sr_operational_attrs = NULL;
 
@@ -79,43 +116,21 @@ backsql_compare( Operation *op, SlapReply *rs )
                        goto return_results;
                }
                
-               user_entry.e_attrs = nrs.sr_operational_attrs;
-
-       } else {
-               rc = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
-                               -1, -1, -1, NULL, dbh, op, rs, anlist,
-                               ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
-               if ( rc != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
-                               "could not retrieve compareDN ID - no such entry\n", 
-                               0, 0, 0 );
-                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
-                       goto return_results;
-               }
-
-               bsi.bsi_e = &user_entry;
-               rc = backsql_id2entry( &bsi, &bsi.bsi_base_id );
-               if ( rc != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
-                               "error %d in backsql_id2entry() "
-                               "- compare failed\n", rc, 0, 0 );
-                       rs->sr_err = rc;
-                       goto return_results;
-               }
+               *ap = nrs.sr_operational_attrs;
        }
-       e = &user_entry;
 
-       if ( ! access_allowed( op, e, op->oq_compare.rs_ava->aa_desc, 
+       if ( ! access_allowed( op, &e, op->oq_compare.rs_ava->aa_desc,
                                &op->oq_compare.rs_ava->aa_value,
-                               ACL_COMPARE, NULL ) ) {
+                               ACL_COMPARE, NULL ) )
+       {
                rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
                goto return_results;
        }
 
        rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
-       for ( a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc );
+       for ( a = attrs_find( e.e_attrs, op->oq_compare.rs_ava->aa_desc );
                        a != NULL;
-                       a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ))
+                       a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ) )
        {
                rs->sr_err = LDAP_COMPARE_FALSE;
                if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
@@ -131,24 +146,56 @@ backsql_compare( Operation *op, SlapReply *rs )
        }
 
 return_results:;
+       switch ( rs->sr_err ) {
+       case LDAP_COMPARE_TRUE:
+       case LDAP_COMPARE_FALSE:
+               break;
+
+       default:
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+               if ( !BER_BVISNULL( &e.e_nname ) &&
+                               ! access_allowed( op, &e,
+                                       slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       rs->sr_text = NULL;
+               }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+               break;
+       }
+
        send_ldap_result( op, rs );
 
+       if ( rs->sr_matched ) {
+               rs->sr_matched = NULL;
+       }
+
+       if ( rs->sr_ref ) {
+               ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+       }
+
        if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &e.e_nname ) ) {
+               entry_clean( &e );
        }
 
-       if ( e != NULL ) {
-               entry_clean( e );
+       if ( bsi.bsi_attrs != NULL ) {
+               op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
        }
 
        Debug(LDAP_DEBUG_TRACE,"<==backsql_compare()\n",0,0,0);
        switch ( rs->sr_err ) {
        case LDAP_COMPARE_TRUE:
        case LDAP_COMPARE_FALSE:
-               return 0;
+               return LDAP_SUCCESS;
 
        default:
-               return 1;
+               return rs->sr_err;
        }
 }
  
index 0068e8269c91422e516214422c78d5b8890faa70..9e82f0b3584fc15945b19c07e122a20cf347eef9 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -173,18 +176,20 @@ backsql_db_config(
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
                        "at_query=%s\n", bi->sql_at_query, 0, 0 );
 
-       } else if ( !strcasecmp( argv[ 0 ], "insentry_query" ) ) {
+       } else if ( !strcasecmp( argv[ 0 ], "insentry_stmt" ) ||
+                       !strcasecmp( argv[ 0 ], "insentry_query" ) )
+       {
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE, 
                                "<==backsql_db_config (%s line %d): "
                                "missing SQL statement "
-                               "in \"insentry_query\" directive\n",
+                               "in \"insentry_stmt\" directive\n",
                                fname, lineno, 0 );
                        return 1;
                }
-               bi->sql_insentry_query = ch_strdup( argv[ 1 ] );
+               bi->sql_insentry_stmt = ch_strdup( argv[ 1 ] );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "insentry_query=%s\n", bi->sql_insentry_query, 0, 0 );
+                       "insentry_stmt=%s\n", bi->sql_insentry_stmt, 0, 0 );
 
        } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) {
                if ( argc < 2 ) {
@@ -271,44 +276,50 @@ backsql_db_config(
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
                        "strcast_func=%s\n", bi->sql_strcast_func.bv_val, 0, 0 );
 
-       } else if ( !strcasecmp( argv[ 0 ], "delentry_query" ) ) {
+       } else if ( !strcasecmp( argv[ 0 ], "delentry_stmt" ) ||
+                       !strcasecmp( argv[ 0 ], "delentry_query" ) )
+       {
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
                                "<==backsql_db_config (%s line %d): "
                                "missing SQL statement "
-                               "in \"delentry_query\" directive\n",
+                               "in \"delentry_stmt\" directive\n",
                                fname, lineno, 0 );
                        return 1;
                }
-               bi->sql_delentry_query = ch_strdup( argv[ 1 ] );
+               bi->sql_delentry_stmt = ch_strdup( argv[ 1 ] );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "delentry_query=%s\n", bi->sql_delentry_query, 0, 0 );
+                       "delentry_stmt=%s\n", bi->sql_delentry_stmt, 0, 0 );
 
-       } else if ( !strcasecmp( argv[ 0 ], "delobjclasses_query" ) ) {
+       } else if ( !strcasecmp( argv[ 0 ], "renentry_stmt" ) ||
+                       !strcasecmp( argv[ 0 ], "renentry_query" ) )
+       {
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
                                "<==backsql_db_config (%s line %d): "
                                "missing SQL statement "
-                               "in \"delobjclasses_query\" directive\n",
+                               "in \"renentry_stmt\" directive\n",
                                fname, lineno, 0 );
                        return 1;
                }
-               bi->sql_delobjclasses_query = ch_strdup( argv[ 1 ] );
+               bi->sql_renentry_stmt = ch_strdup( argv[ 1 ] );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "delobjclasses_query=%s\n", bi->sql_delobjclasses_query, 0, 0 );
+                       "renentry_stmt=%s\n", bi->sql_renentry_stmt, 0, 0 );
 
-       } else if ( !strcasecmp( argv[ 0 ], "delreferrals_query" ) ) {
+       } else if ( !strcasecmp( argv[ 0 ], "delobjclasses_stmt" ) ||
+                       !strcasecmp( argv[ 0 ], "delobjclasses_query" ) )
+       {
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
                                "<==backsql_db_config (%s line %d): "
                                "missing SQL statement "
-                               "in \"delreferrals_query\" directive\n",
+                               "in \"delobjclasses_stmt\" directive\n",
                                fname, lineno, 0 );
                        return 1;
                }
-               bi->sql_delreferrals_query = ch_strdup( argv[ 1 ] );
+               bi->sql_delobjclasses_stmt = ch_strdup( argv[ 1 ] );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "delreferrals_query=%s\n", bi->sql_delreferrals_query, 0, 0 );
+                       "delobjclasses_stmt=%s\n", bi->sql_delobjclasses_stmt, 0, 0 );
 
        } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) {
                if ( argc < 2 ) {
@@ -433,7 +444,8 @@ backsql_db_config(
                }
 
        } else if ( !strcasecmp( argv[ 0 ], "sqllayer") ) {
-               if ( backsql_api_config( bi, argv[ 1 ] ) ) {
+               if ( backsql_api_config( bi, argv[ 1 ], argc - 2, &argv[ 2 ] ) )
+               {
                        Debug( LDAP_DEBUG_TRACE,
                                "<==backsql_db_config (%s line %d): "
                                "unable to load sqllayer \"%s\"\n",
@@ -441,6 +453,114 @@ backsql_db_config(
                        return 1;
                }
 
+       } else if ( !strcasecmp( argv[ 0 ], "id_query" ) ) {
+               if ( argc < 2 ) {
+                       Debug( LDAP_DEBUG_TRACE, 
+                               "<==backsql_db_config (%s line %d): "
+                               "missing SQL condition "
+                               "in \"id_query\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+               bi->sql_id_query = ch_strdup( argv[ 1 ] );
+               Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
+                       "id_query=%s\n", bi->sql_id_query, 0, 0 );
+
+       } else if ( !strcasecmp( argv[ 0 ], "use_subtree_shortcut") ) {
+               if ( argc < 2 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "missing { yes | no }"
+                               "in \"use_subtree_shortcut\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
+               if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
+                       bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT;
+
+               } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
+                       bi->sql_flags &= ~BSQLF_USE_SUBTREE_SHORTCUT;
+
+               } else {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "\"use_subtree_shortcut\" directive arg "
+                               "must be \"yes\" or \"no\"\n",
+                               fname, lineno, 0 );
+                       return 1;
+
+               }
+               Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
+                       "use_subtree_shortcut=%s\n", 
+                       BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ? "yes" : "no",
+                       0, 0 );
+
+       } else if ( !strcasecmp( argv[ 0 ], "fetch_all_attrs") ) {
+               if ( argc < 2 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "missing { yes | no }"
+                               "in \"fetch_all_attrs\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
+               if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
+                       bi->sql_flags |= BSQLF_FETCH_ALL_ATTRS;
+
+               } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
+                       bi->sql_flags &= ~BSQLF_FETCH_ALL_ATTRS;
+
+               } else {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "\"fetch_all_attrs\" directive arg "
+                               "must be \"yes\" or \"no\"\n",
+                               fname, lineno, 0 );
+                       return 1;
+
+               }
+               Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
+                       "fetch_all_attrs=%s\n", 
+                       BACKSQL_FETCH_ALL_ATTRS( bi ) ? "yes" : "no",
+                       0, 0 );
+
+       } else if ( !strcasecmp( argv[ 0 ], "fetch_attrs") ) {
+               char    *str, *s, *next;
+               char    delimstr[] = ",";
+
+               if ( argc < 2 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "missing <attrlist>"
+                               "in \"fetch_all_attrs <attrlist>\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
+               str = ch_strdup( argv[ 1 ] );
+               for ( s = ldap_pvt_strtok( str, delimstr, &next );
+                               s != NULL;
+                               s = ldap_pvt_strtok( NULL, delimstr, &next ) )
+               {
+                       if ( strlen( s ) == 1 ) {
+                               if ( *s == '*' ) {
+                                       bi->sql_flags |= BSQLF_FETCH_ALL_USERATTRS;
+                                       argv[ 1 ][ s - str ] = ',';
+
+                               } else if ( *s == '+' ) {
+                                       bi->sql_flags |= BSQLF_FETCH_ALL_OPATTRS;
+                                       argv[ 1 ][ s - str ] = ',';
+                               }
+                       }
+               }
+               ch_free( str );
+               bi->sql_anlist = str2anlist( bi->sql_anlist, argv[ 1 ], delimstr );
+               if ( bi->sql_anlist == NULL ) {
+                       return -1;
+               }
+
        } else {
                return SLAP_CONF_UNKNOWN;
        }
@@ -469,7 +589,8 @@ read_baseObject(
        fp = fopen( fname, "r" );
        if ( fp == NULL ) {
                Debug( LDAP_DEBUG_ANY,
-                       "could not open back-sql baseObject attr file \"%s\" - absolute path?\n",
+                       "could not open back-sql baseObject "
+                       "attr file \"%s\" - absolute path?\n",
                        fname, 0, 0 );
                perror( fname );
                return LDAP_OTHER;
@@ -491,8 +612,9 @@ read_baseObject(
                Attribute       *a;
 
                if( e == NULL ) {
-                       fprintf( stderr, "back-sql baseObject: could not parse entry (line=%d)\n",
-                               lineno );
+                       fprintf( stderr, "back-sql baseObject: "
+                                       "could not parse entry (line=%d)\n",
+                                       lineno );
                        rc = LDAP_OTHER;
                        break;
                }
@@ -500,8 +622,9 @@ read_baseObject(
                /* make sure the DN is the database's suffix */
                if ( !be_issuffix( be, &e->e_nname ) ) {
                        fprintf( stderr,
-                               "back-sql: invalid baseObject - dn=\"%s\" (line=%d)\n",
-                               e->e_dn, lineno );
+                               "back-sql: invalid baseObject - "
+                               "dn=\"%s\" (line=%d)\n",
+                               e->e_name.bv_val, lineno );
                        entry_free( e );
                        rc = EXIT_FAILURE;
                        break;
@@ -512,8 +635,10 @@ read_baseObject(
                 * entry, and add each attribute type and description to baseObject
                 */
                for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
-                       if ( attr_merge( bi->sql_baseObject, a->a_desc, a->a_vals,
-                               ( a->a_nvals == a->a_vals ) ? NULL : a->a_nvals ) )
+                       if ( attr_merge( bi->sql_baseObject, a->a_desc,
+                                               a->a_vals,
+                                               ( a->a_nvals == a->a_vals ) ?
+                                               NULL : a->a_nvals ) )
                        {
                                rc = LDAP_OTHER;
                                break;
@@ -535,7 +660,8 @@ read_baseObject(
 
        fclose( fp );
 
-       Debug( LDAP_DEBUG_CONFIG, "back-sql baseObject file \"%s\" read.\n", fname, 0, 0 );
+       Debug( LDAP_DEBUG_CONFIG, "back-sql baseObject file \"%s\" read.\n",
+                       fname, 0, 0 );
 
        return rc;
 }
@@ -556,9 +682,11 @@ create_baseObject(
                        "dn: %s\n"
                        "objectClass: extensibleObject\n"
                        "description: builtin baseObject for back-sql\n"
-                       "description: all entries mapped in the \"ldap_entries\" table\n"
-                       "description: must have \"" BACKSQL_BASEOBJECT_IDSTR "\" "
-                               "in the \"parent\" column",
+                       "description: all entries mapped "
+                       "in the \"ldap_entries\" table\n"
+                       "description: must have "
+                       "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
+                       "in the \"parent\" column",
                        be->be_suffix[0].bv_val );
 
        bi->sql_baseObject = str2entry( buf );
@@ -574,11 +702,14 @@ create_baseObject(
                return 0;
        }
 
-       rc = ldap_bv2rdn( &be->be_suffix[ 0 ], &rdn, (char **) &p, LDAP_DN_FORMAT_LDAP );
+       rc = ldap_bv2rdn( &be->be_suffix[ 0 ], &rdn, (char **)&p,
+                       LDAP_DN_FORMAT_LDAP );
        if ( rc != LDAP_SUCCESS ) {
                snprintf( buf, sizeof(buf),
-                       "unable to extract RDN from baseObject DN \"%s\" (%d: %s)",
-                       be->be_suffix[ 0 ].bv_val, rc, ldap_err2string( rc ) );
+                       "unable to extract RDN "
+                       "from baseObject DN \"%s\" (%d: %s)",
+                       be->be_suffix[ 0 ].bv_val,
+                       rc, ldap_err2string( rc ) );
                Debug( LDAP_DEBUG_TRACE,
                        "<==backsql_db_config (%s line %d): %s\n",
                        fname, lineno, buf );
@@ -622,12 +753,14 @@ create_baseObject(
        
                        if ( rc != LDAP_SUCCESS ) {
                                snprintf( buf, sizeof(buf),
-                                       "prettying of attribute #%d from baseObject "
+                                       "prettying of attribute #%d "
+                                       "from baseObject "
                                        "DN \"%s\" failed: %d: %s",
                                        iAVA, be->be_suffix[ 0 ].bv_val,
                                        rc, ldap_err2string( rc ) );
                                Debug( LDAP_DEBUG_TRACE,
-                                       "<==backsql_db_config (%s line %d): %s\n",
+                                       "<==backsql_db_config (%s line %d): "
+                                       "%s\n",
                                        fname, lineno, buf );
                                return 1;
                        }
index c769783ca05584f3a8b5c9de9a37d0993b49c36e..79a8e98e54201c9d49292d176407ea45e1833b51 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -80,34 +82,22 @@ int
 backsql_delete( Operation *op, SlapReply *rs )
 {
        backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
-       SQLHDBC                 dbh;
-       SQLHSTMT                sth;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        RETCODE                 rc;
-       int                     retval;
+       int                     prc = LDAP_SUCCESS;
        backsql_oc_map_rec      *oc = NULL;
-       backsql_entryID         e_id = BACKSQL_ENTRYID_INIT;
-       Entry                   e;
+       backsql_srch_info       bsi = { 0 };
+       backsql_entryID         e_id = { 0 };
+       Entry                   d = { 0 }, p = { 0 }, *e = NULL;
+       struct berval           pdn = BER_BVNULL;
+       int                     manageDSAit = get_manageDSAit( op );
        /* first parameter no */
        SQLUSMALLINT            pno;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_delete(): deleting entry \"%s\"\n",
                        op->o_req_ndn.bv_val, 0, 0 );
 
-       dnParent( &op->o_req_dn, &e.e_name );
-       dnParent( &op->o_req_ndn, &e.e_nname );
-       e.e_attrs = NULL;
-
-       /* check parent for "children" acl */
-       if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
-                       NULL, ACL_WRITE, NULL ) ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
-                       "no write access to parent\n", 
-                       0, 0, 0 );
-               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-               goto done;
-
-       }
-       
        rs->sr_err = backsql_get_db_conn( op, &dbh );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
@@ -115,40 +105,103 @@ backsql_delete( Operation *op, SlapReply *rs )
                        0, 0, 0 );
                rs->sr_text = ( rs->sr_err == LDAP_OTHER )
                        ? "SQL-backend error" : NULL;
+               e = NULL;
                goto done;
        }
        
-       rs->sr_err = backsql_dn2id( op, rs, &e_id, dbh, &op->o_req_ndn, 1 );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
+       /*
+        * Get the entry
+        */
+       bsi.bsi_e = &d;
+       rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs,
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+       switch ( rs->sr_err ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               e = &d;
+               /* fallthru */
+
+       default:
+               Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
+                       "could not retrieve deleteDN ID - no such entry\n", 
+                       0, 0, 0 );
+               if ( !BER_BVISNULL( &d.e_nname ) ) {
+                       /* FIXME: should always be true! */
+                       e = &d;
+
+               } else {
+                       e = NULL;
+               }
+               goto done;
+       }
+
+       if ( get_assert( op ) &&
+                       ( test_filter( op, &d, get_assertion( op ) )
+                         != LDAP_COMPARE_TRUE ) )
+       {
+               rs->sr_err = LDAP_ASSERTION_FAILED;
+               e = &d;
+               goto done;
+       }
+
+       if ( !access_allowed( op, &d, slap_schema.si_ad_entry, 
+                       NULL, ACL_WRITE, NULL ) )
+       {
                Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
-                       "could not lookup entry id\n", 0, 0, 0 );
+                       "no write access to entry\n", 
+                       0, 0, 0 );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               e = &d;
                goto done;
        }
 
        rs->sr_err = backsql_has_children( bi, dbh, &op->o_req_ndn );
        switch ( rs->sr_err ) {
+       case LDAP_COMPARE_FALSE:
+               rs->sr_err = LDAP_SUCCESS;
+               break;
+
        case LDAP_COMPARE_TRUE:
+               if ( get_treeDelete( op ) ) {
+                       /* not supported yet */ ;
+               }
                Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
                        "entry \"%s\" has children\n",
                        op->o_req_dn.bv_val, 0, 0 );
                rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
                rs->sr_text = "subtree delete not supported";
-               goto done;
-
-       case LDAP_COMPARE_FALSE:
-               break;
+               /* fallthru */
 
        default:
+               e = &d;
                goto done;
        }
 
-       oc = backsql_id2oc( bi, e_id.eid_oc_id );
+       oc = backsql_id2oc( bi, bsi.bsi_base_id.eid_oc_id );
        if ( oc == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
                        "cannot determine objectclass of entry -- aborting\n",
                        0, 0, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "operation not permitted within namingContext";
+               e = NULL;
                goto done;
        }
 
@@ -158,12 +211,48 @@ backsql_delete( Operation *op, SlapReply *rs )
                        "for this objectclass - aborting\n", 0, 0, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "operation not permitted within namingContext";
+               e = NULL;
+               goto done;
+       }
+
+       /*
+        * Get the parent
+        */
+       dnParent( &op->o_req_ndn, &pdn );
+       bsi.bsi_e = &p;
+       e_id = bsi.bsi_base_id;
+       rs->sr_err = backsql_init_search( &bsi, &pdn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs,
+                       BACKSQL_ISF_GET_ENTRY );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
+                       "could not retrieve deleteDN ID - no such entry\n", 
+                       0, 0, 0 );
+               e = &p;
                goto done;
        }
 
+       (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+
+       /* check parent for "children" acl */
+       if ( !access_allowed( op, &p, slap_schema.si_ad_children, 
+                       NULL, ACL_WRITE, NULL ) )
+       {
+               Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
+                       "no write access to parent\n", 
+                       0, 0, 0 );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               e = &p;
+               goto done;
+
+       }
+
        /* avl_apply ... */
        rs->sr_err = backsql_delete_all_attrs( op, rs, dbh, &e_id, oc );
        if ( rs->sr_err != LDAP_SUCCESS ) {
+               e = &d;
                goto done;
        }
 
@@ -177,12 +266,13 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
        if ( BACKSQL_IS_DEL( oc->bom_expect_return ) ) {
                pno = 1;
-               rc = backsql_BindParamInt( sth, 1, SQL_PARAM_OUTPUT, &retval );
+               rc = backsql_BindParamInt( sth, 1, SQL_PARAM_OUTPUT, &prc );
                if ( rc != SQL_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE,
                                "   backsql_delete(): "
@@ -194,6 +284,7 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                        rs->sr_text = "SQL-backend error";
                        rs->sr_err = LDAP_OTHER;
+                       e = NULL;
                        goto done;
                }
 
@@ -213,23 +304,38 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
        rc = SQLExecute( sth );
-       if ( rc != SQL_SUCCESS ) {
+       if ( rc == SQL_SUCCESS && prc == LDAP_SUCCESS ) {
+               rs->sr_err = LDAP_SUCCESS;
+
+       } else {
                Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
-                       "delete_proc execution failed\n", 0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
+                       "delete_proc execution failed (rc=%d, prc=%d)\n",
+                       rc, prc, 0 );
+
+
+               if ( prc != LDAP_SUCCESS ) {
+                       /* SQL procedure executed fine 
+                        * but returned an error */
+                       rs->sr_err = BACKSQL_SANITIZE_ERROR( prc );
+
+               } else {
+                       backsql_PrintErrors( bi->sql_db_env, dbh,
+                                       sth, rc );
+                       rs->sr_err = LDAP_OTHER;
+               }
                SQLFreeStmt( sth, SQL_DROP );
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
+               e = &d;
                goto done;
        }
        SQLFreeStmt( sth, SQL_DROP );
 
        /* delete "auxiliary" objectClasses, if any... */
-       rc = backsql_Prepare( dbh, &sth, bi->sql_delobjclasses_query, 0 );
+       rc = backsql_Prepare( dbh, &sth, bi->sql_delobjclasses_stmt, 0 );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_delete(): "
@@ -239,6 +345,7 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
@@ -255,6 +362,7 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
@@ -274,62 +382,13 @@ backsql_delete( Operation *op, SlapReply *rs )
                SQLFreeStmt( sth, SQL_DROP );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
-               goto done;
-       }
-       SQLFreeStmt( sth, SQL_DROP );
-
-       /* delete referrals, if any... */
-       rc = backsql_Prepare( dbh, &sth, bi->sql_delreferrals_query, 0 );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_delete(): "
-                       "error preparing ldap_referrals delete query\n", 
-                       0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
-               goto done;
-       }
-
-       rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT, &e_id.eid_id );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_delete(): "
-                       "error binding referrals entry ID parameter "
-                       "for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, 
-                       sth, rc );
-               SQLFreeStmt( sth, SQL_DROP );
-
-               rs->sr_text = "SQL-backend error";
-               rs->sr_err = LDAP_OTHER;
-               goto done;
-       }
-
-       rc = SQLExecute( sth );
-       switch ( rc ) {
-       case SQL_NO_DATA:
-               /* apparently there were no referrals
-                * for this entry... */
-       case SQL_SUCCESS:
-               break;
-
-       default:
-               Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
-                       "failed to delete record from ldap_referrals\n", 
-                       0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-               SQLFreeStmt( sth, SQL_DROP );
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
        SQLFreeStmt( sth, SQL_DROP );
 
        /* delete entry... */
-       rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_query, 0 );
+       rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_stmt, 0 );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_delete(): "
@@ -339,6 +398,7 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
@@ -355,6 +415,7 @@ backsql_delete( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
@@ -367,29 +428,59 @@ backsql_delete( Operation *op, SlapReply *rs )
                SQLFreeStmt( sth, SQL_DROP );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
        SQLFreeStmt( sth, SQL_DROP );
 
+       rs->sr_err = LDAP_SUCCESS;
+
        /*
         * Commit only if all operations succeed
-        *
-        * FIXME: backsql_add() does not fail if add operations 
-        * are not available for some attributes, or if
-        * a multiple value add actually results in a replace, 
-        * or if a single operation on an attribute fails 
-        * for any reason
         */
-       SQLTransact( SQL_NULL_HENV, dbh, 
-                       op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
+       if ( sth != SQL_NULL_HSTMT ) {
+               SQLUSMALLINT    CompletionType = SQL_ROLLBACK;
+       
+               if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+                       CompletionType = SQL_COMMIT;
+               }
 
-       rs->sr_err = LDAP_SUCCESS;
+               SQLTransact( SQL_NULL_HENV, dbh, CompletionType );
+       }
 
 done:;
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       if ( e != NULL ) {
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+               }
+       }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
        send_ldap_result( op, rs );
 
        Debug( LDAP_DEBUG_TRACE, "<==backsql_delete()\n", 0, 0, 0 );
 
-       return ( ( rs->sr_err == LDAP_SUCCESS ) ? op->o_noop : 1 );
+       if ( !BER_BVISNULL( &e_id.eid_ndn ) ) {
+               (void)backsql_free_entryID( op, &e_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &d.e_nname ) ) {
+               entry_clean( &d );
+       }
+
+       if ( !BER_BVISNULL( &p.e_nname ) ) {
+               entry_clean( &p );
+       }
+
+       return rs->sr_err;
 }
 
index 819da825d4571c537c6cd298a0bb9e95e9bd1791..abfe7027122e8e8bb089763bf864fbb386181221 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati and Mark Adamson.
  */
 
 #include "portable.h"
@@ -32,7 +35,7 @@ struct berval backsql_baseObject_bv = BER_BVC( BACKSQL_BASEOBJECT_IDSTR );
 #endif /* BACKSQL_ARBITRARY_KEY */
 
 backsql_entryID *
-backsql_free_entryID( backsql_entryID *id, int freeit )
+backsql_free_entryID( Operation *op, backsql_entryID *id, int freeit )
 {
        backsql_entryID         *next;
 
@@ -44,28 +47,28 @@ backsql_free_entryID( backsql_entryID *id, int freeit )
                if ( !BER_BVISNULL( &id->eid_dn )
                                && id->eid_dn.bv_val != id->eid_ndn.bv_val )
                {
-                       free( id->eid_dn.bv_val );
+                       op->o_tmpfree( id->eid_dn.bv_val, op->o_tmpmemctx );
                        BER_BVZERO( &id->eid_dn );
                }
 
-               free( id->eid_ndn.bv_val );
+               op->o_tmpfree( id->eid_ndn.bv_val, op->o_tmpmemctx );
                BER_BVZERO( &id->eid_ndn );
        }
 
 #ifdef BACKSQL_ARBITRARY_KEY
-       if ( id->eid_id.bv_val ) {
-               free( id->eid_id.bv_val );
+       if ( !BER_BVISNULL( &id->eid_id ) ) {
+               op->o_tmpfree( id->eid_id.bv_val, op->o_tmpmemctx );
                BER_BVZERO( &id->eid_id );
        }
 
-       if ( id->eid_keyval.bv_val ) {
-               free( id->eid_keyval.bv_val );
+       if ( !BER_BVISNULL( &id->eid_keyval ) ) {
+               op->o_tmpfree( id->eid_keyval.bv_val, op->o_tmpmemctx );
                BER_BVZERO( &id->eid_keyval );
        }
 #endif /* BACKSQL_ARBITRARY_KEY */
 
        if ( freeit ) {
-               free( id );
+               op->o_tmpfree( id, op->o_tmpmemctx );
        }
 
        return next;
@@ -78,9 +81,10 @@ int
 backsql_dn2id(
        Operation               *op,
        SlapReply               *rs,
-       backsql_entryID         *id,
        SQLHDBC                 dbh,
        struct berval           *ndn,
+       backsql_entryID         *id,
+       int                     matched,
        int                     muck )
 {
        backsql_info            *bi = op->o_bd->be_private;
@@ -102,31 +106,44 @@ backsql_dn2id(
         * positive cases, or the most appropriate error
         */
 
-       Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): dn=\"%s\"%s\n", 
-                       ndn->bv_val, id == NULL ? " (no ID)" : "", 0 );
+       Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(\"%s\")%s%s\n", 
+                       ndn->bv_val, id == NULL ? " (no ID expected)" : "",
+                       matched ? " matched expected" : "" );
+
+       if ( id ) {
+               /* NOTE: trap inconsistencies */
+               assert( BER_BVISNULL( &id->eid_ndn ) );
+       }
 
        if ( ndn->bv_len > BACKSQL_MAX_DN_LEN ) {
                Debug( LDAP_DEBUG_TRACE, 
-                       "backsql_dn2id(): DN \"%s\" (%ld bytes) "
-                       "exceeds max DN length (%d):\n",
+                       "   backsql_dn2id(\"%s\"): DN length=%ld "
+                       "exceeds max DN length %d:\n",
                        ndn->bv_val, ndn->bv_len, BACKSQL_MAX_DN_LEN );
                return LDAP_OTHER;
        }
 
        /* return baseObject if available and matches */
-       if ( bi->sql_baseObject != NULL && dn_match( ndn, &bi->sql_baseObject->e_nname ) ) {
+       /* FIXME: if ndn is already mucked, we cannot check this */
+       if ( bi->sql_baseObject != NULL &&
+                       dn_match( ndn, &bi->sql_baseObject->e_nname ) )
+       {
                if ( id != NULL ) {
 #ifdef BACKSQL_ARBITRARY_KEY
-                       ber_dupbv( &id->eid_id, &backsql_baseObject_bv );
-                       ber_dupbv( &id->eid_keyval, &backsql_baseObject_bv );
+                       ber_dupbv_x( &id->eid_id, &backsql_baseObject_bv,
+                                       op->o_tmpmemctx );
+                       ber_dupbv_x( &id->eid_keyval, &backsql_baseObject_bv,
+                                       op->o_tmpmemctx );
 #else /* ! BACKSQL_ARBITRARY_KEY */
                        id->eid_id = BACKSQL_BASEOBJECT_ID;
                        id->eid_keyval = BACKSQL_BASEOBJECT_KEYVAL;
 #endif /* ! BACKSQL_ARBITRARY_KEY */
                        id->eid_oc_id = BACKSQL_BASEOBJECT_OC;
 
-                       ber_dupbv( &id->eid_ndn, &bi->sql_baseObject->e_nname );
-                       ber_dupbv( &id->eid_dn, &bi->sql_baseObject->e_name );
+                       ber_dupbv_x( &id->eid_ndn, &bi->sql_baseObject->e_nname,
+                                       op->o_tmpmemctx );
+                       ber_dupbv_x( &id->eid_dn, &bi->sql_baseObject->e_name,
+                                       op->o_tmpmemctx );
 
                        id->eid_next = NULL;
                }
@@ -135,13 +152,15 @@ backsql_dn2id(
        }
        
        /* begin TimesTen */
-       Debug( LDAP_DEBUG_TRACE, "id_query \"%s\"\n", bi->sql_id_query, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "   backsql_dn2id(\"%s\"): id_query \"%s\"\n",
+                       ndn->bv_val, bi->sql_id_query, 0 );
        assert( bi->sql_id_query );
        rc = backsql_Prepare( dbh, &sth, bi->sql_id_query, 0 );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, 
-                       "backsql_dn2id(): error preparing SQL:\n%s", 
-                       bi->sql_id_query, 0, 0);
+                       "   backsql_dn2id(\"%s\"): "
+                       "error preparing SQL:\n   %s", 
+                       ndn->bv_val, bi->sql_id_query, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
                res = LDAP_OTHER;
                goto done;
@@ -164,14 +183,16 @@ backsql_dn2id(
                 * that can be searched using indexes
                 */
 
-               for ( i = 0, j = realndn.bv_len - 1; realndn.bv_val[ i ]; i++, j--) {
+               for ( i = 0, j = realndn.bv_len - 1; realndn.bv_val[ i ]; i++, j--)
+               {
                        upperdn[ i ] = realndn.bv_val[ j ];
                }
                upperdn[ i ] = '\0';
                ldap_pvt_str2upper( upperdn );
 
-               Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): upperdn=\"%s\"\n",
-                               upperdn, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "   backsql_dn2id(\"%s\"): "
+                               "upperdn=\"%s\"\n",
+                               ndn->bv_val, upperdn, 0 );
                ber_str2bv( upperdn, 0, 0, &tbbDN );
 
        } else {
@@ -179,8 +200,9 @@ backsql_dn2id(
                        AC_MEMCPY( upperdn, realndn.bv_val, realndn.bv_len + 1 );
                        ldap_pvt_str2upper( upperdn );
                        Debug( LDAP_DEBUG_TRACE,
-                               "==>backsql_dn2id(): upperdn=\"%s\"\n",
-                               upperdn, 0, 0 );
+                               "   backsql_dn2id(\"%s\"): "
+                               "upperdn=\"%s\"\n",
+                               ndn->bv_val, upperdn, 0 );
                        ber_str2bv( upperdn, 0, 0, &tbbDN );
 
                } else {
@@ -191,9 +213,9 @@ backsql_dn2id(
        rc = backsql_BindParamBerVal( sth, 1, SQL_PARAM_INPUT, &tbbDN );
        if ( rc != SQL_SUCCESS) {
                /* end TimesTen */ 
-               Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): "
+               Debug( LDAP_DEBUG_TRACE, "   backsql_dn2id(\"%s\"): "
                        "error binding dn=\"%s\" parameter:\n", 
-                       tbbDN.bv_val, 0, 0 );
+                       ndn->bv_val, tbbDN.bv_val, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
                res = LDAP_OTHER;
                goto done;
@@ -201,9 +223,9 @@ backsql_dn2id(
 
        rc = SQLExecute( sth );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): "
+               Debug( LDAP_DEBUG_TRACE, "   backsql_dn2id(\"%s\"): "
                        "error executing query (\"%s\", \"%s\"):\n", 
-                       bi->sql_id_query, tbbDN.bv_val, 0 );
+                       ndn->bv_val, bi->sql_id_query, tbbDN.bv_val );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
                res = LDAP_OTHER;
                goto done;
@@ -212,7 +234,7 @@ backsql_dn2id(
        backsql_BindRowAsStrings( sth, &row );
        rc = SQLFetch( sth );
        if ( BACKSQL_SUCCESS( rc ) ) {
-               char    buf[BUFSIZ];
+               char    buf[ SLAP_TEXT_BUFLEN ];
 
 #ifdef LDAP_DEBUG
                snprintf( buf, sizeof(buf),
@@ -220,7 +242,8 @@ backsql_dn2id(
                        row.cols[ 0 ], row.cols[ 1 ],
                        row.cols[ 2 ], row.cols[ 3 ] );
                Debug( LDAP_DEBUG_TRACE,
-                       "<==backsql_dn2id(): %s\n", buf, 0, 0 );
+                       "   backsql_dn2id(\"%s\"): %s\n",
+                       ndn->bv_val, buf, 0 );
 #endif /* LDAP_DEBUG */
 
                res = LDAP_SUCCESS;
@@ -228,8 +251,10 @@ backsql_dn2id(
                        struct berval   dn;
 
 #ifdef BACKSQL_ARBITRARY_KEY
-                       ber_str2bv( row.cols[ 0 ], 0, 1, &id->eid_id );
-                       ber_str2bv( row.cols[ 1 ], 0, 1, &id->eid_keyval );
+                       ber_str2bv_x( row.cols[ 0 ], 0, 1, &id->eid_id,
+                                       op->o_tmpmemctx );
+                       ber_str2bv_x( row.cols[ 1 ], 0, 1, &id->eid_keyval,
+                                       op->o_tmpmemctx );
 #else /* ! BACKSQL_ARBITRARY_KEY */
                        id->eid_id = strtol( row.cols[ 0 ], NULL, 0 );
                        id->eid_keyval = strtol( row.cols[ 1 ], NULL, 0 );
@@ -242,16 +267,18 @@ backsql_dn2id(
                                res = LDAP_OTHER;
 
                        } else {
-                               res = dnPrettyNormal( NULL, &dn, &id->eid_dn, &id->eid_ndn, NULL );
+                               res = dnPrettyNormal( NULL, &dn,
+                                               &id->eid_dn, &id->eid_ndn,
+                                               op->o_tmpmemctx );
                                if ( res != LDAP_SUCCESS ) {
                                        Debug( LDAP_DEBUG_TRACE,
-                                               "<==backsql_dn2id(\"%s\"): "
+                                               "   backsql_dn2id(\"%s\"): "
                                                "dnPrettyNormal failed (%d: %s)\n",
                                                realndn.bv_val, res,
                                                ldap_err2string( res ) );
 
                                        /* cleanup... */
-                                       (void)backsql_free_entryID( id, 0 );
+                                       (void)backsql_free_entryID( op, id, 0 );
                                }
 
                                if ( dn.bv_val != row.cols[ 3 ] ) {
@@ -264,12 +291,47 @@ backsql_dn2id(
 
        } else {
                res = LDAP_NO_SUCH_OBJECT;
-               Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(): no match\n",
-                               0, 0, 0 );
+               if ( matched ) {
+                       struct berval   pdn = *ndn;
+
+                       /*
+                        * Look for matched
+                        */
+                       rs->sr_matched = NULL;
+                       while ( !be_issuffix( op->o_bd, &pdn ) ) {
+                               struct berval   dn;
+                               char            *matchedDN = NULL;
+       
+                               dn = pdn;
+                               dnParent( &dn, &pdn );
+       
+                               /*
+                                * Empty DN ("") defaults to LDAP_SUCCESS
+                                */
+                               rs->sr_err = backsql_dn2id( op, rs, dbh, &pdn, id, 0, 1 );
+                               switch ( rs->sr_err ) {
+                               case LDAP_NO_SUCH_OBJECT:
+                                       /* try another one */
+                                       break;
+                                       
+                               case LDAP_SUCCESS:
+                                       matchedDN = pdn.bv_val;
+                                       /* fail over to next case */
+       
+                               default:
+                                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                                       rs->sr_matched = matchedDN;
+                                       goto done;
+                               } 
+                       }
+               }
        }
        backsql_FreeRow( &row );
 
 done:;
+       Debug( LDAP_DEBUG_TRACE,
+               "<==backsql_dn2id(\"%s\"): err=%d\n",
+               ndn->bv_val, res, 0 );
        if ( sth != SQL_NULL_HSTMT ) {
                SQLFreeStmt( sth, SQL_DROP );
        }
@@ -288,7 +350,7 @@ backsql_count_children(
        struct berval           *dn,
        unsigned long           *nchildren )
 {
-       SQLHSTMT                sth
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        BACKSQL_ROW_NTS         row;
        RETCODE                 rc;
        int                     res = LDAP_SUCCESS;
@@ -391,9 +453,23 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
        backsql_srch_info       *bsi = v_bsi;
        backsql_info            *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
        RETCODE                 rc;
-       SQLHSTMT                sth;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        BACKSQL_ROW_NTS         row;
-       int                     i;
+       unsigned long           i,
+                               k = 0,
+                               oldcount = 0;
+#ifdef BACKSQL_COUNTQUERY
+       unsigned long           count,
+                               countsize = sizeof( count ),
+                               j;
+       Attribute               *attr = NULL;
+
+       slap_mr_normalize_func          *normfunc = NULL;
+#endif /* BACKSQL_COUNTQUERY */
+#ifdef BACKSQL_PRETTY_VALIDATE
+       slap_syntax_validate_func       *validate = NULL;
+       slap_syntax_transform_func      *pretty = NULL;
+#endif /* BACKSQL_PRETTY_VALIDATE */
 
        assert( at );
        assert( bsi );
@@ -410,9 +486,141 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
                bsi->bsi_c_eid->eid_keyval );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
+#ifdef BACKSQL_PRETTY_VALIDATE
+       validate = at->bam_ad->ad_type->sat_syntax->ssyn_validate;
+       pretty =  at->bam_ad->ad_type->sat_syntax->ssyn_pretty;
+
+       if ( validate == NULL && pretty == NULL ) {
+               return 1;
+       }
+#endif /* BACKSQL_PRETTY_VALIDATE */
+
+#ifdef BACKSQL_COUNTQUERY
+       if ( at->bam_ad->ad_type->sat_equality ) {
+               normfunc = at->bam_ad->ad_type->sat_equality->smr_normalize;
+       }
+
+       /* Count how many rows will be returned. This avoids memory 
+        * fragmentation that can result from loading the values in 
+        * one by one and using realloc() 
+        */
+       rc = backsql_Prepare( bsi->bsi_dbh, &sth, at->bam_countquery, 0 );
+       if ( rc != SQL_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
+                       "error preparing count query: %s\n",
+                       at->bam_countquery, 0, 0 );
+               backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
+               return 1;
+       }
+
+       rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT,
+                       &bsi->bsi_c_eid->eid_keyval );
+       if ( rc != SQL_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
+                       "error binding key value parameter\n", 0, 0, 0 );
+               SQLFreeStmt( sth, SQL_DROP );
+               return 1;
+       }
+
+       rc = SQLExecute( sth );
+       if ( ! BACKSQL_SUCCESS( rc ) ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
+                       "error executing attribute count query '%s'\n",
+                       at->bam_countquery, 0, 0 );
+               backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
+               SQLFreeStmt( sth, SQL_DROP );
+               return 1;
+       }
+
+       SQLBindCol( sth, (SQLUSMALLINT)1, SQL_C_LONG,
+                       (SQLPOINTER)&count,
+                       (SQLINTEGER)sizeof( count ),
+                       &countsize );
+
+       rc = SQLFetch( sth );
+       if ( rc != SQL_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
+                       "error fetch results of count query: %s\n",
+                       at->bam_countquery, 0, 0 );
+               backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
+               SQLFreeStmt( sth, SQL_DROP );
+               return 1;
+       }
+
+       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
+               "number of values in query: %d\n", count, 0, 0 );
+       SQLFreeStmt( sth, SQL_DROP );
+       if ( count == 0 ) {
+               return 1;
+       }
+
+       attr = attr_find( bsi->bsi_e->e_attrs, at->bam_ad );
+       if ( attr != NULL ) {
+               BerVarray       tmp;
+
+               if ( attr->a_vals != NULL ) {
+                       for ( ; !BER_BVISNULL( &attr->a_vals[ oldcount ] ); oldcount++ )
+                               /* just count */ ;
+               }
+
+               tmp = ch_realloc( attr->a_vals, ( oldcount + count + 1 ) * sizeof( struct berval ) );
+               if ( tmp == NULL ) {
+                       return 1;
+               }
+               attr->a_vals = tmp;
+               memset( &attr->a_vals[ oldcount ], 0, ( count + 1 ) * sizeof( struct berval ) );
+
+               if ( normfunc ) {
+                       tmp = ch_realloc( attr->a_nvals, ( oldcount + count + 1 ) * sizeof( struct berval ) );
+                       if ( tmp == NULL ) {
+                               return 1;
+                       }
+                       attr->a_nvals = tmp;
+                       memset( &attr->a_nvals[ oldcount ], 0, ( count + 1 ) * sizeof( struct berval ) );
+
+               } else {
+                       attr->a_nvals = attr->a_vals;
+               }
+
+       } else {
+               Attribute       **ap;
+
+               /* Make space for the array of values */
+               attr = (Attribute *) ch_malloc( sizeof( Attribute ) );
+               attr->a_desc = at->bam_ad;
+               attr->a_flags = 0;
+               attr->a_next = NULL;
+               attr->a_vals = ch_calloc( count + 1, sizeof( struct berval ) );
+               if ( attr->a_vals == NULL ) {
+                       Debug( LDAP_DEBUG_TRACE, "Out of memory!\n", 0,0,0 );
+                       ch_free( attr );
+                       return 1;
+               }
+               memset( attr->a_vals, 0, ( count + 1 ) * sizeof( struct berval ) );
+               if ( normfunc ) {
+                       attr->a_nvals = ch_calloc( count + 1, sizeof( struct berval ) );
+                       if ( attr->a_nvals == NULL ) {
+                               ch_free( attr->a_vals );
+                               ch_free( attr );
+                               return 1;
+
+                       } else {
+                               memset( attr->a_nvals, 0, ( count + 1 ) * sizeof( struct berval ) );
+                       }
+
+               } else {
+                       attr->a_nvals = attr->a_vals;
+               }
+
+               for ( ap = &bsi->bsi_e->e_attrs; (*ap) != NULL; ap = &(*ap)->a_next )
+                       /* goto last */ ;
+               *ap =  attr;
+       }
+#endif /* BACKSQL_COUNTQUERY */
+
        rc = backsql_Prepare( bsi->bsi_dbh, &sth, at->bam_query, 0 );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
                        "error preparing query: %s\n", at->bam_query, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
                return 1;
@@ -421,18 +629,18 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
        rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT,
                        &bsi->bsi_c_eid->eid_keyval );
        if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
                        "error binding key value parameter\n", 0, 0, 0 );
                return 1;
        }
 
 #ifdef BACKSQL_TRACE
 #ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
+       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
                "query=\"%s\" keyval=%s\n", at->bam_query,
                bsi->bsi_c_eid->eid_keyval.bv_val, 0 );
 #else /* !BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
+       Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
                "query=\"%s\" keyval=%d\n", at->bam_query,
                bsi->bsi_c_eid->eid_keyval, 0 );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
@@ -440,7 +648,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
 
        rc = SQLExecute( sth );
        if ( ! BACKSQL_SUCCESS( rc ) ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
+               Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
                        "error executing attribute query \"%s\"\n",
                        at->bam_query, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
@@ -449,30 +657,146 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
        }
 
        backsql_BindRowAsStrings( sth, &row );
-
-       rc = SQLFetch( sth );
-       for ( ; BACKSQL_SUCCESS( rc ); rc = SQLFetch( sth ) ) {
+#ifdef BACKSQL_COUNTQUERY
+       j = oldcount;
+#endif /* BACKSQL_COUNTQUERY */
+       for ( rc = SQLFetch( sth ), k = 0;
+                       BACKSQL_SUCCESS( rc );
+                       rc = SQLFetch( sth ), k++ )
+       {
                for ( i = 0; i < row.ncols; i++ ) {
+
                        if ( row.value_len[ i ] > 0 ) {
-                               struct berval   bv;
+                               struct berval           bv;
+                               int                     retval;
+#ifdef BACKSQL_TRACE
+                               AttributeDescription    *ad = NULL;
+                               const char              *text;
+
+                               retval = slap_bv2ad( &row.col_names[ i ], &ad, &text );
+                               if ( retval != LDAP_SUCCESS ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "==>backsql_get_attr_vals(\"%s\"): "
+                                               "unable to find AttributeDescription %s "
+                                               "in schema (%d)\n",
+                                               bsi->bsi_e->e_name.bv_val,
+                                               row.col_names[ i ].bv_val, retval );
+                                       return 1;
+                               }
+
+                               if ( ad != at->bam_ad ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "==>backsql_get_attr_vals(\"%s\"): "
+                                               "column name %s differs from "
+                                               "AttributeDescription %s\n",
+                                               bsi->bsi_e->e_name.bv_val,
+                                               ad->ad_cname.bv_val,
+                                               at->bam_ad->ad_cname.bv_val );
+                                       return 1;
+                               }
+#endif /* BACKSQL_TRACE */
 
-                               bv.bv_val = row.cols[ i ];
-#if 0
-                               bv.bv_len = row.col_prec[ i ];
-#else
                                /*
                                 * FIXME: what if a binary 
                                 * is fetched?
                                 */
-                               bv.bv_len = strlen( row.cols[ i ] );
-#endif
-                                       backsql_entry_addattr( bsi->bsi_e, 
-                                               &row.col_names[ i ], &bv,
+                               ber_str2bv( row.cols[ i ], 0, 0, &bv );
+
+#ifdef BACKSQL_PRETTY_VALIDATE
+                               if ( pretty ) {
+                                       struct berval   pbv;
+
+                                       retval = pretty( at->bam_ad->ad_type->sat_syntax,
+                                               &bv, &pbv, bsi->bsi_op->o_tmpmemctx );
+                                       bv = pbv;
+
+                               } else {
+                                       retval = validate( at->bam_ad->ad_type->sat_syntax,
+                                               &bv );
+                               }
+
+                               if ( retval != LDAP_SUCCESS ) {
+                                       char    buf[ SLAP_TEXT_BUFLEN ];
+
+                                       /* FIXME: we're ignoring invalid values,
+                                        * but we're accepting the attributes;
+                                        * should we fail at all? */
+                                       snprintf( buf, sizeof( buf ),
+                                                       "unable to %s value #%d "
+                                                       "of AttributeDescription %s",
+                                                       pretty ? "prettify" : "validate",
+                                                       at->bam_ad->ad_cname.bv_val,
+                                                       k - oldcount );
+                                       Debug( LDAP_DEBUG_TRACE,
+                                               "==>backsql_get_attr_vals(\"%s\"): "
+                                               "%s (%d)\n",
+                                               bsi->bsi_e->e_name.bv_val, buf, retval );
+                                       continue;
+                               }
+#endif /* BACKSQL_PRETTY_VALIDATE */
+
+#ifndef BACKSQL_COUNTQUERY
+                               (void)backsql_entry_addattr( bsi->bsi_e, 
+                                               at->bam_ad, &bv,
                                                bsi->bsi_op->o_tmpmemctx );
 
+#else /* BACKSQL_COUNTQUERY */
+                               if ( normfunc ) {
+                                       struct berval   nbv;
+
+                                       retval = (*normfunc)( SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                               at->bam_ad->ad_type->sat_syntax,
+                                               at->bam_ad->ad_type->sat_equality,
+                                               &bv, &nbv,
+                                               bsi->bsi_op->o_tmpmemctx );
+
+                                       if ( retval != LDAP_SUCCESS ) {
+                                               char    buf[ SLAP_TEXT_BUFLEN ];
+
+                                               /* FIXME: we're ignoring invalid values,
+                                                * but we're accepting the attributes;
+                                                * should we fail at all? */
+                                               snprintf( buf, sizeof( buf ),
+                                                       "unable to normalize value #%d "
+                                                       "of AttributeDescription %s",
+                                                       at->bam_ad->ad_cname.bv_val,
+                                                       k - oldcount );
+                                               Debug( LDAP_DEBUG_TRACE,
+                                                       "==>backsql_get_attr_vals(\"%s\"): "
+                                                       "%s (%d)\n",
+                                                       bsi->bsi_e->e_name.bv_val, buf, retval );
+
+#ifdef BACKSQL_PRETTY_VALIDATE
+                                               if ( pretty ) {
+                                                       bsi->bsi_op->o_tmpfree( bv.bv_val,
+                                                                       bsi->bsi_op->o_tmpmemctx );
+                                               }
+#endif /* BACKSQL_PRETTY_VALIDATE */
+
+                                               continue;
+                                       }
+                                       ber_dupbv( &attr->a_nvals[ j ], &nbv );
+                                       bsi->bsi_op->o_tmpfree( nbv.bv_val,
+                                                       bsi->bsi_op->o_tmpmemctx );
+                               }
+
+                               ber_dupbv( &attr->a_vals[ j ], &bv );
+
+                               assert( j < oldcount + count );
+                               j++;
+#endif /* BACKSQL_COUNTQUERY */
+
+#ifdef BACKSQL_PRETTY_VALIDATE
+                               if ( pretty ) {
+                                       bsi->bsi_op->o_tmpfree( bv.bv_val,
+                                                       bsi->bsi_op->o_tmpmemctx );
+                               }
+#endif /* BACKSQL_PRETTY_VALIDATE */
+
 #ifdef BACKSQL_TRACE
                                Debug( LDAP_DEBUG_TRACE, "prec=%d\n",
                                        (int)row.col_prec[ i ], 0, 0 );
+
                        } else {
                                Debug( LDAP_DEBUG_TRACE, "NULL value "
                                        "in this row for attribute \"%s\"\n",
@@ -496,10 +820,10 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
 int
 backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
 {
-       backsql_info            *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
+       Operation               *op = bsi->bsi_op;
+       backsql_info            *bi = (backsql_info *)op->o_bd->be_private;
        int                     i;
        int                     rc;
-       AttributeDescription    *ad_oc = slap_schema.si_ad_objectClass;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 );
 
@@ -520,8 +844,8 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
                goto done;
        }
 
-       ber_dupbv_x( &bsi->bsi_e->e_name, &eid->eid_dn, bsi->bsi_op->o_tmpmemctx );
-       ber_dupbv_x( &bsi->bsi_e->e_nname, &eid->eid_ndn, bsi->bsi_op->o_tmpmemctx );
+       ber_dupbv_x( &bsi->bsi_e->e_name, &eid->eid_dn, op->o_tmpmemctx );
+       ber_dupbv_x( &bsi->bsi_e->e_nname, &eid->eid_ndn, op->o_tmpmemctx );
 
        bsi->bsi_e->e_attrs = NULL;
        bsi->bsi_e->e_private = NULL;
@@ -531,12 +855,14 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
        bsi->bsi_c_eid = eid;
 
 #ifndef BACKSQL_ARBITRARY_KEY  
+       /* FIXME: unused */
        bsi->bsi_e->e_id = eid->eid_id;
 #endif /* ! BACKSQL_ARBITRARY_KEY */
  
-       rc = attr_merge_normalize_one( bsi->bsi_e, ad_oc,
-                               &bsi->bsi_oc->bom_oc->soc_cname,
-                               bsi->bsi_op->o_tmpmemctx );
+       rc = attr_merge_normalize_one( bsi->bsi_e,
+                       slap_schema.si_ad_objectClass,
+                       &bsi->bsi_oc->bom_oc->soc_cname,
+                       bsi->bsi_op->o_tmpmemctx );
        if ( rc != LDAP_SUCCESS ) {
                entry_clean( bsi->bsi_e );
                return rc;
@@ -552,7 +878,7 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
        } else {
                Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
                        "custom attribute list\n", 0, 0, 0 );
-               for ( i = 0; bsi->bsi_attrs[ i ].an_name.bv_val; i++ ) {
+               for ( i = 0; !BER_BVISNULL( &bsi->bsi_attrs[ i ].an_name ); i++ ) {
                        backsql_at_map_rec      **vat;
                        AttributeName           *an = &bsi->bsi_attrs[ i ];
                        int                     j;
@@ -562,7 +888,7 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
                         * because subtypes are already dealt with
                         * by backsql_supad2at()
                         */
-                       for ( j = 0; bsi->bsi_attrs[ j ].an_name.bv_val; j++ ) {
+                       for ( j = 0; !BER_BVISNULL( &bsi->bsi_attrs[ j ].an_name ); j++ ) {
                                /* skip self */
                                if ( j == i ) {
                                        continue;
@@ -619,7 +945,7 @@ next:;
                int rc;
 
                bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname;
-               bv[ 1 ].bv_val = NULL;
+               BER_BVZERO( &bv[ 1 ] );
 
                rc = structural_class( bv, &soc, NULL, 
                                &text, textbuf, textlen );
index 501dedaee65c57cd2a52fce62f78552bf93c104c..678d106d411753a4d9bcb677e747bad58a7629f0 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -32,11 +34,14 @@ sql_back_initialize(
        BackendInfo     *bi )
 { 
        static char *controls[] = {
+               LDAP_CONTROL_ASSERT,
+               LDAP_CONTROL_MANAGEDSAIT,
 #if 0 /* needs improvements */
-#ifdef LDAP_CONTROL_NOOP
                LDAP_CONTROL_NOOP,
-#endif /* LDAP_CONTROL_NOOP */
 #endif
+#ifdef LDAP_CONTROL_X_TREE_DELETE
+               LDAP_CONTROL_X_TREE_DELETE,
+#endif /* LDAP_CONTROL_X_TREE_DELETE */
 #ifdef LDAP_CONTROL_VALUESRETURNFILTER
                LDAP_CONTROL_VALUESRETURNFILTER,
 #endif /* LDAP_CONTROL_VALUESRETURNFILTER */
@@ -45,6 +50,12 @@ sql_back_initialize(
 
        bi->bi_controls = controls;
 
+       bi->bi_flags |=
+#if 0
+               SLAP_BFLAG_INCREMENT |
+#endif
+               SLAP_BFLAG_REFERRALS;
+
        Debug( LDAP_DEBUG_TRACE,"==>sql_back_initialize()\n", 0, 0, 0 );
        
        bi->bi_db_init = backsql_db_init;
@@ -133,10 +144,20 @@ backsql_db_destroy(
        free( bi->sql_subtree_cond.bv_val );
        free( bi->sql_oc_query );
        free( bi->sql_at_query );
-       free( bi->sql_insentry_query );
-       free( bi->sql_delentry_query );
-       free( bi->sql_delobjclasses_query );
-       free( bi->sql_delreferrals_query );
+       free( bi->sql_insentry_stmt );
+       free( bi->sql_delentry_stmt );
+       free( bi->sql_renentry_stmt );
+       free( bi->sql_delobjclasses_stmt );
+
+       if ( bi->sql_anlist ) {
+               int     i;
+
+               for ( i = 0; !BER_BVISNULL( &bi->sql_anlist[i].an_name ); i++ )
+               {
+                       ch_free( bi->sql_anlist[i].an_name.bv_val );
+               }
+               ch_free( bi->sql_anlist );
+       }
 
        if ( bi->sql_baseObject ) {
                entry_free( bi->sql_baseObject );
@@ -153,8 +174,7 @@ backsql_db_open(
        BackendDB       *bd )
 {
        backsql_info    *bi = (backsql_info*)bd->be_private;
-       SQLHDBC         dbh;
-       ber_len_t       idq_len;
+       SQLHDBC         dbh = SQL_NULL_HDBC;
        struct berbuf   bb = BB_NULL;
 
        char            opbuf[ OPERATION_BUFFER_SIZE ];
@@ -342,48 +362,48 @@ backsql_db_open(
                bi->sql_at_query = ch_strdup( backsql_def_at_query );
        }
        
-       if ( bi->sql_insentry_query == NULL ) {
+       if ( bi->sql_insentry_stmt == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "entry insertion SQL statement not specified "
-                       "(use \"insentry_query\" directive in slapd.conf)\n",
+                       "(use \"insentry_stmt\" directive in slapd.conf)\n",
                        0, 0, 0 );
                Debug(LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "setting \"%s\" by default\n",
-                       backsql_def_insentry_query, 0, 0 );
-               bi->sql_insentry_query = ch_strdup( backsql_def_insentry_query );
+                       backsql_def_insentry_stmt, 0, 0 );
+               bi->sql_insentry_stmt = ch_strdup( backsql_def_insentry_stmt );
        }
        
-       if ( bi->sql_delentry_query == NULL ) {
+       if ( bi->sql_delentry_stmt == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "entry deletion SQL statement not specified "
-                       "(use \"delentry_query\" directive in slapd.conf)\n",
+                       "(use \"delentry_stmt\" directive in slapd.conf)\n",
                        0, 0, 0 );
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "setting \"%s\" by default\n",
-                       backsql_def_delentry_query, 0, 0 );
-               bi->sql_delentry_query = ch_strdup( backsql_def_delentry_query );
+                       backsql_def_delentry_stmt, 0, 0 );
+               bi->sql_delentry_stmt = ch_strdup( backsql_def_delentry_stmt );
        }
 
-       if ( bi->sql_delobjclasses_query == NULL ) {
+       if ( bi->sql_renentry_stmt == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
-                       "objclasses deletion SQL statement not specified "
-                       "(use \"delobjclasses_query\" directive in slapd.conf)\n",
+                       "entry deletion SQL statement not specified "
+                       "(use \"renentry_stmt\" directive in slapd.conf)\n",
                        0, 0, 0 );
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "setting \"%s\" by default\n",
-                       backsql_def_delobjclasses_query, 0, 0 );
-               bi->sql_delobjclasses_query = ch_strdup( backsql_def_delobjclasses_query );
+                       backsql_def_renentry_stmt, 0, 0 );
+               bi->sql_renentry_stmt = ch_strdup( backsql_def_renentry_stmt );
        }
 
-       if ( bi->sql_delreferrals_query == NULL ) {
+       if ( bi->sql_delobjclasses_stmt == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
-                       "referrals deletion SQL statement not specified "
-                       "(use \"delreferrals_query\" directive in slapd.conf)\n",
+                       "objclasses deletion SQL statement not specified "
+                       "(use \"delobjclasses_stmt\" directive in slapd.conf)\n",
                        0, 0, 0 );
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "setting \"%s\" by default\n",
-                       backsql_def_delreferrals_query, 0, 0 );
-               bi->sql_delreferrals_query = ch_strdup( backsql_def_delreferrals_query );
+                       backsql_def_delobjclasses_stmt, 0, 0 );
+               bi->sql_delobjclasses_stmt = ch_strdup( backsql_def_delobjclasses_stmt );
        }
 
        op->o_hdr = (Opheader *)&op[ 1 ];
@@ -398,34 +418,34 @@ backsql_db_open(
        /*
         * Prepare ID selection query
         */
-       bi->sql_id_query = NULL;
-       idq_len = 0;
-
-       if ( bi->sql_upper_func.bv_val == NULL ) {
-               backsql_strcat( &bb, backsql_id_query, "dn=?", NULL );
+       if ( bi->sql_id_query == NULL ) {
+               /* no custom id_query provided */
+               if ( bi->sql_upper_func.bv_val == NULL ) {
+                       backsql_strcat( &bb, backsql_id_query, "dn=?", NULL );
 
-       } else {
-               if ( BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ) {
-                       backsql_strcat( &bb, backsql_id_query,
-                                       "dn_ru=?", NULL );
                } else {
-                       if ( BACKSQL_USE_REVERSE_DN( bi ) ) {
-                               backsql_strfcat( &bb, "sbl",
-                                               backsql_id_query,
-                                               &bi->sql_upper_func, 
-                                               (ber_len_t)STRLENOF( "(dn)=?" ), "(dn)=?" );
+                       if ( BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ) {
+                               backsql_strcat( &bb, backsql_id_query,
+                                               "dn_ru=?", NULL );
                        } else {
-                               backsql_strfcat( &bb, "sblbcb",
-                                               backsql_id_query,
-                                               &bi->sql_upper_func, 
-                                               (ber_len_t)STRLENOF( "(dn)=" ), "(dn)=",
-                                               &bi->sql_upper_func_open, 
-                                               '?', 
-                                               &bi->sql_upper_func_close );
+                               if ( BACKSQL_USE_REVERSE_DN( bi ) ) {
+                                       backsql_strfcat( &bb, "sbl",
+                                                       backsql_id_query,
+                                                       &bi->sql_upper_func, 
+                                                       (ber_len_t)STRLENOF( "(dn)=?" ), "(dn)=?" );
+                               } else {
+                                       backsql_strfcat( &bb, "sblbcb",
+                                                       backsql_id_query,
+                                                       &bi->sql_upper_func, 
+                                                       (ber_len_t)STRLENOF( "(dn)=" ), "(dn)=",
+                                                       &bi->sql_upper_func_open, 
+                                                       '?', 
+                                                       &bi->sql_upper_func_close );
+                               }
                        }
                }
+               bi->sql_id_query = bb.bb_val.bv_val;
        }
-       bi->sql_id_query = bb.bb_val.bv_val;
 
                /*
         * Prepare children ID selection query
@@ -448,6 +468,14 @@ backsql_db_open(
                        0, 0, 0 );
                return 1;
        }
+
+       /* should never happen! */
+       assert( bd->be_nsuffix != NULL );
+       
+       if ( BER_BVISNULL( &bd->be_nsuffix[ 1 ] ) ) {
+               /* enable if only one suffix is defined */
+               bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT;
+       }
        
        Debug( LDAP_DEBUG_TRACE, "<==backsql_db_open(): "
                "test succeeded, schema map loaded\n", 0, 0, 0 );
index e1434cdf65426823252112faba5208437dc59105..8f5be4fc39039b382320b21d9a09bdd3d9cd6f0b 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -31,10 +33,12 @@ int
 backsql_modify( Operation *op, SlapReply *rs )
 {
        backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
-       SQLHDBC                 dbh;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
        backsql_oc_map_rec      *oc = NULL;
-       backsql_entryID         e_id = BACKSQL_ENTRYID_INIT;
-       Entry                   e;
+       backsql_srch_info       bsi = { 0 };
+       Entry                   m = { 0 }, *e = NULL;
+       int                     manageDSAit = get_manageDSAit( op );
+       SQLUSMALLINT            CompletionType = SQL_ROLLBACK;
 
        /*
         * FIXME: in case part of the operation cannot be performed
@@ -58,26 +62,68 @@ backsql_modify( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       rs->sr_err = backsql_dn2id( op, rs, &e_id, dbh, &op->o_req_ndn, 1 );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
-                       "could not lookup entry id\n", 0, 0, 0 );
-               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
-                       ? "SQL-backend error" : NULL;
+       bsi.bsi_e = &m;
+       rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs,
+                       slap_anlist_all_attributes,
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+       switch ( rs->sr_err ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               e = &m;
+               /* fallthru */
+
+       default:
+               Debug( LDAP_DEBUG_TRACE, "backsql_modify(): "
+                       "could not retrieve modifyDN ID - no such entry\n", 
+                       0, 0, 0 );
+               if ( !BER_BVISNULL( &m.e_nname ) ) {
+                       /* FIXME: should always be true! */
+                       e = &m;
+
+               } else {
+                       e = NULL;
+               }
                goto done;
        }
 
 #ifdef BACKSQL_ARBITRARY_KEY
        Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
                "modifying entry \"%s\" (id=%s)\n", 
-               e_id.eid_dn.bv_val, e_id.eid_id.bv_val, 0 );
+               bsi.bsi_base_id.eid_dn.bv_val,
+               bsi.bsi_base_id.eid_id.bv_val, 0 );
 #else /* ! BACKSQL_ARBITRARY_KEY */
        Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
                "modifying entry \"%s\" (id=%ld)\n", 
-               e_id.eid_dn.bv_val, e_id.eid_id, 0 );
+               bsi.bsi_base_id.eid_dn.bv_val, bsi.bsi_base_id.eid_id, 0 );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
-       oc = backsql_id2oc( bi, e_id.eid_oc_id );
+       if ( get_assert( op ) &&
+                       ( test_filter( op, &m, get_assertion( op ) )
+                         != LDAP_COMPARE_TRUE ))
+       {
+               rs->sr_err = LDAP_ASSERTION_FAILED;
+               e = &m;
+               goto done;
+       }
+
+       oc = backsql_id2oc( bi, bsi.bsi_base_id.eid_oc_id );
        if ( oc == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modify(): "
                        "cannot determine objectclass of entry -- aborting\n",
@@ -92,32 +138,90 @@ backsql_modify( Operation *op, SlapReply *rs )
                 */
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
+               e = NULL;
                goto done;
        }
 
-       e.e_attrs = NULL;
-       e.e_name = op->o_req_dn;
-       e.e_nname = op->o_req_ndn;
-       if ( !acl_check_modlist( op, &e, op->oq_modify.rs_modlist ) ) {
+       if ( !acl_check_modlist( op, &m, op->oq_modify.rs_modlist ) ) {
                rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               e = &m;
+               goto done;
+       }
 
-       } else {
-               rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id,
-                               op->oq_modify.rs_modlist );
+       rs->sr_err = backsql_modify_internal( op, rs, dbh, oc,
+                       &bsi.bsi_base_id, op->oq_modify.rs_modlist );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               e = &m;
+               goto do_transact;
        }
 
-       if ( rs->sr_err == LDAP_SUCCESS ) {
-               /*
-                * Commit only if all operations succeed
-                */
-               SQLTransact( SQL_NULL_HENV, dbh, 
-                               op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
+       if ( global_schemacheck ) {
+               char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
+
+               entry_clean( &m );
+
+               bsi.bsi_e = &m;
+               rs->sr_err = backsql_id2entry( &bsi, &bsi.bsi_base_id );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       e = &m;
+                       goto do_transact;
+               }
+
+               rs->sr_err = entry_schema_check( op->o_bd, &m,
+                               NULL,
+                               &rs->sr_text, textbuf, sizeof( textbuf ) );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                               "entry failed schema check -- aborting\n",
+                               m.e_name.bv_val, 0, 0 );
+                       e = NULL;
+                       goto do_transact;
+               }
        }
 
+do_transact:;
+       /*
+        * Commit only if all operations succeed
+        */
+       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+               CompletionType = SQL_COMMIT;
+       }
+
+       SQLTransact( SQL_NULL_HENV, dbh, CompletionType );
+
 done:;
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       if ( e != NULL ) {
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+               }
+       }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
        send_ldap_result( op, rs );
+
+       if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &m.e_nname ) ) {
+               entry_clean( &m );
+       }
+
+       if ( bsi.bsi_attrs != NULL ) {
+               op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
+       }
+
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modify()\n", 0, 0, 0 );
 
-       return rs->sr_err != LDAP_SUCCESS ? rs->sr_err : op->o_noop;
+       return rs->sr_err;
 }
 
index 4a9703c7ce4371dc9f64bcc51906a62c69d6ba16..a1578e565d8749d6c399feea9a62c11211a6f858 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -31,20 +33,24 @@ int
 backsql_modrdn( Operation *op, SlapReply *rs )
 {
        backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
-       SQLHDBC                 dbh;
-       SQLHSTMT                sth;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        RETCODE                 rc;
        backsql_entryID         e_id = BACKSQL_ENTRYID_INIT,
-                               pe_id = BACKSQL_ENTRYID_INIT,
-                               new_pe_id = BACKSQL_ENTRYID_INIT;
+                               n_id = BACKSQL_ENTRYID_INIT;
+       backsql_srch_info       bsi = { 0 };
        backsql_oc_map_rec      *oc = NULL;
-       struct berval           p_dn = BER_BVNULL, p_ndn = BER_BVNULL,
+       struct berval           pdn = BER_BVNULL, pndn = BER_BVNULL,
                                *new_pdn = NULL, *new_npdn = NULL,
                                new_dn = BER_BVNULL, new_ndn = BER_BVNULL,
                                realnew_dn = BER_BVNULL;
        LDAPRDN                 new_rdn = NULL;
        LDAPRDN                 old_rdn = NULL;
-       Entry                   e;
+       Entry                   r = { 0 },
+                               p = { 0 },
+                               n = { 0 },
+                               *e = NULL;
+       int                     manageDSAit = get_manageDSAit( op );
        Modifications           *mod = NULL;
        struct berval           *newSuperior = op->oq_modrdn.rs_newSup;
        char                    *next;
@@ -53,6 +59,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        "newrdn=\"%s\", newSuperior=\"%s\"\n",
                        op->o_req_dn.bv_val, op->oq_modrdn.rs_newrdn.bv_val, 
                        newSuperior ? newSuperior->bv_val : "(NULL)" );
+
        rs->sr_err = backsql_get_db_conn( op, &dbh );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
@@ -60,19 +67,49 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        0, 0, 0 );
                rs->sr_text = ( rs->sr_err == LDAP_OTHER )
                        ?  "SQL-backend error" : NULL;
-               send_ldap_result( op, rs );
-               return 1;
+               e = NULL;
+               goto done;
        }
 
-       rs->sr_err = backsql_dn2id( op, rs, &e_id, dbh, &op->o_req_ndn, 1 );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "could not lookup entry id (%d)\n",
-                       rs->sr_err, 0, 0 );
-               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
-                       ?  "SQL-backend error" : NULL;
-               send_ldap_result( op, rs );
-               return 1;
+       bsi.bsi_e = &r;
+       rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs,
+                       slap_anlist_all_attributes,
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+       switch ( rs->sr_err ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               e = &r;
+               /* fallthru */
+
+       default:
+               Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
+                       "could not retrieve modrdnDN ID - no such entry\n", 
+                       0, 0, 0 );
+               if ( !BER_BVISNULL( &r.e_nname ) ) {
+                       /* FIXME: should always be true! */
+                       e = &r;
+
+               } else {
+                       e = NULL;
+               }
+               goto done;
        }
 
 #ifdef BACKSQL_ARBITRARY_KEY
@@ -83,81 +120,152 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                e_id.eid_id, 0, 0 );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
+       if ( get_assert( op ) &&
+                       ( test_filter( op, &r, get_assertion( op ) )
+                         != LDAP_COMPARE_TRUE ) )
+       {
+               rs->sr_err = LDAP_ASSERTION_FAILED;
+               e = &r;
+               goto done;
+       }
+
        if ( backsql_has_children( bi, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                        "entry \"%s\" has children\n",
                        op->o_req_dn.bv_val, 0, 0 );
                rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
                rs->sr_text = "subtree rename not supported";
-               send_ldap_result( op, rs );
-               return 1;
+               e = &r;
+               goto done;
        }
 
-       dnParent( &op->o_req_dn, &p_dn );
-       dnParent( &op->o_req_ndn, &p_ndn );
+       /*
+        * Check for entry access to target
+        */
+       if ( !access_allowed( op, &r, slap_schema.si_ad_entry, 
+                               NULL, ACL_WRITE, NULL ) ) {
+               Debug( LDAP_DEBUG_TRACE, "   no access to entry\n", 0, 0, 0 );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               goto done;
+       }
+
+       dnParent( &op->o_req_dn, &pdn );
+       dnParent( &op->o_req_ndn, &pndn );
 
        /*
         * namingContext "" is not supported
         */
-       if ( p_dn.bv_len == 0 ) {
+       if ( BER_BVISEMPTY( &pdn ) ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                        "parent is \"\" - aborting\n", 0, 0, 0 );
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                rs->sr_text = "not allowed within namingContext";
-               send_ldap_result( op, rs );
-               goto modrdn_return;
+               e = NULL;
+               goto done;
        }
 
        /*
         * Check for children access to parent
         */
-       e.e_attrs = NULL;
-       e.e_name = p_dn;
-       e.e_nname = p_ndn;
-       if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
+       bsi.bsi_e = &p;
+       e_id = bsi.bsi_base_id;
+       rs->sr_err = backsql_init_search( &bsi, &pndn,
+                       LDAP_SCOPE_BASE, 
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL, dbh, op, rs,
+                       slap_anlist_all_attributes,
+                       BACKSQL_ISF_GET_ENTRY );
+
+#ifdef BACKSQL_ARBITRARY_KEY
+       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
+               "old parent entry id is %s\n",
+               bsi.bsi_base_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
+               "old parent entry id is %ld\n",
+               bsi.bsi_base_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
+                       "could not retrieve renameDN ID - no such entry\n", 
+                       0, 0, 0 );
+               e = &p;
+               goto done;
+       }
+
+       if ( !access_allowed( op, &p, slap_schema.si_ad_children, 
                                NULL, ACL_WRITE, NULL ) ) {
                Debug( LDAP_DEBUG_TRACE, "   no access to parent\n", 0, 0, 0 );
                rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-               goto modrdn_return;
+               goto done;
        }
 
        if ( newSuperior ) {
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+               
                /*
                 * namingContext "" is not supported
                 */
-               if ( newSuperior->bv_len == 0 ) {
+               if ( BER_BVISEMPTY( newSuperior ) ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                                "newSuperior is \"\" - aborting\n", 0, 0, 0 );
                        rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                        rs->sr_text = "not allowed within namingContext";
-                       send_ldap_result( op, rs );
-                       goto modrdn_return;
+                       e = NULL;
+                       goto done;
                }
 
                new_pdn = newSuperior;
                new_npdn = op->oq_modrdn.rs_nnewSup;
 
-               e.e_name = *new_pdn;
-               e.e_nname = *new_npdn;
-
                /*
                 * Check for children access to new parent
                 */
-               if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
+               bsi.bsi_e = &n;
+               rs->sr_err = backsql_init_search( &bsi, new_npdn,
+                               LDAP_SCOPE_BASE, 
+                               SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                               (time_t)(-1), NULL, dbh, op, rs,
+                               slap_anlist_all_attributes,
+                               ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
+                               "could not retrieve renameDN ID - no such entry\n", 
+                               0, 0, 0 );
+                       e = &n;
+                       goto done;
+               }
+
+               n_id = bsi.bsi_base_id;
+
+#ifdef BACKSQL_ARBITRARY_KEY
+               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
+                       "new parent entry id=%s\n",
+                       n_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
+                       "new parent entry id=%ld\n",
+                       n_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
+               if ( !access_allowed( op, &n, slap_schema.si_ad_children, 
                                        NULL, ACL_WRITE, NULL ) ) {
                        Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                                        "no access to new parent \"%s\"\n", 
                                        new_pdn->bv_val, 0, 0 );
                        rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-                       goto modrdn_return;
+                       e = &n;
+                       goto done;
                }
 
        } else {
-               new_pdn = &p_dn;
-               new_npdn = &p_ndn;
+               n_id = bsi.bsi_base_id;
+               new_pdn = &pdn;
+               new_npdn = &pndn;
        }
 
-       if ( newSuperior && dn_match( &p_ndn, new_npdn ) ) {
+       if ( newSuperior && dn_match( &pndn, new_npdn ) ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                        "newSuperior is equal to old parent - ignored\n",
                        0, 0, 0 );
@@ -170,137 +278,45 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        "- aborting\n", 0, 0, 0 );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "newSuperior is equal to old DN";
-               send_ldap_result( op, rs );
-               goto modrdn_return;
+               e = &r;
+               goto done;
        }
 
        build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn,
                        op->o_tmpmemctx );
-       rs->sr_err = dnNormalize( 0, NULL, NULL, &new_dn, &new_ndn,
+       build_new_dn( &new_ndn, new_npdn, &op->oq_modrdn.rs_nnewrdn,
                        op->o_tmpmemctx );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "new dn is invalid (\"%s\") - aborting\n",
-                       new_dn.bv_val, 0, 0 );
-               rs->sr_text = "unable to build new DN";
-               send_ldap_result( op, rs );
-               goto modrdn_return;
-       }
        
        Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): new entry dn is \"%s\"\n",
                        new_dn.bv_val, 0, 0 );
 
-       rs->sr_err = backsql_dn2id( op, rs, &pe_id, dbh, &p_ndn, 1 );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "could not lookup old parent entry id\n", 0, 0, 0 );
-               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
-                       ? "SQL-backend error" : NULL;
-               send_ldap_result( op, rs );
-               goto modrdn_return;
-       }
-
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "old parent entry id is %s\n", pe_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "old parent entry id is %ld\n", pe_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
-
-       (void)backsql_free_entryID( &pe_id, 0 );
-
-       rs->sr_err = backsql_dn2id( op, rs, &new_pe_id, dbh, new_npdn, 1 );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "could not lookup new parent entry id\n", 0, 0, 0 );
-               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
-                       ? "SQL-backend error" : NULL;
-               send_ldap_result( op, rs );
-               goto modrdn_return;
-       }
-
-#ifdef BACKSQL_ARBITRARY_KEY
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "new parent entry id=%s\n", new_pe_id.eid_id.bv_val, 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
-       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "new parent entry id=%ld\n", new_pe_id.eid_id, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
-
-       Debug(  LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "executing delentry_query\n", 0, 0, 0 );
-
-       rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_query, 0 );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_modrdn(): "
-                       "error preparing delentry_query\n", 0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, 
-                               sth, rc );
-
-               rs->sr_text = "SQL-backend error";
-               rs->sr_err = LDAP_OTHER;
-               goto done;
-       }
-
-       rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT, &e_id.eid_id );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_delete(): "
-                       "error binding entry ID parameter "
-                       "for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, 
-                       sth, rc );
+       realnew_dn = new_dn;
+       if ( backsql_api_dn2odbc( op, rs, &realnew_dn ) ) {
+               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(\"%s\"): "
+                       "backsql_api_dn2odbc(\"%s\") failed\n", 
+                       op->o_req_dn.bv_val, realnew_dn.bv_val, 0 );
                SQLFreeStmt( sth, SQL_DROP );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
-       rc = SQLExecute( sth );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "failed to delete record from ldap_entries\n",
-                       0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-               SQLFreeStmt( sth, SQL_DROP );
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
-               send_ldap_result( op, rs );
-               goto done;
-       }
-
-       SQLFreeStmt( sth, SQL_DROP );
-
        Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-               "executing insentry_query\n", 0, 0, 0 );
+               "executing renentry_stmt\n", 0, 0, 0 );
 
-       rc = backsql_Prepare( dbh, &sth, bi->sql_insentry_query, 0 );
+       rc = backsql_Prepare( dbh, &sth, bi->sql_renentry_stmt, 0 );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_modrdn(): "
-                       "error preparing insentry_query\n", 0, 0, 0 );
+                       "error preparing renentry_stmt\n", 0, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                                sth, rc );
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
-               goto done;
-       }
-
-       realnew_dn = new_dn;
-       if ( backsql_api_dn2odbc( op, rs, &realnew_dn ) ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(\"%s\"): "
-                       "backsql_api_dn2odbc(\"%s\") failed\n", 
-                       op->o_req_dn.bv_val, realnew_dn.bv_val, 0 );
-               SQLFreeStmt( sth, SQL_DROP );
-
-               rs->sr_text = "SQL-backend error";
-               rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
@@ -316,14 +332,15 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
-       rc = backsql_BindParamInt( sth, 2, SQL_PARAM_INPUT, &e_id.eid_oc_id );
+       rc = backsql_BindParamID( sth, 2, SQL_PARAM_INPUT, &n_id.eid_id );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_add_attr(): "
-                       "error binding objectClass ID parameter for objectClass %s\n",
+                       "error binding parent ID parameter for objectClass %s\n",
                        oc->bom_oc->soc_cname.bv_val, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
@@ -331,14 +348,15 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
-       rc = backsql_BindParamID( sth, 3, SQL_PARAM_INPUT, &new_pe_id.eid_id );
+       rc = backsql_BindParamID( sth, 3, SQL_PARAM_INPUT, &e_id.eid_keyval );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_add_attr(): "
-                       "error binding parent ID parameter for objectClass %s\n",
+                       "error binding entry ID parameter for objectClass %s\n",
                        oc->bom_oc->soc_cname.bv_val, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
@@ -346,14 +364,15 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
-       rc = backsql_BindParamID( sth, 4, SQL_PARAM_INPUT, &e_id.eid_keyval );
+       rc = backsql_BindParamID( sth, 4, SQL_PARAM_INPUT, &e_id.eid_id );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_add_attr(): "
-                       "error binding entry ID parameter for objectClass %s\n",
+                       "error binding ID parameter for objectClass %s\n",
                        oc->bom_oc->soc_cname.bv_val, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                        sth, rc );
@@ -361,18 +380,19 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                rs->sr_text = "SQL-backend error";
                rs->sr_err = LDAP_OTHER;
+               e = NULL;
                goto done;
        }
 
        rc = SQLExecute( sth );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
-                       "could not insert ldap_entries record\n", 0, 0, 0 );
+                       "could not rename ldap_entries record\n", 0, 0, 0 );
                backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "SQL-backend error";
-               send_ldap_result( op, rs );
+               e = NULL;
                goto done;
        }
        SQLFreeStmt( sth, SQL_DROP );
@@ -386,15 +406,15 @@ backsql_modrdn( Operation *op, SlapReply *rs )
        {
                Debug( LDAP_DEBUG_TRACE,
                        "   backsql_modrdn: can't figure out "
-                       "type(s)/values(s) of newrdn\n", 
+                       "type(s)/values(s) of new_rdn\n", 
                        0, 0, 0 );
                rs->sr_err = LDAP_INVALID_DN_SYNTAX;
+               e = &r;
                goto done;
        }
 
-       Debug( LDAP_DEBUG_TRACE,
-               "   backsql_modrdn: new_rdn_type=\"%s\", "
-               "new_rdn_val=\"%s\"\n",
+       Debug( LDAP_DEBUG_TRACE, "backsql_modrdn: "
+               "new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
                new_rdn[ 0 ]->la_attr.bv_val,
                new_rdn[ 0 ]->la_value.bv_val, 0 );
 
@@ -407,37 +427,117 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                                "the old_rdn type(s)/value(s)\n", 
                                0, 0, 0 );
                        rs->sr_err = LDAP_OTHER;
-                       goto done;              
+                       e = NULL;
+                       goto done;
                }
        }
 
-       e.e_name = new_dn;
-       e.e_nname = new_ndn;
-       rs->sr_err = slap_modrdn2mods( op, rs, &e, old_rdn, new_rdn, &mod );
+       rs->sr_err = slap_modrdn2mods( op, rs, &r, old_rdn, new_rdn, &mod );
        if ( rs->sr_err != LDAP_SUCCESS ) {
-               goto modrdn_return;
-       }
-
-       if ( !acl_check_modlist( op, &e, mod )) {
-               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-               goto modrdn_return;
+               e = &r;
+               goto done;
        }
 
        oc = backsql_id2oc( bi, e_id.eid_oc_id );
        rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, mod );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               e = &r;
+               goto done;
+       }
+
+       if ( global_schemacheck ) {
+               char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
+
+               entry_clean( &r );
+               (void)backsql_free_entryID( op, &e_id, 0 );
+
+               bsi.bsi_e = &r;
+               rs->sr_err = backsql_init_search( &bsi, &new_ndn,
+                               LDAP_SCOPE_BASE, 
+                               SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                               (time_t)(-1), NULL, dbh, op, rs,
+                               slap_anlist_all_attributes,
+                               ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+               switch ( rs->sr_err ) {
+               case LDAP_SUCCESS:
+                       break;
+
+               case LDAP_REFERRAL:
+                       if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                                       dn_match( &new_ndn, &bsi.bsi_e->e_nname ) )
+                       {
+                               rs->sr_err = LDAP_SUCCESS;
+                               rs->sr_text = NULL;
+                               rs->sr_matched = NULL;
+                               if ( rs->sr_ref ) {
+                                       ber_bvarray_free( rs->sr_ref );
+                                       rs->sr_ref = NULL;
+                               }
+                               break;
+                       }
+                       e = &r;
+                       /* fallthru */
+
+               default:
+                       Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
+                               "could not retrieve modrdnDN ID - no such entry\n", 
+                               0, 0, 0 );
+                       if ( !BER_BVISNULL( &r.e_nname ) ) {
+                               /* FIXME: should always be true! */
+                               e = &r;
+
+                       } else {
+                               e = NULL;
+                       }
+                       goto done;
+               }
+
+               e_id = bsi.bsi_base_id;
+
+               rs->sr_err = entry_schema_check( op->o_bd, &r,
+                               NULL,
+                               &rs->sr_text, textbuf, sizeof( textbuf ) );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                               "entry failed schema check -- aborting\n",
+                               r.e_name.bv_val, 0, 0 );
+                       e = NULL;
+                       goto done;
+               }
+       }
 
 done:;
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       if ( e != NULL ) {
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+               }
+       }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
+       send_ldap_result( op, rs );
+
        /*
         * Commit only if all operations succeed
         */
-       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
-               SQLTransact( SQL_NULL_HENV, dbh, SQL_COMMIT );
+       if ( sth != SQL_NULL_HSTMT ) {
+               SQLUSMALLINT    CompletionType = SQL_ROLLBACK;
+       
+               if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+                       CompletionType = SQL_COMMIT;
+               }
 
-       } else {
-               SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
+               SQLTransact( SQL_NULL_HENV, dbh, CompletionType );
        }
 
-modrdn_return:;
        if ( !BER_BVISNULL( &realnew_dn ) && realnew_dn.bv_val != new_dn.bv_val ) {
                ch_free( realnew_dn.bv_val );
        }
@@ -465,13 +565,28 @@ modrdn_return:;
                }
        }
 
-       if ( !BER_BVISNULL( &new_pe_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &new_pe_id, 0 );
+       if ( !BER_BVISNULL( &e_id.eid_ndn ) ) {
+               (void)backsql_free_entryID( op, &e_id, 0 );
        }
 
-       send_ldap_result( op, rs );
+       if ( !BER_BVISNULL( &n_id.eid_ndn ) ) {
+               (void)backsql_free_entryID( op, &n_id, 0 );
+       }
+
+       if ( !BER_BVISNULL( &r.e_nname ) ) {
+               entry_clean( &r );
+       }
+
+       if ( !BER_BVISNULL( &p.e_nname ) ) {
+               entry_clean( &p );
+       }
+
+       if ( !BER_BVISNULL( &n.e_nname ) ) {
+               entry_clean( &n );
+       }
 
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 );
-       return op->o_noop;
+
+       return rs->sr_err;
 }
 
index c0c7ed2442f5012f84a023febd91ffc9a5841725..e0f4af3b1ada65e903f2832bc064bf70d82b0cb6 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -178,12 +180,13 @@ backsql_operational(
                        && !got[ BACKSQL_OP_ENTRYUUID ]
                        && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID ) == NULL )
        {
-               backsql_srch_info       bsi;
+               backsql_srch_info       bsi = { 0 };
 
                rc = backsql_init_search( &bsi, &rs->sr_entry->e_nname,
-                               LDAP_SCOPE_BASE, -1, -1, -1, NULL,
-                               dbh, op, rs, NULL,
-                               ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
+                               LDAP_SCOPE_BASE,
+                               SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                               (time_t)(-1), NULL, dbh, op, rs, NULL,
+                               BACKSQL_ISF_GET_ID );
                if ( rc != LDAP_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
                                "could not retrieve entry ID - no such entry\n", 
@@ -193,7 +196,11 @@ backsql_operational(
 
                *ap = backsql_operational_entryUUID( bi, &bsi.bsi_base_id );
 
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+
+               if ( bsi.bsi_attrs != NULL ) {
+                       op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
+               }
 
                if ( *ap == NULL ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
index 42162b9535fdcf9f347324ac052ed6f3f16abacf..8019284223d1e0e0712fcc321fbfe705c86273c4 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Mararati.
  * All rights reserved.
@@ -16,7 +16,7 @@
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
  * by OpenLDAP Software.  Additional significant contributors include
- *    Pierangelo Mararati
+ * Pierangelo Masarati
  */
 
 /*
@@ -74,7 +74,6 @@
 #define PROTO_SQL_H
 
 #include "back-sql.h"
-#include "sql-types.h"
 
 /*
  * add.c
@@ -97,7 +96,9 @@ int backsql_modify_internal(
 /*
  * api.c
  */
-int backsql_api_config( backsql_info *si, const char *name );
+int backsql_api_config( backsql_info *bi, const char *name,
+               int argc, char *argv[] );
+int backsql_api_destroy( backsql_info *bi );
 int backsql_api_register( backsql_api *ba );
 int backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn );
 int backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn );
@@ -110,8 +111,9 @@ extern struct berval        backsql_baseObject_bv;
 #endif /* BACKSQL_ARBITRARY_KEY */
 
 /* stores in *id the ID in table ldap_entries corresponding to DN, if any */
-int backsql_dn2id( Operation *op, SlapReply *rs, backsql_entryID *id,
-               SQLHDBC dbh, struct berval *dn, int muck );
+int backsql_dn2id( Operation *op, SlapReply *rs, SQLHDBC dbh,
+               struct berval *ndn, backsql_entryID *id,
+               int matched, int muck );
 
 /* stores in *nchildren the count of children for an entry */
 int backsql_count_children( backsql_info *bi, SQLHDBC dbh,
@@ -122,7 +124,8 @@ int backsql_count_children( backsql_info *bi, SQLHDBC dbh,
 int backsql_has_children( backsql_info *bi, SQLHDBC dbh, struct berval *dn );
 
 /* frees *id and returns next in list */
-backsql_entryID *backsql_free_entryID( backsql_entryID *id, int freeit );
+backsql_entryID *backsql_free_entryID( Operation *op, backsql_entryID *id,
+               int freeit );
 
 /* turns an ID into an entry */
 int backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *id );
@@ -160,8 +163,6 @@ int backsql_destroy_schema_map( backsql_info *si );
  * search.c
  */
 
-#define BACKSQL_ISF_GET_ID     0x1U
-#define BACKSQL_ISF_MUCK       0x2U
 int backsql_init_search( backsql_srch_info *bsi, 
                struct berval *nbase, int scope, int slimit, int tlimit,
                time_t stoptime, Filter *filter, SQLHDBC dbh,
@@ -222,10 +223,10 @@ extern char
        backsql_def_oc_query[],
        backsql_def_needs_select_oc_query[],
        backsql_def_at_query[],
-       backsql_def_delentry_query[],
-       backsql_def_insentry_query[],
-       backsql_def_delobjclasses_query[],
-       backsql_def_delreferrals_query[],
+       backsql_def_delentry_stmt[],
+       backsql_def_renentry_stmt[],
+       backsql_def_insentry_stmt[],
+       backsql_def_delobjclasses_stmt[],
        backsql_def_subtree_cond[],
        backsql_def_upper_subtree_cond[],
        backsql_id_query[],
@@ -236,7 +237,7 @@ extern char
 struct berbuf * backsql_strcat( struct berbuf *dest, ... );
 struct berbuf * backsql_strfcat( struct berbuf *dest, const char *fmt, ... );
 
-int backsql_entry_addattr( Entry *e, struct berval *at_name
+int backsql_entry_addattr( Entry *e, AttributeDescription *ad
                struct berval *at_val, void *memctx );
 
 int backsql_merge_from_clause( struct berbuf *dest_from, 
index c82e75002e2cbc614a0b52b1d1a6519a8515e39e..cb2856bbc763ff07c308017c281c447667342c3b 100644 (file)
@@ -50,13 +50,6 @@ alter table ldap_entries add
                dn
        );  
 
-drop table ldap_referrals;
-create table ldap_referrals
- (
-       entry_id integer not null references ldap_entries(id),
-       url varchar(256) not null
-);
-
 drop table ldap_entry_objclasses;
 create table ldap_entry_objclasses
  (
index 556470cb53cc6c4c7185896aae5e4b5856c81565..f6c16130099b26c13557d7735578b7157008b6c1 100644 (file)
@@ -28,7 +28,7 @@ dbname                ldap_db2
 dbuser         db2inst1
 dbpasswd       ibmdb2
 subtree_cond   "upper(ldap_entries.dn) LIKE CONCAT('%',?)"
-insentry_query "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select max(id)+1 from ldap_entries),?,?,?,?)"
+insentry_stmt  "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select max(id)+1 from ldap_entries),?,?,?,?)"
 upper_func     "upper"
 upper_needs_cast       "yes"
 create_needs_select    "yes"
index 4cd7330c1e6c3785cadbaedf5c1c08ef27205726..b6e850c80aa996fdd794ed520b93cba1a2c47f36 100644 (file)
@@ -32,6 +32,13 @@ CREATE TABLE phones (
        pers_id int NOT NULL 
 );
 
+drop table referrals;
+CREATE TABLE referrals (
+       id int NOT NULL,
+       name varchar(255) NOT NULL,
+       url varchar(255) NOT NULL
+);
+
 
 
 ALTER TABLE authors_docs  ADD 
index 79f07d3078ceb7331f7f8a9bd14ccc2d9da79164..c204ecd8ce78958c5b9802313fd529abb05d3cb6 100644 (file)
@@ -14,3 +14,5 @@ insert into documents (id,abstract,title) values (2,'abstract2','book2');
 insert into authors_docs (pers_id,doc_id) values (1,1);
 insert into authors_docs (pers_id,doc_id) values (1,2);
 insert into authors_docs (pers_id,doc_id) values (2,1);
+
+insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/');
index 33c509a13b1bbbbd35c9370071532560f9231b6a..0b0d1c2e8fe7a3460853046e8b358e788017e25b 100644 (file)
@@ -21,6 +21,10 @@ insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,create_keyval,de
 values (3,'organization','institutes','id','INSERT INTO institutes (id,name) VALUES ((SELECT max(id)+1 FROM institutes),'''')',
        'SELECT max(id) FROM institutes','DELETE FROM institutes WHERE id=?',0);
 
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,create_keyval,delete_proc,expect_return)
+values (4,'referral','referrals','id','INSERT INTO referrals (id,name,url) VALUES ((SELECT max(id)+1 FROM referrals),'''','''')',
+       'SELECT max(id) FROM referrals','DELETE FROM referrals WHERE id=?',0);
+
 -- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data.
 --      id              a unique number identifying the attribute       
 --      oc_map_id       the value of "ldap_oc_mappings.id" that identifies the objectClass this attributeType is defined for
@@ -78,39 +82,42 @@ values (12,3,'dc','lcase(institutes.name)','institutes,ldap_entries AS dcObject,
        'institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',
        NULL,NULL,3,0);
 
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (13,4,'ou','referrals.name','referrals',NULL,'UPDATE referrals SET name=? WHERE id=?',NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (14,4,'ref','referrals.url','referrals',NULL,'UPDATE referrals SET url=? WHERE id=?',NULL,3,0);
+
 -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
 --      id              a unique number > 0 identifying the entry
 --      dn              the DN of the entry, in "pretty" form
 --      oc_map_id       the "ldap_oc_mappings.id" of the main objectClass of this entry (view it as the structuralObjectClass)
 --      parent          the "ldap_entries.id" of the parent of this objectClass; 0 if it is the "suffix" of the database
 --      keyval          the value of the "keytbl.keycol" defined for this objectClass
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(1,'dc=example,dc=com',3,0,1);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (1,'dc=example,dc=com',3,0,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (2,'cn=Mitya Kovalev,dc=example,dc=com',1,1,1);
 
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(2,'cn=Mitya Kovalev,dc=example,dc=com',1,1,1);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (3,'cn=Torvlobnor Puzdoy,dc=example,dc=com',1,1,2);
 
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(3,'cn=Torvlobnor Puzdoy,dc=example,dc=com',1,1,2);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (4,'cn=Akakiy Zinberstein,dc=example,dc=com',1,1,3);
 
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(4,'cn=Akakiy Zinberstein,dc=example,dc=com',1,1,3);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (5,'documentTitle=book1,dc=example,dc=com',2,1,1);
 
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(5,'documentTitle=book1,dc=example,dc=com',2,1,1);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (6,'documentTitle=book2,dc=example,dc=com',2,1,2);
 
-insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values
-(6,'documentTitle=book2,dc=example,dc=com',2,1,2);
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (7,'ou=Referral,dc=example,dc=com',4,1,1);
 
 -- objectClass mapping: entries that have multiple objectClass instances are listed here with the objectClass name (view them as auxiliary objectClass)
 --      entry_id        the "ldap_entries.id" of the entry this objectClass value must be added
 --      oc_name         the name of the objectClass; it MUST match the name of an objectClass that is loaded in slapd's schema
 insert into ldap_entry_objclasses (entry_id,oc_name) values (1,'dcObject');
 
-insert into ldap_entry_objclasses (entry_id,oc_name) values (4,'referral');
-
--- referrals mapping: entries that should be treated as referrals are stored here
---      entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
---      url             the URI of the referral
-insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost/');
-
+insert into ldap_entry_objclasses (entry_id,oc_name) values (7,'extensibleObject');
index 91d808d2dcb3d2ec6dabe190ed361bd7e4ef4caf..9a9582d1777c20a59df680dca2facf0068b4e209 100644 (file)
@@ -99,7 +99,7 @@ insert into ldap_entry_objclasses (entry_id,oc_name)
 values (4,'referral');
 
 insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost/');
+values (4,'ldap://localhost:9010/');
 
 -- support procedures
 
index b39df23abdc82485ecbe508e3087669b66939d69..771c1c88bf9118278fa0c24a364a1a726c9402e0 100644 (file)
@@ -49,13 +49,6 @@ alter table ldap_entries add
                dn
        );  
 
-drop table if exists ldap_referrals;
-create table ldap_referrals
- (
-       entry_id integer not null references ldap_entries(id),
-       url text not null
-);
-
 drop table if exists ldap_entry_objclasses;
 create table ldap_entry_objclasses
  (
index a780c83954d2dcb7b52786c111193ab01dc329c0..8f6e4e12f1ee1578b42084e5e212ded2e5c5e93e 100644 (file)
@@ -28,5 +28,5 @@ dbname                ldap_mysql
 dbuser         root
 dbpasswd       
 subtree_cond   "ldap_entries.dn LIKE CONCAT('%',?)"
-insentry_query "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)"
+insentry_stmt  "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)"
 has_ldapinfo_dn_ru     no
index b83a4e9616ff54b007300a6db4f0eb4009127467..3c6b71e8b066735d73280127a88249c96e82f58b 100644 (file)
@@ -66,3 +66,10 @@ ALTER TABLE phones  ADD
                id
        ); 
 
+drop table if exists referrals;
+CREATE TABLE referrals (
+       id int NOT NULL,
+       name varchar(255) NOT NULL,
+       url varchar(255) NOT NULL
+);
+
index 79f07d3078ceb7331f7f8a9bd14ccc2d9da79164..c204ecd8ce78958c5b9802313fd529abb05d3cb6 100644 (file)
@@ -14,3 +14,5 @@ insert into documents (id,abstract,title) values (2,'abstract2','book2');
 insert into authors_docs (pers_id,doc_id) values (1,1);
 insert into authors_docs (pers_id,doc_id) values (1,2);
 insert into authors_docs (pers_id,doc_id) values (2,1);
+
+insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/');
index 8933a4c87803f4f47f28cab8908ee6c5f30ae986..1606600fe994dd4e55a49a231f18308219fbe732 100644 (file)
@@ -17,6 +17,9 @@ values (2,'document','documents','id',NULL,NULL,0);
 insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
 values (3,'organization','institutes','id',NULL,NULL,0);
 
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (4,'referral','referrals','id',NULL,NULL,0);
+
 -- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data.
 --     id              a unique number identifying the attribute       
 --     oc_map_id       the value of "ldap_oc_mappings.id" that identifies the objectClass this attributeType is defined for
@@ -71,6 +74,12 @@ values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,
        'institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',
        NULL,NULL,3,0);
 
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (13,4,'ou','referrals.name','referrals',NULL,NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (14,4,'ref','referrals.url','referrals',NULL,NULL,NULL,3,0);
+
 -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
 --     id              a unique number > 0 identifying the entry
 --     dn              the DN of the entry, in "pretty" form
@@ -94,7 +103,9 @@ values (5,'documentTitle=book1,dc=example,dc=com',2,1,1);
 
 insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
 values (6,'documentTitle=book2,dc=example,dc=com',2,1,2);
-       
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (7,'ou=Referral,dc=example,dc=com',4,1,1);
 
 -- objectClass mapping: entries that have multiple objectClass instances are listed here with the objectClass name (view them as auxiliary objectClass)
 --     entry_id        the "ldap_entries.id" of the entry this objectClass value must be added
@@ -103,11 +114,5 @@ insert into ldap_entry_objclasses (entry_id,oc_name)
 values (1,'dcObject');
 
 insert into ldap_entry_objclasses (entry_id,oc_name)
-values (4,'referral');
-
--- referrals mapping: entries that should be treated as referrals are stored here
---     entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
---     url             the URI of the referral
-insert into ldap_referrals (entry_id,url)
-values (4,'ldap://localhost/');
+values (7,'extensibleObject');
 
index e94368237a49f658c23e14c0d0469010c09bc686..cc195d91e8c2cccebf9507b37afa7a97cfa81bbf 100644 (file)
@@ -28,5 +28,5 @@ dbname                ldap_ora8
 dbuser         ldap
 dbpasswd       ldap
 subtree_cond   "UPPER(ldap_entries.dn) LIKE CONCAT('%',UPPER(?))"
-insentry_query "INSERT INTO ldap_entries (id,dn,oc_map_id,parent,keyval) VALUES (ldap_entry_ids.nextval,?,?,?,?)"
+insentry_stmt  "INSERT INTO ldap_entries (id,dn,oc_map_id,parent,keyval) VALUES (ldap_entry_ids.nextval,?,?,?,?)"
 upper_func     UPPER
index d0c3186f49dd31a96d4a58af972f98864295c0dd..f6c8d14acc92747e9b388053fbb9a8c64786cd0d 100644 (file)
@@ -115,7 +115,7 @@ values (4,'referral');
 --     entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
 --     url             the URI of the referral
 insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost/');
+values (4,'ldap://localhost:9010/');
 
 
 -- procedures
index 65aea733cb596f86d3bcc3e36024eef2b7a954fd..a4baa7040018877021b89703bd249d9804476891 100644 (file)
@@ -41,13 +41,6 @@ create table ldap_entries
        UNIQUE ( dn )
 );
 
-drop table ldap_referrals;
-create table ldap_referrals
- (
-       entry_id integer not null references ldap_entries(id),
-       url text not null
-);
-
 drop table ldap_entry_objclasses;
 create table ldap_entry_objclasses
  (
index aecc890597407c1941e14db58d88c6b27c739f39..70a8dee054679a4d2f96ea84fd49e4f73b313d88 100644 (file)
@@ -27,7 +27,7 @@ rootpw                secret
 dbname         PostgreSQL
 dbuser         postgres
 dbpasswd       postgres
-insentry_query "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select max(id)+1 from ldap_entries),?,?,?,?)"
+insentry_stmt  "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select max(id)+1 from ldap_entries),?,?,?,?)"
 upper_func     "upper"
 strcast_func   "text"
 concat_pattern "?||?"
index f156891dffc882dbba4fba2f3d466810c17521e3..0142dd9b15a1c3e8a6cf1f6234938ef8d5eaab9d 100644 (file)
@@ -37,3 +37,11 @@ create table phones (
        pers_id int not null
 );
 
+drop table referrals;
+drop sequence referrals_id_seq;
+create table referrals (
+       id serial not null primary key,
+       name varchar(255) not null,
+       url varchar(255) not null
+);
+
index f7743f62313fcf22461a39bbd6482eed3b134bbc..c204ecd8ce78958c5b9802313fd529abb05d3cb6 100644 (file)
@@ -15,3 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1);
 insert into authors_docs (pers_id,doc_id) values (1,2);
 insert into authors_docs (pers_id,doc_id) values (2,1);
 
+insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/');
index 75ade75e504f4d265e6cb117eb079b0785e82f9f..4afea62502df036e7d121355e6cec86bfa76ecc3 100644 (file)
@@ -14,6 +14,8 @@ insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expe
 
 insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (3,'organization','institutes','id','SELECT create_o()','DELETE FROM institutes WHERE id=?',0);
 
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (4,'referral','referrals','id','SELECT create_referral()','DELETE FROM referrals WHERE id=?',0);
+
 -- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data.
 --     id              a unique number identifying the attribute       
 --     oc_map_id       the value of "ldap_oc_mappings.id" that identifies the objectClass this attributeType is defined for
@@ -49,6 +51,9 @@ insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,
 
 insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,ldap_entry_objclasses AS auxObjectClass','institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',NULL,NULL,3,0);
 
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (13,4,'ou','referrals.name','referrals',NULL,'UPDATE referrals SET name=? WHERE id=?',NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (14,4,'ref','referrals.url','referrals',NULL,'UPDATE referrals SET url=? WHERE id=?',NULL,3,0);
 
 -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
 --     id              a unique number > 0 identifying the entry
@@ -68,18 +73,14 @@ insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (5,'documentTitl
 
 insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (6,'documentTitle=book2,dc=example,dc=com',2,1,2);
        
-       
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (7,'ou=Referral,dc=example,dc=com',4,1,1);
+
 -- objectClass mapping: entries that have multiple objectClass instances are listed here with the objectClass name (view them as auxiliary objectClass)
 --     entry_id        the "ldap_entries.id" of the entry this objectClass value must be added
 --     oc_name         the name of the objectClass; it MUST match the name of an objectClass that is loaded in slapd's schema
 insert into ldap_entry_objclasses (entry_id,oc_name) values (1,'dcObject');
 
-insert into ldap_entry_objclasses (entry_id,oc_name) values (4,'referral');
-
--- referrals mapping: entries that should be treated as referrals are stored here
---     entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
---     url             the URI of the referral
-insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost/');
+insert into ldap_entry_objclasses (entry_id,oc_name) values (7,'extensibleObject');
 
 -- procedures
 -- these procedures are specific for this RDBMS and are used in mapping objectClass and attributeType creation/modify/deletion
@@ -131,3 +132,11 @@ as '
        select max(id) from institutes
 ' language 'sql';
 
+create function create_referral () returns int
+as '
+       select setval (''referrals_id_seq'', (select case when max(id) is null then 1 else max(id) end from referrals));
+       insert into referrals (id,name,url) 
+               values ((select case when max(id) is null then 1 else nextval(''referrals_id_seq'') end from referrals),'''','''');
+       select max(id) from referrals
+' language 'sql';
+
index 88440aed5f92a67b1b5657f5205775658f622ebe..c6293b2a0458a8987c73c545dd6ca0c6ba3ea9f8 100644 (file)
@@ -1,4 +1,4 @@
-## Copyright 1997-2004 The OpenLDAP Foundation, All Rights Reserved.
+## Copyright 1997-2005 The OpenLDAP Foundation, All Rights Reserved.
 ##  COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 
 #
index a9722d1e7432e63365ea76480940278cf926962e..4006eab8aaf836c0152e5653da0700f49f2683d7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 1997-2004 The OpenLDAP Foundation, All Rights Reserved.
+// Copyright 1997-2005 The OpenLDAP Foundation, All Rights Reserved.
 //  COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 
 // (c) Copyright 1999-2001 TimesTen Performance Software. All rights reserved.
index b0b15a386f7aea499b54ba7fccbe8ceeaf98a065..f93de8b402e3285eef91dafa9223457a0f8315a2 100644 (file)
@@ -28,4 +28,4 @@ dbname                ldap_tt
 dbuser         root
 dbpasswd       
 subtree_cond   "ldap_entries.dn LIKE ?"
-insentry_query "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)"
+insentry_stmt  "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)"
index 098eea23b043e8c7fd4e21c8500e73b8562523f0..40e8001a8c611cea962805a75c42c4ac9d5fb555 100644 (file)
@@ -105,4 +105,4 @@ insert into ldap_entry_objclasses (entry_id,oc_name)
 values (4,'referral');
 
 insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost');
+values (4,'ldap://localhost:9010');
index 9022c451dc08942e2efd09097a2a410bb20d054f..7d7be83a8f311bff975ea17b8e430fee9640865a 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati and Mark Adamson.
  */
 
 #include "portable.h"
@@ -151,7 +154,30 @@ backsql_make_attr_query(
 #endif /* ! BACKSQL_ALIASING_QUOTE */
 
        at_map->bam_query = bb.bb_val.bv_val;
-       
+
+#ifdef BACKSQL_COUNTQUERY
+       /* Query to count how many rows will be returned. */
+       BER_BVZERO( &bb.bb_val );
+       bb.bb_len = 0;
+       backsql_strfcat( &bb, "lblbcbl", 
+                       (ber_len_t)STRLENOF( "SELECT COUNT(*) FROM " ),
+                               "SELECT COUNT(*) FROM ", 
+                       &at_map->bam_from_tbls, 
+                       (ber_len_t)STRLENOF( " WHERE " ), " WHERE ", 
+                       &oc_map->bom_keytbl,
+                       '.', 
+                       &oc_map->bom_keycol,
+                       (ber_len_t)STRLENOF( "=?" ), "=?" );
+
+       if ( !BER_BVISNULL( &at_map->bam_join_where ) ) {
+               backsql_strfcat( &bb, "lb",
+                               (ber_len_t)STRLENOF( " AND " ), " AND ", 
+                               &at_map->bam_join_where );
+       }
+
+       at_map->bam_countquery = bb.bb_val.bv_val;
+#endif /* BACKSQL_COUNTQUERY */
+
        return 0;
 }
 
@@ -164,8 +190,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
        struct berbuf           bb;
        
        sbv.bv_val = s;
-       snprintf( s, sizeof( s ), "%ld", oc_map->bom_id );
-       sbv.bv_len = strlen( s );
+       sbv.bv_len = snprintf( s, sizeof( s ), "%ld", oc_map->bom_id );
 
        /* extra objectClasses */
        at_map = (backsql_at_map_rec *)ch_calloc(1, 
@@ -259,81 +284,6 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
                        &sbv );
        at_map->bam_join_where = bb.bb_val;
 
-       /* referral attribute */
-       at_map = (backsql_at_map_rec *)ch_calloc( 1, 
-                       sizeof( backsql_at_map_rec ) );
-       at_map->bam_ad = slap_schema.si_ad_ref;
-       ber_str2bv( "ldap_referrals.url", 0, 1, &at_map->bam_sel_expr );
-       ber_str2bv( "ldap_referrals,ldap_entries", 0, 1, &at_map->bam_from_tbls );
-
-       bb.bb_len = at_map->bam_from_tbls.bv_len + 1;
-       bb.bb_val = at_map->bam_from_tbls;
-       backsql_merge_from_clause( &bb, &oc_map->bom_keytbl );
-       at_map->bam_from_tbls = bb.bb_val;
-
-       BER_BVZERO( &bb.bb_val );
-       bb.bb_len = 0;
-       backsql_strfcat( &bb, "lbcblb",
-                       (ber_len_t)STRLENOF( "ldap_entries.id=ldap_referrals.entry_id AND ldap_entries.keyval=" ),
-                               "ldap_entries.id=ldap_referrals.entry_id AND ldap_entries.keyval=",
-                       &oc_map->bom_keytbl, 
-                       '.', 
-                       &oc_map->bom_keycol,
-                       (ber_len_t)STRLENOF( " AND ldap_entries.oc_map_id=" ), 
-                               " AND ldap_entries.oc_map_id=", 
-                       &sbv );
-
-       at_map->bam_join_where = bb.bb_val;
-
-       at_map->bam_oc = NULL;
-
-       at_map->bam_add_proc = NULL;
-       {
-               char    tmp[] =
-                       "INSERT INTO ldap_referrals "
-                       "(entry_id,url) VALUES "
-                       "((SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?),?)";
-               snprintf( tmp, sizeof(tmp), 
-                       "INSERT INTO ldap_referrals "
-                       "(entry_id,url) VALUES "
-                       "((SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id=%lu "
-                       "AND keyval=?),?)", oc_map->bom_id );
-               at_map->bam_add_proc = ch_strdup( tmp );
-       }
-
-       at_map->bam_delete_proc = NULL;
-       {
-               char    tmp[] =
-                       "DELETE FROM ldap_referrals "
-                       "WHERE entry_id=(SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?) and url=?";
-               snprintf( tmp, sizeof(tmp), 
-                       "DELETE FROM ldap_referrals "
-                       "WHERE entry_id=(SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id=%lu"
-                       "AND keyval=?) and url=?",
-                       oc_map->bom_id );
-               at_map->bam_delete_proc = ch_strdup( tmp );
-       }
-
-       at_map->bam_param_order = 0;
-       at_map->bam_expect_return = 0;
-       at_map->bam_next = NULL;
-
-       backsql_make_attr_query( oc_map, at_map );
-       if ( avl_insert( &oc_map->bom_attrs, at_map, backsql_cmp_attr, backsql_dup_attr ) == BACKSQL_DUPLICATE ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_add_sysmaps(): "
-                               "duplicate attribute \"%s\" in objectClass \"%s\" map\n",
-                               at_map->bam_ad->ad_cname.bv_val,
-                               oc_map->bom_oc->soc_cname.bv_val, 0 );
-       }
-
        return 1;
 }
 
@@ -385,6 +335,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
        backsql_BindRowAsStrings( bas->bas_sth, &at_row );
        for ( ; rc = SQLFetch( bas->bas_sth ), BACKSQL_SUCCESS( rc ); ) {
                const char      *text = NULL;
+               char            *next = NULL;
                struct berval   bv;
                struct berbuf   bb = BB_NULL;
 
@@ -446,9 +397,15 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
                        at_map->bam_delete_proc = ch_strdup( at_row.cols[ 5 ] );
                }
                at_map->bam_param_order = strtol( at_row.cols[ 6 ], 
-                               NULL, 0 );
+                               &next, 0 );
+               if ( next == at_row.cols[ 6 ] || next[0] != '\0' ) {
+                       /* error */
+               }
                at_map->bam_expect_return = strtol( at_row.cols[ 7 ],
-                               NULL, 0 );
+                               &next, 0 );
+               if ( next == at_row.cols[ 7 ] || next[0] != '\0' ) {
+                       /* error */
+               }
                backsql_make_attr_query( oc_map, at_map );
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_attr_mapping(): "
                        "preconstructed query \"%s\"\n",
@@ -491,7 +448,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
 int
 backsql_load_schema_map( backsql_info *bi, SQLHDBC dbh )
 {
-       SQLHSTMT                        sth;
+       SQLHSTMT                        sth = SQL_NULL_HSTMT;
        RETCODE                         rc;
        BACKSQL_ROW_NTS                 oc_row;
        unsigned long                   oc_id;
@@ -573,6 +530,28 @@ backsql_load_schema_map( backsql_info *bi, SQLHDBC dbh )
                oc_map->bom_expect_return = strtol( oc_row.cols[ colnum + 1 ], 
                                NULL, 0 );
 
+               colnum += 2;
+               if ( ( oc_row.ncols > colnum ) &&
+                               ( oc_row.value_len[ colnum ] > 0 ) )
+               {
+                       const char      *text;
+
+                       oc_map->bom_create_hint = NULL;
+                       rc = slap_str2ad( oc_row.cols[ colnum ],
+                                       &oc_map->bom_create_hint, &text );
+                       if ( rc != SQL_SUCCESS ) {
+                               Debug( LDAP_DEBUG_TRACE, "load_schema_map(): "
+                                               "error matching "
+                                               "AttributeDescription %s "
+                                               "in create_hint: %s (%d)\n",
+                                               oc_row.cols[ colnum ],
+                                               text, rc );
+                               backsql_PrintErrors( bi->sql_db_env, dbh,
+                                               sth, rc );
+                               return LDAP_OTHER;
+                       }
+               }
+
                /*
                 * FIXME: first attempt to check for offending
                 * instructions in {create|delete}_proc
@@ -593,22 +572,27 @@ backsql_load_schema_map( backsql_info *bi, SQLHDBC dbh )
                }
                oc_id = oc_map->bom_id;
                Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
-                       "objectClass \"%s\": keytbl=\"%s\" keycol=\"%s\"\n",
+                       "objectClass \"%s\":\n    keytbl=\"%s\" keycol=\"%s\"\n",
                        BACKSQL_OC_NAME( oc_map ),
                        oc_map->bom_keytbl.bv_val, oc_map->bom_keycol.bv_val );
                if ( oc_map->bom_create_proc ) {
-                       Debug( LDAP_DEBUG_TRACE, "create_proc=\"%s\"\n",
+                       Debug( LDAP_DEBUG_TRACE, "    create_proc=\"%s\"\n",
                                oc_map->bom_create_proc, 0, 0 );
                }
                if ( oc_map->bom_create_keyval ) {
-                       Debug( LDAP_DEBUG_TRACE, "create_keyval=\"%s\"\n",
+                       Debug( LDAP_DEBUG_TRACE, "    create_keyval=\"%s\"\n",
                                oc_map->bom_create_keyval, 0, 0 );
                }
+               if ( oc_map->bom_create_hint ) {
+                       Debug( LDAP_DEBUG_TRACE, "    create_hint=\"%s\"\n", 
+                               oc_map->bom_create_hint->ad_cname.bv_val,
+                               0, 0 );
+               }
                if ( oc_map->bom_delete_proc ) {
-                       Debug( LDAP_DEBUG_TRACE, "delete_proc=\"%s\"\n", 
+                       Debug( LDAP_DEBUG_TRACE, "    delete_proc=\"%s\"\n", 
                                oc_map->bom_delete_proc, 0, 0 );
                }
-               Debug( LDAP_DEBUG_TRACE, "expect_return: "
+               Debug( LDAP_DEBUG_TRACE, "    expect_return: "
                        "add=%d, del=%d; attributes:\n",
                        BACKSQL_IS_ADD( oc_map->bom_expect_return ), 
                        BACKSQL_IS_DEL( oc_map->bom_expect_return ), 0 );
@@ -789,7 +773,7 @@ supad2at_f( void *v_at, void *v_arg )
        struct supad2at_t       *va = (struct supad2at_t *)v_arg;
 
        if ( is_at_subtype( at->bam_ad->ad_type, va->ad->ad_type ) ) {
-               backsql_at_map_rec      **ret;
+               backsql_at_map_rec      **ret = NULL;
                unsigned                i;
 
                /* if already listed, holler! (should never happen) */
@@ -806,9 +790,11 @@ supad2at_f( void *v_at, void *v_arg )
                }
 
                ret = ch_realloc( va->ret,
-                               sizeof( backsql_at_map_rec *) * ( va->n + 2 ) );
+                               sizeof( backsql_at_map_rec * ) * ( va->n + 2 ) );
                if ( ret == NULL ) {
                        ch_free( va->ret );
+                       va->ret = NULL;
+                       va->n = 0;
                        return SUPAD2AT_STOP;
                }
 
@@ -830,7 +816,7 @@ int
 backsql_supad2at( backsql_oc_map_rec *objclass, AttributeDescription *supad,
                backsql_at_map_rec ***pret )
 {
-       struct supad2at_t       va;
+       struct supad2at_t       va = { 0 };
        int                     rc;
 
        assert( objclass );
@@ -839,9 +825,7 @@ backsql_supad2at( backsql_oc_map_rec *objclass, AttributeDescription *supad,
 
        *pret = NULL;
 
-       va.ret = NULL;
        va.ad = supad;
-       va.n = 0;
 
        rc = avl_apply( objclass->bom_attrs, supad2at_f, &va,
                        SUPAD2AT_STOP, AVL_INORDER );
diff --git a/servers/slapd/back-sql/schema-map.h b/servers/slapd/back-sql/schema-map.h
deleted file mode 100644 (file)
index 7114578..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2004 The OpenLDAP Foundation.
- * Portions Copyright 1999 Dmitry Kovalev.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
- */
-
-#ifndef __BACKSQL_SCHEMA_MAP_H__
-#define __BACKSQL_SCHEMA_MAP_H__
-
-typedef struct backsql_oc_map_rec {
-       /*
-        * Structure of corresponding LDAP objectClass definition
-        */
-       ObjectClass     *bom_oc;
-#define BACKSQL_OC_NAME(ocmap) ((ocmap)->bom_oc->soc_cname.bv_val)
-       
-       struct berval   bom_keytbl;
-       struct berval   bom_keycol;
-       /* expected to return keyval of newly created entry */
-       char            *bom_create_proc;
-       /* in case create_proc does not return the keyval of the newly
-        * created row */
-       char            *bom_create_keyval;
-       /* supposed to expect keyval as parameter and delete 
-        * all the attributes as well */
-       char            *bom_delete_proc;
-       /* flags whether delete_proc is a function (whether back-sql 
-        * should bind first parameter as output for return code) */
-       int             bom_expect_return;
-       unsigned long   bom_id;
-       Avlnode         *bom_attrs;
-} backsql_oc_map_rec;
-
-typedef struct backsql_at_map_rec {
-       /* Description of corresponding LDAP attribute type */
-       AttributeDescription    *bam_ad;
-       /* ObjectClass if bam_ad is objectClass */
-       ObjectClass             *bam_oc;
-
-       struct berval   bam_from_tbls;
-       struct berval   bam_join_where;
-       struct berval   bam_sel_expr;
-
-       /* TimesTen, or, if a uppercase function is defined,
-        * an uppercased version of bam_sel_expr */
-       struct berval   bam_sel_expr_u;
-
-       /* supposed to expect 2 binded values: entry keyval 
-        * and attr. value to add, like "add_name(?,?,?)" */
-       char            *bam_add_proc;
-       /* supposed to expect 2 binded values: entry keyval 
-        * and attr. value to delete */
-       char            *bam_delete_proc;
-       /* for optimization purposes attribute load query 
-        * is preconstructed from parts on schemamap load time */
-       char            *bam_query;
-       /* following flags are bitmasks (first bit used for add_proc, 
-        * second - for delete_proc) */
-       /* order of parameters for procedures above; 
-        * 1 means "data then keyval", 0 means "keyval then data" */
-       int             bam_param_order;
-       /* flags whether one or more of procedures is a function 
-        * (whether back-sql should bind first parameter as output 
-        * for return code) */
-       int             bam_expect_return;
-
-       /* next mapping for attribute */
-       struct backsql_at_map_rec       *bam_next;
-} backsql_at_map_rec;
-
-#define BACKSQL_AT_MAP_REC_INIT { NULL, NULL, BER_BVC(""), BER_BVC(""), BER_BVNULL, BER_BVNULL, NULL, NULL, NULL, 0, 0, NULL }
-
-/* define to uppercase filters only if the matching rule requires it
- * (currently broken) */
-/* #define     BACKSQL_UPPERCASE_FILTER */
-#define        BACKSQL_AT_CANUPPERCASE(at)     ((at)->bam_sel_expr_u.bv_val)
-
-/* defines to support bitmasks above */
-#define BACKSQL_ADD    0x1
-#define BACKSQL_DEL    0x2
-
-#define BACKSQL_IS_ADD(x)      ( BACKSQL_ADD & (x) )
-#define BACKSQL_IS_DEL(x)      ( BACKSQL_DEL & (x) )
-
-#define BACKSQL_NCMP(v1,v2)    ber_bvcmp((v1),(v2))
-
-int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
-/* Deprecated */
-backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
-backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
-backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
-/* Deprecated */
-backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
-               struct berval *at_name );
-backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
-               AttributeDescription *ad );
-int backsql_supad2at( backsql_oc_map_rec *objclass,
-               AttributeDescription *supad, backsql_at_map_rec ***pret );
-int backsql_destroy_schema_map( backsql_info *si );
-
-#endif /* __BACKSQL_SCHEMA_MAP_H__ */
-
index c43abc2053a390c58c498f2505f052f9e9eab092..e99842c67f9bbc6a3190cbc0de3c64f167d6514d 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati and Mark Adamson.
  */
 
 #include "portable.h"
@@ -52,7 +55,7 @@ backsql_attrlist_add( backsql_srch_info *bsi, AttributeDescription *ad )
         * clear the list (retrieve all attrs)
         */
        if ( ad == NULL ) {
-               ch_free( bsi->bsi_attrs );
+               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs, bsi->bsi_op->o_tmpmemctx );
                bsi->bsi_attrs = NULL;
                bsi->bsi_flags |= BSQL_SF_ALL_ATTRS;
                return 1;
@@ -76,8 +79,9 @@ backsql_attrlist_add( backsql_srch_info *bsi, AttributeDescription *ad )
        Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
                "adding \"%s\" to list\n", ad->ad_cname.bv_val, 0, 0 );
 
-       an = (AttributeName *)ch_realloc( bsi->bsi_attrs,
-                       sizeof( AttributeName ) * ( n_attrs + 2 ) );
+       an = (AttributeName *)bsi->bsi_op->o_tmprealloc( bsi->bsi_attrs,
+                       sizeof( AttributeName ) * ( n_attrs + 2 ),
+                       bsi->bsi_op->o_tmpmemctx );
        if ( an == NULL ) {
                return -1;
        }
@@ -115,10 +119,11 @@ backsql_init_search(
        AttributeName           *attrs,
        unsigned                flags )
 {
-       AttributeName           *p;
+       backsql_info            *bi = (backsql_info *)op->o_bd->be_private;
        int                     rc = LDAP_SUCCESS;
 
        bsi->bsi_base_ndn = nbase;
+       bsi->bsi_use_subtree_shortcut = 0;
        BER_BVZERO( &bsi->bsi_base_id.eid_dn );
        BER_BVZERO( &bsi->bsi_base_id.eid_ndn );
        bsi->bsi_scope = scope;
@@ -130,49 +135,121 @@ backsql_init_search(
        bsi->bsi_rs = rs;
        bsi->bsi_flags = BSQL_SF_NONE;
 
-       /*
-        * handle "*"
-        */
-       if ( attrs == NULL ) {
-               /* also add request for all operational */
-               bsi->bsi_attrs = NULL;
-               bsi->bsi_flags |= BSQL_SF_ALL_USER;
+       bsi->bsi_attrs = NULL;
+
+       if ( BACKSQL_FETCH_ALL_ATTRS( bi ) ) {
+               /*
+                * if requested, simply try to fetch all attributes
+                */
+               bsi->bsi_flags |= BSQL_SF_ALL_ATTRS;
 
        } else {
-               int     got_oc = 0;
+               if ( BACKSQL_FETCH_ALL_USERATTRS( bi ) ) {
+                       bsi->bsi_flags |= BSQL_SF_ALL_USER;
 
-               bsi->bsi_attrs = (AttributeName *)ch_calloc( 1, 
-                               sizeof( AttributeName ) );
-               BER_BVZERO( &bsi->bsi_attrs[ 0 ].an_name );
-               
-               for ( p = attrs; !BER_BVISNULL( &p->an_name ); p++ ) {
-                       /*
-                        * ignore "1.1"; handle "+"
-                        */
-                       if ( BACKSQL_NCMP( &p->an_name, &AllUser ) == 0 ) {
-                               bsi->bsi_flags |= BSQL_SF_ALL_USER;
-                               continue;
+               } else if ( BACKSQL_FETCH_ALL_OPATTRS( bi ) ) {
+                       bsi->bsi_flags |= BSQL_SF_ALL_OPER;
+               }
 
-                       } else if ( BACKSQL_NCMP( &p->an_name, &AllOper ) == 0 ) {
-                               bsi->bsi_flags |= BSQL_SF_ALL_OPER;
-                               continue;
+               if ( attrs == NULL ) {
+                       /* NULL means all user attributes */
+                       bsi->bsi_flags |= BSQL_SF_ALL_USER;
 
-                       } else if ( BACKSQL_NCMP( &p->an_name, &NoAttrs ) == 0 ) {
-                               continue;
+               } else {
+                       AttributeName   *p;
+                       int             got_oc = 0;
 
-                       } else if ( p->an_desc == slap_schema.si_ad_objectClass ) {
-                               got_oc = 1;
+                       bsi->bsi_attrs = (AttributeName *)bsi->bsi_op->o_tmpalloc(
+                                       sizeof( AttributeName ),
+                                       bsi->bsi_op->o_tmpmemctx );
+                       BER_BVZERO( &bsi->bsi_attrs[ 0 ].an_name );
+       
+                       for ( p = attrs; !BER_BVISNULL( &p->an_name ); p++ ) {
+                               if ( BACKSQL_NCMP( &p->an_name, &AllUser ) == 0 ) {
+                                       /* handle "*" */
+                                       bsi->bsi_flags |= BSQL_SF_ALL_USER;
+
+                                       /* if all attrs are requested, there's
+                                        * no need to continue */
+                                       if ( BSQL_ISF_ALL_ATTRS( bsi ) ) {
+                                               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs,
+                                                               bsi->bsi_op->o_tmpmemctx );
+                                               bsi->bsi_attrs = NULL;
+                                               break;
+                                       }
+                                       continue;
+
+                               } else if ( BACKSQL_NCMP( &p->an_name, &AllOper ) == 0 ) {
+                                       /* handle "+" */
+                                       bsi->bsi_flags |= BSQL_SF_ALL_OPER;
+
+                                       /* if all attrs are requested, there's
+                                        * no need to continue */
+                                       if ( BSQL_ISF_ALL_ATTRS( bsi ) ) {
+                                               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs,
+                                                               bsi->bsi_op->o_tmpmemctx );
+                                               bsi->bsi_attrs = NULL;
+                                               break;
+                                       }
+                                       continue;
+
+                               } else if ( BACKSQL_NCMP( &p->an_name, &NoAttrs ) == 0 ) {
+                                       /* ignore "1.1" */
+                                       continue;
+
+                               } else if ( p->an_desc == slap_schema.si_ad_objectClass ) {
+                                       got_oc = 1;
+                               }
+
+                               backsql_attrlist_add( bsi, p->an_desc );
                        }
 
-                       backsql_attrlist_add( bsi, p->an_desc );
+                       if ( got_oc == 0 && !( bsi->bsi_flags & BSQL_SF_ALL_USER ) ) {
+                               /* add objectClass if not present,
+                                * because it is required to understand
+                                * if an entry is a referral, an alias 
+                                * or so... */
+                               backsql_attrlist_add( bsi, slap_schema.si_ad_objectClass );
+                       }
                }
 
-               if ( got_oc == 0 ) {
-                       /* add objectClass if not present,
-                        * because it is required to understand
-                        * if an entry is a referral, an alias 
-                        * or so... */
-                       backsql_attrlist_add( bsi, slap_schema.si_ad_objectClass );
+               if ( !BSQL_ISF_ALL_ATTRS( bsi ) && bi->sql_anlist ) {
+                       AttributeName   *p;
+                       
+                       /* use hints if available */
+                       for ( p = bi->sql_anlist; !BER_BVISNULL( &p->an_name ); p++ ) {
+                               if ( BACKSQL_NCMP( &p->an_name, &AllUser ) == 0 ) {
+                                       /* handle "*" */
+                                       bsi->bsi_flags |= BSQL_SF_ALL_USER;
+
+                                       /* if all attrs are requested, there's
+                                        * no need to continue */
+                                       if ( BSQL_ISF_ALL_ATTRS( bsi ) ) {
+                                               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs,
+                                                               bsi->bsi_op->o_tmpmemctx );
+                                               bsi->bsi_attrs = NULL;
+                                               break;
+                                       }
+                                       continue;
+
+                               } else if ( BACKSQL_NCMP( &p->an_name, &AllOper ) == 0 ) {
+                                       /* handle "+" */
+                                       bsi->bsi_flags |= BSQL_SF_ALL_OPER;
+
+                                       /* if all attrs are requested, there's
+                                        * no need to continue */
+                                       if ( BSQL_ISF_ALL_ATTRS( bsi ) ) {
+                                               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs,
+                                                               bsi->bsi_op->o_tmpmemctx );
+                                               bsi->bsi_attrs = NULL;
+                                               break;
+                                       }
+                                       continue;
+                               }
+
+                               backsql_attrlist_add( bsi, p->an_desc );
+                       }
+
                }
        }
 
@@ -191,14 +268,77 @@ backsql_init_search(
        bsi->bsi_flt_where.bb_len = 0;
        bsi->bsi_filter_oc = NULL;
 
-       if ( flags & BACKSQL_ISF_GET_ID ) {
+       if ( BACKSQL_IS_GET_ID( flags ) ) {
+               int     matched = BACKSQL_IS_MATCHED( flags );
+               int     getentry = BACKSQL_IS_GET_ENTRY( flags );
+               int     gotit = 0;
+
                assert( op->o_bd->be_private );
 
-               rc = backsql_dn2id( op, rs, &bsi->bsi_base_id, dbh, nbase,
-                               ( flags & BACKSQL_ISF_MUCK ) );
+               rc = backsql_dn2id( op, rs, dbh, nbase, &bsi->bsi_base_id,
+                               matched, 1 );
+
+               /* the entry is collected either if requested for by getentry
+                * or if get noSuchObject and requested to climb the tree,
+                * so that a matchedDN or a referral can be returned */
+               if ( ( rc == LDAP_NO_SUCH_OBJECT && matched ) || getentry ) {
+                       if ( !BER_BVISNULL( &bsi->bsi_base_id.eid_ndn ) ) {
+                               assert( bsi->bsi_e != NULL );
+                               
+                               if ( dn_match( nbase, &bsi->bsi_base_id.eid_ndn ) )
+                               {
+                                       gotit = 1;
+                               }
+                       
+                               /*
+                                * let's see if it is a referral and, in case, get it
+                                */
+                               backsql_attrlist_add( bsi, slap_schema.si_ad_ref );
+                               rc = backsql_id2entry( bsi, &bsi->bsi_base_id );
+                               if ( rc == LDAP_SUCCESS ) {
+                                       if ( is_entry_referral( bsi->bsi_e ) )
+                                       {
+                                               BerVarray erefs = get_entry_referrals( op, bsi->bsi_e );
+                                               if ( erefs ) {
+                                                       rc = rs->sr_err = LDAP_REFERRAL;
+                                                       rs->sr_ref = referral_rewrite( erefs,
+                                                                       &bsi->bsi_e->e_nname,
+                                                                       &op->o_req_dn,
+                                                                       scope );
+                                                       ber_bvarray_free( erefs );
+       
+                                               } else {
+                                                       rc = rs->sr_err = LDAP_OTHER;
+                                                       rs->sr_text = "bad referral object";
+                                               }
+
+                                       } else if ( !gotit ) {
+                                               rc = rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                                       }
+                               }
+
+                       } else {
+                               rs->sr_ref = referral_rewrite( default_referral,
+                                               NULL, &op->o_req_dn, scope );
+                               rc = rs->sr_err = LDAP_REFERRAL;
+                       }
+               }
+       }
+
+       bsi->bsi_status = rc;
+
+       switch ( rc ) {
+       case LDAP_SUCCESS:
+       case LDAP_REFERRAL:
+               break;
+
+       default:
+               bsi->bsi_op->o_tmpfree( bsi->bsi_attrs,
+                               bsi->bsi_op->o_tmpmemctx );
+               break;
        }
 
-       return ( bsi->bsi_status = rc );
+       return rc;
 }
 
 static int
@@ -261,15 +401,17 @@ backsql_process_sub_filter( backsql_srch_info *bsi, Filter *f,
 
        /* always uppercase strings by now */
 #ifdef BACKSQL_UPPERCASE_FILTER
-       if ( SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr,
-                       bi->sql_caseIgnoreMatch ) )
+       if ( f->f_sub_desc->ad_type->sat_substr &&
+                       SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr,
+                               bi->sql_caseIgnoreMatch ) )
 #endif /* BACKSQL_UPPERCASE_FILTER */
        {
                casefold = 1;
        }
 
-       if ( SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr,
-                       bi->sql_telephoneNumberMatch ) )
+       if ( f->f_sub_desc->ad_type->sat_substr &&
+                       SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr,
+                               bi->sql_telephoneNumberMatch ) )
        {
 
                struct berval   bv;
@@ -598,11 +740,11 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                                backsql_merge_from_tbls( bsi, &ldap_entry_objclasses );
 
                                backsql_strfcat( &bsi->bsi_flt_where, "lbl",
-                                               (ber_len_t)STRLENOF( "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */ ),
-                                                       "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */,
+                                               (ber_len_t)STRLENOF( "(2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ')) */ ),
+                                                       "(2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ')) */,
                                                &bsi->bsi_oc->bom_oc->soc_cname,
-                                               (ber_len_t)STRLENOF( /* (' */ "')" ),
-                                                       /* (' */ "')" );
+                                               (ber_len_t)STRLENOF( /* ((' */ "'))" ),
+                                                       /* ((' */ "'))" );
                                bsi->bsi_status = LDAP_SUCCESS;
                                rc = 1;
                                goto done;
@@ -613,7 +755,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
 
                case LDAP_FILTER_PRESENT:
                        backsql_strfcat( &bsi->bsi_flt_where, "l",
-                                       (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                                       (ber_len_t)STRLENOF( "3=3" ), "3=3" );
                        bsi->bsi_status = LDAP_SUCCESS;
                        rc = 1;
                        goto done;
@@ -666,7 +808,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
 
                case LDAP_FILTER_PRESENT:
                        backsql_strfcat( &bsi->bsi_flt_where, "l",
-                                       (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                                       (ber_len_t)STRLENOF( "4=4" ), "4=4" );
                        break;
 
                default:
@@ -681,8 +823,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
 #ifdef BACKSQL_SYNCPROV
        } else if ( ad == slap_schema.si_ad_entryCSN ) {
                /*
-                * TODO: introduce appropriate entryCSN filtering
-                * to support syncrepl as producer...
+                * support for syncrepl as producer...
                 */
                if ( !bsi->bsi_op->o_sync ) {
                        /* unsupported at present... */
@@ -696,7 +837,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                /* if doing a syncrepl, try to return as much as possible,
                 * and always match the filter */
                backsql_strfcat( &bsi->bsi_flt_where, "l",
-                               (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                               (ber_len_t)STRLENOF( "5=5" ), "5=5" );
 
                /* save for later use in operational attributes */
                /* FIXME: saves only the first occurrence, because 
@@ -730,7 +871,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                 * candidate.
                 */
                backsql_strfcat( &bsi->bsi_flt_where, "l",
-                               (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                               (ber_len_t)STRLENOF( "6=6" ), "6=6" );
                if ( ad == slap_schema.si_ad_hasSubordinates ) {
                        /*
                         * instruct candidate selection algorithm
@@ -763,7 +904,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                /* search anyway; other parts of the filter
                 * may succeeed */
                backsql_strfcat( &bsi->bsi_flt_where, "l",
-                               (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                               (ber_len_t)STRLENOF( "7=7" ), "7=7" );
                bsi->bsi_status = LDAP_SUCCESS;
                rc = 1;
                goto done;
@@ -953,6 +1094,10 @@ equality_match:;
                        casefold = 1;
                }
 
+               /* FIXME: directoryString filtering should use a similar
+                * approach to deal with non-prettified values like
+                * " A  non    prettified   value  ", by using a LIKE
+                * filter with all whitespaces collapsed to a single '%' */
                if ( SLAP_MR_ASSOCIATED( matching_rule,
                                        bi->sql_telephoneNumberMatch ) )
                {
@@ -1015,10 +1160,13 @@ equality_match:;
                /* fall thru to next case */
                
        case LDAP_FILTER_LE:
+               filter_value = &f->f_av_value;
+               
                /* always uppercase strings by now */
 #ifdef BACKSQL_UPPERCASE_FILTER
-               if ( SLAP_MR_ASSOCIATED( at->bam_ad->ad_type->sat_ordering,
-                               bi->sql_caseIgnoreMatch ) )
+               if ( at->bam_ad->ad_type->sat_ordering &&
+                               SLAP_MR_ASSOCIATED( at->bam_ad->ad_type->sat_ordering,
+                                       bi->sql_caseIgnoreMatch ) )
 #endif /* BACKSQL_UPPERCASE_FILTER */
                {
                        casefold = 1;
@@ -1086,7 +1234,7 @@ equality_match:;
                /* unhandled filter type; should not happen */
                assert( 0 );
                backsql_strfcat( &bsi->bsi_flt_where, "l",
-                               (ber_len_t)STRLENOF( "1=1" ), "1=1" );
+                               (ber_len_t)STRLENOF( "8=8" ), "8=8" );
                break;
 
        }
@@ -1106,6 +1254,8 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
        assert( query );
        BER_BVZERO( query );
 
+       bsi->bsi_use_subtree_shortcut = 0;
+
        Debug( LDAP_DEBUG_TRACE, "==>backsql_srch_query()\n", 0, 0, 0 );
        BER_BVZERO( &bsi->bsi_sel.bb_val );
        BER_BVZERO( &bsi->bsi_sel.bb_val );
@@ -1205,11 +1355,40 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
        case LDAP_SCOPE_SUBORDINATE:
 #endif /* LDAP_SCOPE_SUBORDINATE */
        case LDAP_SCOPE_SUBTREE:
-               if ( BACKSQL_CANUPPERCASE( bi ) ) {
+               if ( BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ) {
+                       int             i;
+                       BackendDB       *bd = bsi->bsi_op->o_bd;
+
+                       assert( bd->be_nsuffix );
+
+                       for ( i = 0; !BER_BVISNULL( &bd->be_nsuffix[ i ] ); i++ )
+                       {
+                               if ( dn_match( &bd->be_nsuffix[ i ],
+                                                       bsi->bsi_base_ndn ) )
+                               {
+                                       /* pass this to the candidate selection
+                                        * routine so that the DN is not bound
+                                        * to the select statement */
+                                       bsi->bsi_use_subtree_shortcut = 1;
+                                       break;
+                               }
+                       }
+               }
+
+               if ( bsi->bsi_use_subtree_shortcut ) {
+                       /* Skip the base DN filter, as every entry will match it */
+                       backsql_strfcat( &bsi->bsi_join_where, "l",
+                                       (ber_len_t)STRLENOF( "9=9"), "9=9");
+
+               } else if ( !BER_BVISNULL( &bi->sql_subtree_cond ) ) {
+                       backsql_strfcat( &bsi->bsi_join_where, "b", &bi->sql_subtree_cond );
+
+               } else if ( BACKSQL_CANUPPERCASE( bi ) ) {
                        backsql_strfcat( &bsi->bsi_join_where, "bl",
                                        &bi->sql_upper_func,
                                        (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE ?" ),
                                                "(ldap_entries.dn) LIKE ?"  );
+
                } else {
                        backsql_strfcat( &bsi->bsi_join_where, "l",
                                        (ber_len_t)STRLENOF( "ldap_entries.dn LIKE ?" ),
@@ -1268,9 +1447,10 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
 {
        backsql_oc_map_rec      *oc = v_oc;
        backsql_srch_info       *bsi = v_bsi;
+       Operation               *op = bsi->bsi_op;
        backsql_info            *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
        struct berval           query;
-       SQLHSTMT                sth;
+       SQLHSTMT                sth = SQL_NULL_HSTMT;
        RETCODE                 rc;
        int                     res;
        BACKSQL_ROW_NTS         row;
@@ -1402,6 +1582,12 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
 #endif /* LDAP_SCOPE_SUBORDINATE */
        case LDAP_SCOPE_SUBTREE:
        {
+               /* if short-cutting the search base,
+                * don't bind any parameter */
+               if ( bsi->bsi_use_subtree_shortcut ) {
+                       break;
+               }
+               
                /*
                 * We do not accept DNs longer than BACKSQL_MAX_DN_LEN;
                 * however this should be handled earlier
@@ -1531,7 +1717,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                        continue;
                }
 
-               ret = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
+               ret = dnPrettyNormal( NULL, &dn, &pdn, &ndn, op->o_tmpmemctx );
                if ( dn.bv_val != row.cols[ 3 ] ) {
                        free( dn.bv_val );
                }
@@ -1541,16 +1727,18 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                }
 
                if ( bi->sql_baseObject && dn_match( &ndn, &bi->sql_baseObject->e_nname ) ) {
-                       free( pdn.bv_val );
-                       free( ndn.bv_val );
+                       op->o_tmpfree( pdn.bv_val, op->o_tmpmemctx );
+                       op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
                        continue;
                }
 
                c_id = (backsql_entryID *)ch_calloc( 1, 
                                sizeof( backsql_entryID ) );
 #ifdef BACKSQL_ARBITRARY_KEY
-               ber_str2bv( row.cols[ 0 ], 0, 1, &c_id->eid_id );
-               ber_str2bv( row.cols[ 1 ], 0, 1, &c_id->eid_keyval );
+               ber_str2bv_x( row.cols[ 0 ], 0, 1, &c_id->eid_id,
+                               op->o_tmpmemctx );
+               ber_str2bv_x( row.cols[ 1 ], 0, 1, &c_id->eid_keyval,
+                               op->o_tmpmemctx );
 #else /* ! BACKSQL_ARBITRARY_KEY */
                c_id->eid_id = strtol( row.cols[ 0 ], NULL, 0 );
                c_id->eid_keyval = strtol( row.cols[ 1 ], NULL, 0 );
@@ -1595,22 +1783,20 @@ int
 backsql_search( Operation *op, SlapReply *rs )
 {
        backsql_info            *bi = (backsql_info *)op->o_bd->be_private;
-       SQLHDBC                 dbh;
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
        int                     sres;
-       Entry                   user_entry = { 0 };
-       int                     manageDSAit;
+       Entry                   user_entry = { 0 },
+                               base_entry = { 0 };
+       int                     manageDSAit = get_manageDSAit( op );
        time_t                  stoptime = 0;
-       backsql_srch_info       bsi;
+       backsql_srch_info       bsi = { 0 };
        backsql_entryID         *eid = NULL;
-       struct berval           nbase = BER_BVNULL,
-                               realndn = BER_BVNULL;
-
-       manageDSAit = get_manageDSAit( op );
+       struct berval           nbase = BER_BVNULL;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
                "base=\"%s\", filter=\"%s\", scope=%d,", 
                op->o_req_ndn.bv_val,
-               op->ors_filterstr.bv_val,
+               op->ors_filterstr.bv_val ? op->ors_filterstr.bv_val : "(no filter)",
                op->ors_scope );
        Debug( LDAP_DEBUG_TRACE, " deref=%d, attrsonly=%d, "
                "attributes to load: %s\n",
@@ -1646,28 +1832,88 @@ backsql_search( Operation *op, SlapReply *rs )
        /* compute it anyway; root does not use it */
        stoptime = op->o_time + op->ors_tlimit;
 
-       realndn = op->o_req_ndn;
-       if ( backsql_api_dn2odbc( op, rs, &realndn ) ) {
-               Debug( LDAP_DEBUG_TRACE, "   backsql_search(\"%s\"): "
-                       "backsql_api_dn2odbc(\"%s\") failed\n", 
-                       op->o_req_ndn.bv_val, realndn.bv_val, 0 );
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
-               send_ldap_result( op, rs );
-               goto done;
-       }
-
        /* init search */
-       rs->sr_err = backsql_init_search( &bsi, &realndn,
+       bsi.bsi_e = &base_entry;
+       rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn,
                        op->ors_scope,
                        op->ors_slimit, op->ors_tlimit,
                        stoptime, op->ors_filter,
                        dbh, op, rs, op->ors_attrs,
-                       ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+       switch ( rs->sr_err ) {
+       case LDAP_SUCCESS:
+               break;
+
+       case LDAP_REFERRAL:
+               if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+                               dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       rs->sr_text = NULL;
+                       rs->sr_matched = NULL;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       break;
+               }
+               /* fall thru */
+
+       default:
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+               if ( !BER_BVISNULL( &base_entry.e_nname )
+                               && ! access_allowed( op, &base_entry,
+                                       slap_schema.si_ad_entry, NULL,
+                                       ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                       if ( rs->sr_ref ) {
+                               ber_bvarray_free( rs->sr_ref );
+                               rs->sr_ref = NULL;
+                       }
+                       rs->sr_matched = NULL;
+                       rs->sr_text = NULL;
+               }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
                send_ldap_result( op, rs );
                goto done;
+
+       }
+#ifdef SLAP_ACL_HONOR_DISCLOSE
+       /* NOTE: __NEW__ "search" access is required
+        * on searchBase object */
+       {
+               slap_mask_t     mask;
+               
+               if ( get_assert( op ) &&
+                               ( test_filter( op, &base_entry, get_assertion( op ) )
+                                 != LDAP_COMPARE_TRUE ) )
+               {
+                       rs->sr_err = LDAP_ASSERTION_FAILED;
+                       
+               }
+               if ( ! access_allowed_mask( op, &base_entry,
+                                       slap_schema.si_ad_entry,
+                                       NULL, ACL_SEARCH, NULL, &mask ) )
+               {
+                       if ( rs->sr_err == LDAP_SUCCESS ) {
+                               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+                       }
+               }
+
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       if ( !ACL_GRANT( mask, ACL_DISCLOSE ) ) {
+                               rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                               rs->sr_text = NULL;
+                       }
+                       send_ldap_result( op, rs );
+                       goto done;
+               }
        }
+#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
+       bsi.bsi_e = NULL;
 
        bsi.bsi_n_candidates =
                ( op->ors_limit == NULL /* isroot == TRUE */ ? -2 : 
@@ -1723,7 +1969,8 @@ backsql_search( Operation *op, SlapReply *rs )
         */
        for ( eid = bsi.bsi_id_list;
                        eid != NULL; 
-                       eid = backsql_free_entryID( eid, eid == &bsi.bsi_base_id ? 0 : 1 ) )
+                       eid = backsql_free_entryID( op,
+                               eid, eid == &bsi.bsi_base_id ? 0 : 1 ) )
        {
                int             rc;
                Attribute       *a_hasSubordinate = NULL,
@@ -1793,15 +2040,20 @@ backsql_search( Operation *op, SlapReply *rs )
                case LDAP_SCOPE_SUBTREE:
                        /* FIXME: this should never fail... */
                        if ( !dnIsSuffix( &eid->eid_ndn, &op->o_req_ndn ) ) {
+                               assert( 0 );
                                goto next_entry2;
                        }
                        break;
                }
 
-               /* don't recollect baseObject ... */
                if ( BACKSQL_IS_BASEOBJECT_ID( &eid->eid_id ) ) {
+                       /* don't recollect baseObject... */
                        e = bi->sql_baseObject;
 
+               } else if ( eid == &bsi.bsi_base_id ) {
+                       /* don't recollect searchBase object... */
+                       e = &base_entry;
+
                } else {
                        bsi.bsi_e = &user_entry;
                        rc = backsql_id2entry( &bsi, eid );
@@ -1811,7 +2063,6 @@ backsql_search( Operation *op, SlapReply *rs )
                                        "- skipping\n", rc, 0, 0 );
                                continue;
                        }
-
                        e = &user_entry;
                }
 
@@ -1828,22 +2079,28 @@ backsql_search( Operation *op, SlapReply *rs )
                                Entry                   user_entry2 = { 0 };
 
                                /* retry with the full entry... */
-                               (void)backsql_init_search( &bsi2,
+                               bsi2.bsi_e = &user_entry2;
+                               rc = backsql_init_search( &bsi2,
                                                &e->e_nname,
                                                LDAP_SCOPE_BASE, 
-                                               -1, -1, -1, NULL,
+                                               SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                                               (time_t)(-1), NULL,
                                                dbh, op, rs, NULL,
-                                               BACKSQL_ISF_MUCK );
-                               bsi2.bsi_e = &user_entry2;
-                               rc = backsql_id2entry( &bsi2, eid );
+                                               BACKSQL_ISF_GET_ENTRY );
                                if ( rc == LDAP_SUCCESS ) {
                                        if ( is_entry_referral( &user_entry2 ) )
                                        {
                                                refs = get_entry_referrals( op,
                                                                &user_entry2 );
-                                       } /* else: FIXME: inconsistency! */
+                                       } else {
+                                               rs->sr_err = LDAP_OTHER;
+                                       }
                                        entry_clean( &user_entry2 );
                                }
+                               if ( bsi2.bsi_attrs != NULL ) {
+                                       op->o_tmpfree( bsi2.bsi_attrs,
+                                                       op->o_tmpmemctx );
+                               }
                        }
 
                        if ( refs ) {
@@ -1854,12 +2111,14 @@ backsql_search( Operation *op, SlapReply *rs )
                                ber_bvarray_free( refs );
                        }
 
-                       if ( !rs->sr_ref ) {
-                               rs->sr_text = "bad_referral object";
+                       if ( rs->sr_ref ) {
+                               rs->sr_err = LDAP_REFERRAL;
+
+                       } else {
+                               rs->sr_text = "bad referral object";
                        }
 
                        rs->sr_entry = e;
-                       rs->sr_err = LDAP_REFERRAL;
                        rs->sr_matched = user_entry.e_name.bv_val;
                        send_search_reference( op, rs );
 
@@ -1939,21 +2198,17 @@ backsql_search( Operation *op, SlapReply *rs )
                        if ( e == &user_entry ) {
                                rs->sr_flags = REP_ENTRY_MODIFIABLE;
                        }
+                       /* FIXME: need the whole entry (ITS#3480) */
                        sres = send_search_entry( op, rs );
                        rs->sr_entry = NULL;
                        rs->sr_attrs = NULL;
                        rs->sr_operational_attrs = NULL;
 
-                       switch ( sres ) {
-                       case 0:
-                               break;
-
-                       default:
+                       if ( sres == -1 ) {
                                /*
                                 * FIXME: send_search_entry failed;
                                 * better stop
                                 */
-                       case -1:
                                Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
                                        "connection lost\n", 0, 0, 0 );
                                goto end_of_search;
@@ -1961,7 +2216,9 @@ backsql_search( Operation *op, SlapReply *rs )
                }
 
 next_entry:;
-               entry_clean( &user_entry );
+               if ( e == &user_entry ) {
+                       entry_clean( &user_entry );
+               }
 
 next_entry2:;
                if ( op->ors_slimit != SLAP_NO_LIMIT
@@ -1974,6 +2231,8 @@ next_entry2:;
        }
 
 end_of_search:;
+       entry_clean( &base_entry );
+
        /* in case we got here accidentally */
        entry_clean( &user_entry );
 
@@ -2014,16 +2273,10 @@ end_of_search:;
 #endif /* BACKSQL_SYNCPROV */
 
 done:;
-       if ( !BER_BVISNULL( &realndn ) && realndn.bv_val != op->o_req_ndn.bv_val ) {
-               ch_free( realndn.bv_val );
-       }
-
-       if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
-       }
+       (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
 
-       if ( bsi.bsi_attrs ) {
-               ch_free( bsi.bsi_attrs );
+       if ( bsi.bsi_attrs != NULL ) {
+               op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
        }
 
        if ( !BER_BVISNULL( &nbase )
@@ -2053,12 +2306,14 @@ backsql_entry_get(
                int                     rw,
                Entry                   **ent )
 {
-       backsql_srch_info       bsi;
-       SQLHDBC                 dbh;
+       backsql_srch_info       bsi = { 0 };
+       SQLHDBC                 dbh = SQL_NULL_HDBC;
        int                     rc;
        SlapReply               rs = { 0 };
        AttributeName           anlist[ 2 ];
 
+       *ent = NULL;
+
        rc = backsql_get_db_conn( op, &dbh );
        if ( !dbh ) {
                return LDAP_OTHER;
@@ -2070,21 +2325,17 @@ backsql_entry_get(
                BER_BVZERO( &anlist[ 1 ].an_name );
        }
 
+       bsi.bsi_e = ch_malloc( sizeof( Entry ) );
        rc = backsql_init_search( &bsi,
                        ndn,
                        LDAP_SCOPE_BASE, 
-                       SLAP_NO_LIMIT, SLAP_NO_LIMIT, -1, NULL,
+                       SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+                       (time_t)(-1), NULL,
                        dbh, op, &rs, at ? anlist : NULL,
-                       ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
-       if ( rc != LDAP_SUCCESS ) {
-               return rc;
-       }
-
-       bsi.bsi_e = ch_malloc( sizeof( Entry ) );
-       rc = backsql_id2entry( &bsi, &bsi.bsi_base_id );
+                       BACKSQL_ISF_GET_ENTRY );
 
        if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
        }
 
        if ( rc == LDAP_SUCCESS ) {
@@ -2121,6 +2372,10 @@ backsql_entry_get(
        }
 
 return_results:;
+       if ( bsi.bsi_attrs != NULL ) {
+               op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
+       }
+
        if ( rc != LDAP_SUCCESS ) {
                if ( bsi.bsi_e ) {
                        entry_free( bsi.bsi_e );
diff --git a/servers/slapd/back-sql/sql-types.h b/servers/slapd/back-sql/sql-types.h
deleted file mode 100644 (file)
index b7a109f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2004 The OpenLDAP Foundation.
- * Portions Copyright 1999 Dmitry Kovalev.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
- */
-#ifndef __BACKSQL_SQL_TYPES_H__
-#define __BACKSQL_SQL_TYPES_H__
-
-#include <sql.h>
-#include <sqlext.h>
-
-typedef struct {
-       SWORD           ncols;
-       BerVarray       col_names;
-       UDWORD          *col_prec;
-       char            **cols;
-       SQLINTEGER      *value_len;
-} BACKSQL_ROW_NTS;
-
-#endif /* __BACKSQL_SQL_TYPES_H__ */
-
index d5da0886a9977acd3b2809ba80bbb0e9988bceab..13d715395ffc1b2f510270b1d3d9eef695fb1cee 100644 (file)
@@ -1,8 +1,10 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
+ * Portions Copyright 2004 Mark Adamson.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +17,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati and Mark Adamson.
  */
 
 #include "portable.h"
@@ -58,8 +61,6 @@ RETCODE
 backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout )
 {
        RETCODE         rc;
-       char            drv_name[ 30 ];
-       SWORD           len;
 
        rc = SQLAllocStmt( dbh, sth );
        if ( rc != SQL_SUCCESS ) {
@@ -70,36 +71,43 @@ backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout )
        Debug( LDAP_DEBUG_TRACE, "==>backsql_Prepare()\n", 0, 0, 0 );
 #endif /* BACKSQL_TRACE */
 
-       SQLGetInfo( dbh, SQL_DRIVER_NAME, drv_name, sizeof( drv_name ), &len );
+#ifdef BACKSQL_MSSQL_WORKAROUND
+       {
+               char            drv_name[ 30 ];
+               SWORD           len;
+
+               SQLGetInfo( dbh, SQL_DRIVER_NAME, drv_name, sizeof( drv_name ), &len );
 
 #ifdef BACKSQL_TRACE
-       Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name=\"%s\"\n",
-                       drv_name, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name=\"%s\"\n",
+                               drv_name, 0, 0 );
 #endif /* BACKSQL_TRACE */
 
-       ldap_pvt_str2upper( drv_name );
-       if ( !strncmp( drv_name, "SQLSRV32.DLL", sizeof( drv_name ) ) ) {
-               /*
-                * stupid default result set in MS SQL Server
-                * does not support multiple active statements
-                * on the same connection -- so we are trying 
-                * to make it not to use default result set...
-                */
-               Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "
-                       "enabling MS SQL Server default result "
-                       "set workaround\n", 0, 0, 0 );
-               rc = SQLSetStmtOption( *sth, SQL_CONCURRENCY, 
-                               SQL_CONCUR_ROWVER );
-               if ( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
-                       Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): "
-                               "SQLSetStmtOption(SQL_CONCURRENCY,"
-                               "SQL_CONCUR_ROWVER) failed:\n", 
-                               0, 0, 0 );
-                       backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc );
-                       SQLFreeStmt( *sth, SQL_DROP );
-                       return rc;
+               ldap_pvt_str2upper( drv_name );
+               if ( !strncmp( drv_name, "SQLSRV32.DLL", STRLENOF( "SQLSRV32.DLL" ) ) ) {
+                       /*
+                        * stupid default result set in MS SQL Server
+                        * does not support multiple active statements
+                        * on the same connection -- so we are trying 
+                        * to make it not to use default result set...
+                        */
+                       Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "
+                               "enabling MS SQL Server default result "
+                               "set workaround\n", 0, 0, 0 );
+                       rc = SQLSetStmtOption( *sth, SQL_CONCURRENCY, 
+                                       SQL_CONCUR_ROWVER );
+                       if ( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
+                               Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): "
+                                       "SQLSetStmtOption(SQL_CONCURRENCY,"
+                                       "SQL_CONCUR_ROWVER) failed:\n", 
+                                       0, 0, 0 );
+                               backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc );
+                               SQLFreeStmt( *sth, SQL_DROP );
+                               return rc;
+                       }
                }
        }
+#endif /* BACKSQL_MSSQL_WORKAROUND */
 
        if ( timeout > 0 ) {
                Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "
index cc4f6ded4ce64a47cfd13303c4107921fc052f07..641abc7eb1829c74708d386396057164c981eda8 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -45,13 +47,13 @@ char backsql_def_at_query[] =
        "SELECT name,sel_expr,from_tbls,join_where,add_proc,delete_proc,"
        "param_order,expect_return,sel_expr_u FROM ldap_attr_mappings "
        "WHERE oc_map_id=?";
-char backsql_def_delentry_query[] = "DELETE FROM ldap_entries WHERE id=?";
-char backsql_def_insentry_query[] = 
+char backsql_def_delentry_stmt[] = "DELETE FROM ldap_entries WHERE id=?";
+char backsql_def_renentry_stmt[] =
+       "UPDATE ldap_entries SET dn=?,parent=?,keyval=? WHERE id=?";
+char backsql_def_insentry_stmt[] = 
        "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) "
        "VALUES (?,?,?,?)";
-char backsql_def_delobjclasses_query[] = "DELETE FROM ldap_entry_objclasses "
-       "WHERE entry_id=?";
-char backsql_def_delreferrals_query[] = "DELETE FROM ldap_referrals "
+char backsql_def_delobjclasses_stmt[] = "DELETE FROM ldap_entry_objclasses "
        "WHERE entry_id=?";
 char backsql_def_subtree_cond[] = "ldap_entries.dn LIKE CONCAT('%',?)";
 char backsql_def_upper_subtree_cond[] = "(ldap_entries.dn) LIKE CONCAT('%',?)";
@@ -243,44 +245,33 @@ backsql_strfcat( struct berbuf *dest, const char *fmt, ... )
 
 int
 backsql_entry_addattr(
-       Entry           *e,
-       struct berval   *at_name,
-       struct berval   *at_val,
-       void            *memctx )
+       Entry                   *e,
+       AttributeDescription    *ad,
+       struct berval           *val,
+       void                    *memctx )
 {
-       AttributeDescription    *ad;
        int                     rc;
-       const char              *text;
 
 #ifdef BACKSQL_TRACE
-       Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
-               "at_name=\"%s\", at_val=\"%s\"\n", 
-               at_name->bv_val, at_val->bv_val, 0 );
+       Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(\"%s\"): %s=%s\n", 
+               e->e_name.bv_val, ad->ad_cname->bv_val, val->bv_val );
 #endif /* BACKSQL_TRACE */
 
-       ad = NULL;
-       rc = slap_bv2ad( at_name, &ad, &text );
-       if ( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
-                       "failed to find AttributeDescription for \"%s\"\n",
-                       at_name->bv_val, 0, 0 );
-               return 0;
-       }
-
-       rc = attr_merge_normalize_one( e, ad, at_val, memctx );
+       rc = attr_merge_normalize_one( e, ad, val, memctx );
 
-       if ( rc != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
+       if ( rc != LDAP_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(\"%s\"): "
                        "failed to merge value \"%s\" for attribute \"%s\"\n",
-                       at_val->bv_val, at_name->bv_val, 0 );
-               return 0;
+                       e->e_name.bv_val, val->bv_val, ad->ad_cname.bv_val );
+               return rc;
        }
 
 #ifdef BACKSQL_TRACE
-       Debug( LDAP_DEBUG_TRACE, "<==backsql_query_addattr()\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "<==backsql_entry_addattr(\"%s\")\n",
+               e->e_name.bv_val, 0, 0 );
 #endif /* BACKSQL_TRACE */
 
-       return 1;
+       return LDAP_SUCCESS;
 }
 
 static char *
@@ -531,7 +522,7 @@ backsql_entryUUID(
        snprintf( uuidbuf, sizeof( uuidbuf ),
                        "%08x-%04x-%04x-0000-000000000000",
                        ( id->eid_oc_id & 0xFFFFFFFF ),
-                       ( ( id->eid_keyval & 0xFFFF0000 ) >> 16 ),
+                       ( ( id->eid_keyval & 0xFFFF0000 ) >> 020 /* 16 */ ),
                        ( id->eid_keyval & 0xFFFF ) );
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
@@ -556,16 +547,17 @@ backsql_entryUUID_decode(
 {
        fprintf( stderr, "==> backsql_entryUUID_decode()\n" );
 
-       *oc_id = ( entryUUID->bv_val[0] << 3 )
-               + ( entryUUID->bv_val[1] << 2 )
-               + ( entryUUID->bv_val[2] << 1 )
+       *oc_id = ( entryUUID->bv_val[0] << 030 /* 24 */ )
+               + ( entryUUID->bv_val[1] << 020 /* 16 */ )
+               + ( entryUUID->bv_val[2] << 010 /* 8 */ )
                + entryUUID->bv_val[3];
 
 #ifdef BACKSQL_ARBITRARY_KEY
+       /* FIXME */
 #else /* ! BACKSQL_ARBITRARY_KEY */
-       *keyval = ( entryUUID->bv_val[4] << 3 )
-               + ( entryUUID->bv_val[5] << 2 )
-               + ( entryUUID->bv_val[6] << 1 )
+       *keyval = ( entryUUID->bv_val[4] << 030 /* 24 */ )
+               + ( entryUUID->bv_val[5] << 020 /* 16 */ )
+               + ( entryUUID->bv_val[6] << 010 /* 8 */ )
                + entryUUID->bv_val[7];
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
index bbacf69e06444c844984dac771d0d696e196d102..9e63b862d1f60998b98233228bbaa422c6ef34ae 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,19 +56,6 @@ static void call_group_postop_plugins( Operation *op );
  * imported into slapd without appropriate __declspec(dllimport) directives.
  */
 
-/*
- * This file is automatically generated by configure; it defines
- * the BackendInfo binfo[] structure with the configured static 
- * backend info.  It assumes that every backend of type <name> 
- * provides an initialization function
- *
- *     int name_back_initialize( BackendInfo *bi )
- *
- * that populates the rest of the structure.
- */
-
-#include "backend.h"
-
 int                    nBackendInfo = 0;
 BackendInfo            *backendInfo = NULL;
 
@@ -92,25 +79,25 @@ int backend_init(void)
        }
 
        for( ;
-               binfo[nBackendInfo].bi_type != NULL;
+               slap_binfo[nBackendInfo].bi_type != NULL;
                nBackendInfo++ )
        {
-               assert( binfo[nBackendInfo].bi_init );
+               assert( slap_binfo[nBackendInfo].bi_init );
 
-               rc = binfo[nBackendInfo].bi_init( &binfo[nBackendInfo] );
+               rc = slap_binfo[nBackendInfo].bi_init( &slap_binfo[nBackendInfo] );
 
                if(rc != 0) {
                        Debug( LDAP_DEBUG_ANY,
                                "backend_init: initialized for type \"%s\"\n",
-                               binfo[nBackendInfo].bi_type, 0, 0 );
+                               slap_binfo[nBackendInfo].bi_type, 0, 0 );
                        /* destroy those we've already inited */
                        for( nBackendInfo--;
                                nBackendInfo >= 0 ;
                                nBackendInfo-- )
                        { 
-                               if ( binfo[nBackendInfo].bi_destroy ) {
-                                       binfo[nBackendInfo].bi_destroy(
-                                               &binfo[nBackendInfo] );
+                               if ( slap_binfo[nBackendInfo].bi_destroy ) {
+                                       slap_binfo[nBackendInfo].bi_destroy(
+                                               &slap_binfo[nBackendInfo] );
                                }
                        }
                        return rc;
@@ -118,7 +105,7 @@ int backend_init(void)
        }
 
        if ( nBackendInfo > 0) {
-               backendInfo = binfo;
+               backendInfo = slap_binfo;
                return 0;
        }
 
@@ -156,8 +143,8 @@ int backend_add(BackendInfo *aBackendInfo)
        {
                BackendInfo *newBackendInfo = 0;
 
-               /* if backendInfo == binfo no deallocation of old backendInfo */
-               if (backendInfo == binfo) {
+               /* if backendInfo == slap_binfo no deallocation of old backendInfo */
+               if (backendInfo == slap_binfo) {
                        newBackendInfo = ch_calloc(nBackendInfo + 1, sizeof(BackendInfo));
                        AC_MEMCPY(newBackendInfo, backendInfo,
                                sizeof(BackendInfo) * nBackendInfo);
@@ -279,7 +266,7 @@ int backend_startup(Backend *be)
                if ( rc ) return rc;
 
 
-               if ( !LDAP_STAILQ_EMPTY( &backendDB[i].be_syncinfo )) {
+               if ( backendDB[i].be_syncinfo ) {
                        syncinfo_t *si;
 
                        if ( !( backendDB[i].be_search && backendDB[i].be_add &&
@@ -290,7 +277,8 @@ int backend_startup(Backend *be)
                                continue;
                        }
 
-                       LDAP_STAILQ_FOREACH( si, &backendDB[i].be_syncinfo, si_next ) {
+                       {
+                               si = backendDB[i].be_syncinfo;
                                si->si_be = &backendDB[i];
                                init_syncrepl( si );
                                ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
@@ -384,7 +372,6 @@ int backend_destroy(void)
 {
        int i;
        BackendDB *bd;
-       syncinfo_t *si_entry;
        struct slap_csn_entry *csne;
 
        ldap_pvt_thread_pool_destroy( &syncrepl_pool, 1 );
@@ -392,10 +379,8 @@ int backend_destroy(void)
        /* destroy each backend database */
        for( i = 0, bd = backendDB; i < nBackendDB; i++, bd++ ) {
 
-               while ( !LDAP_STAILQ_EMPTY( &bd->be_syncinfo )) {
-                       si_entry = LDAP_STAILQ_FIRST( &bd->be_syncinfo );
-                       LDAP_STAILQ_REMOVE_HEAD( &bd->be_syncinfo, si_next );
-                       syncinfo_free( si_entry );
+               if ( bd->be_syncinfo ) {
+                       syncinfo_free( bd->be_syncinfo );
                }
 
                if ( bd->be_pending_csn_list ) {
@@ -415,9 +400,15 @@ int backend_destroy(void)
                }
                ber_bvarray_free( bd->be_suffix );
                ber_bvarray_free( bd->be_nsuffix );
-               if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
-               if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
-               if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
+               if ( !BER_BVISNULL( &bd->be_rootdn ) ) {
+                       free( bd->be_rootdn.bv_val );
+               }
+               if ( !BER_BVISNULL( &bd->be_rootndn ) ) {
+                       free( bd->be_rootndn.bv_val );
+               }
+               if ( !BER_BVISNULL( &bd->be_rootpw ) ) {
+                       free( bd->be_rootpw.bv_val );
+               }
                acl_destroy( bd->be_acl, frontendDB->be_acl );
        }
        free( backendDB );
@@ -431,7 +422,7 @@ int backend_destroy(void)
        }
 
 #ifdef SLAPD_MODULES
-       if (backendInfo != binfo) {
+       if (backendInfo != slap_binfo) {
           free(backendInfo);
        }
 #endif /* SLAPD_MODULES */
@@ -447,9 +438,15 @@ int backend_destroy(void)
                }
                ber_bvarray_free( bd->be_suffix );
                ber_bvarray_free( bd->be_nsuffix );
-               if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
-               if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
-               if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
+               if ( !BER_BVISNULL( &bd->be_rootdn ) ) {
+                       free( bd->be_rootdn.bv_val );
+               }
+               if ( !BER_BVISNULL( &bd->be_rootndn ) ) {
+                       free( bd->be_rootndn.bv_val );
+               }
+               if ( !BER_BVISNULL( &bd->be_rootpw ) ) {
+                       free( bd->be_rootpw.bv_val );
+               }
                acl_destroy( bd->be_acl, frontendDB->be_acl );
        }
 
@@ -513,8 +510,6 @@ backend_db_init(
        be->be_pcl_mutexp = &be->be_pcl_mutex;
        ldap_pvt_thread_mutex_init( be->be_pcl_mutexp );
 
-       LDAP_STAILQ_INIT( &be->be_syncinfo );
-
        /* assign a default depth limit for alias deref */
        be->be_max_deref_depth = SLAPD_DEFAULT_MAXDEREFDEPTH; 
 
@@ -554,13 +549,16 @@ select_backend(
        int manageDSAit,
        int noSubs )
 {
-       int     i, j;
-       ber_len_t len, dnlen = dn->bv_len;
-       Backend *be = NULL;
+       int             i, j;
+       ber_len_t       len, dnlen = dn->bv_len;
+       Backend         *be = NULL;
 
        for ( i = 0; i < nbackends; i++ ) {
-               for ( j = 0; backends[i].be_nsuffix != NULL &&
-                   backends[i].be_nsuffix[j].bv_val != NULL; j++ )
+               if ( backends[i].be_nsuffix == NULL ) {
+                       continue;
+               }
+
+               for ( j = 0; !BER_BVISNULL( &backends[i].be_nsuffix[j] ); j++ )
                {
                        if ( ( SLAP_GLUE_SUBORDINATE( &backends[i] ) )
                                && noSubs )
@@ -613,58 +611,49 @@ be_issuffix(
 {
        int     i;
 
-       for ( i = 0;
-               be->be_nsuffix != NULL && be->be_nsuffix[i].bv_val != NULL;
-               i++ )
-       {
+       if ( be->be_nsuffix == NULL ) {
+               return 0;
+       }
+
+       for ( i = 0; !BER_BVISNULL( &be->be_nsuffix[i] ); i++ ) {
                if ( bvmatch( &be->be_nsuffix[i], bvsuffix ) ) {
-                       return( 1 );
+                       return 1;
                }
        }
 
-       return( 0 );
+       return 0;
 }
 
 int
 be_isroot_dn( Backend *be, struct berval *ndn )
 {
-       if ( !ndn->bv_len ) {
-               return( 0 );
-       }
-
-       if ( !be->be_rootndn.bv_len ) {
-               return( 0 );
+       if ( BER_BVISEMPTY( ndn ) || BER_BVISEMPTY( &be->be_rootndn ) ) {
+               return 0;
        }
 
        return dn_match( &be->be_rootndn, ndn );
 }
 
-int
-be_sync_update( Operation *op )
-{
-       return ( SLAP_SYNC_SHADOW( op->o_bd ) && syncrepl_isupdate( op ) );
-}
-
 int
 be_slurp_update( Operation *op )
 {
        return ( SLAP_SLURP_SHADOW( op->o_bd ) &&
-               be_isupdate_dn( op->o_bd, &op->o_ndn ));
+               be_isupdate_dn( op->o_bd, &op->o_ndn ) );
 }
 
 int
 be_shadow_update( Operation *op )
 {
-       return ( SLAP_SHADOW( op->o_bd ) &&
-               ( syncrepl_isupdate( op ) || be_isupdate_dn( op->o_bd, &op->o_ndn )));
+       return ( SLAP_SYNC_SHADOW( op->o_bd ) ||
+               ( SLAP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn ) ) );
 }
 
 int
 be_isupdate_dn( Backend *be, struct berval *ndn )
 {
-       if ( !ndn->bv_len ) return( 0 );
-
-       if ( !be->be_update_ndn.bv_len ) return( 0 );
+       if ( BER_BVISEMPTY( ndn ) || BER_BVISEMPTY( &be->be_update_ndn ) ) {
+               return 0;
+       }
 
        return dn_match( &be->be_update_ndn, ndn );
 }
@@ -690,7 +679,7 @@ be_isroot_pw( Operation *op )
                return 0;
        }
 
-       if( op->o_bd->be_rootpw.bv_len == 0 ) {
+       if ( BER_BVISEMPTY( &op->o_bd->be_rootpw ) ) {
                return 0;
        }
 
@@ -1023,7 +1012,7 @@ backend_check_restrictions(
                        }
 
                        if( !( global_allows & SLAP_ALLOW_UPDATE_ANON ) &&
-                               op->o_ndn.bv_len == 0 )
+                               BER_BVISEMPTY( &op->o_ndn ) )
                        {
                                rs->sr_text = "modifications require authentication";
                                rs->sr_err = LDAP_STRONG_AUTH_REQUIRED;
@@ -1031,7 +1020,7 @@ backend_check_restrictions(
                        }
 
 #ifdef SLAP_X_LISTENER_MOD
-                       if ( op->o_conn->c_listener && ! ( op->o_conn->c_listener->sl_perms & ( op->o_ndn.bv_len > 0 ? S_IWUSR : S_IWOTH ) ) ) {
+                       if ( op->o_conn->c_listener && ! ( op->o_conn->c_listener->sl_perms & ( !BER_BVISEMPTY( &op->o_ndn ) ? S_IWUSR : S_IWOTH ) ) ) {
                                /* no "w" mode means readonly */
                                rs->sr_text = "modifications not allowed on this listener";
                                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
@@ -1048,7 +1037,7 @@ backend_check_restrictions(
                        /* should check mechanism */
                        if( ( op->o_transport_ssf < ssf->sss_transport
                                && op->o_authtype == LDAP_AUTH_SIMPLE )
-                               || op->o_dn.bv_len == 0 )
+                               || BER_BVISEMPTY( &op->o_dn ) )
                        {
                                rs->sr_text = "strong(er) authentication required";
                                rs->sr_err = LDAP_STRONG_AUTH_REQUIRED;
@@ -1057,7 +1046,7 @@ backend_check_restrictions(
                }
 
                if( requires & SLAP_REQUIRE_SASL ) {
-                       if( op->o_authtype != LDAP_AUTH_SASL || op->o_dn.bv_len == 0 ) {
+                       if( op->o_authtype != LDAP_AUTH_SASL || BER_BVISEMPTY( &op->o_dn ) ) {
                                rs->sr_text = "SASL authentication required";
                                rs->sr_err = LDAP_STRONG_AUTH_REQUIRED;
                                return rs->sr_err;
@@ -1065,7 +1054,7 @@ backend_check_restrictions(
                }
                        
                if( requires & SLAP_REQUIRE_AUTHC ) {
-                       if( op->o_dn.bv_len == 0 ) {
+                       if( BER_BVISEMPTY( &op->o_dn ) ) {
                                rs->sr_text = "authentication required";
                                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                                return rs->sr_err;
@@ -1096,7 +1085,7 @@ backend_check_restrictions(
                }
 
 #ifdef SLAP_X_LISTENER_MOD
-               if ( !starttls && op->o_dn.bv_len == 0 ) {
+               if ( !starttls && BER_BVISEMPTY( &op->o_dn ) ) {
                        if ( op->o_conn->c_listener &&
                                !( op->o_conn->c_listener->sl_perms & S_IXOTH ))
                {
@@ -1110,7 +1099,7 @@ backend_check_restrictions(
                if ( !starttls && !updateop ) {
                        if ( op->o_conn->c_listener &&
                                !( op->o_conn->c_listener->sl_perms &
-                                       ( op->o_dn.bv_len > 0 ? S_IRUSR : S_IROTH )))
+                                       ( !BER_BVISEMPTY( &op->o_dn ) ? S_IRUSR : S_IROTH )))
                        {
                                /* no "r" mode means no read */
                                rs->sr_text = "read not allowed on this listener";
@@ -1197,15 +1186,18 @@ backend_group(
 
        op->o_bd = select_backend( gr_ndn, 0, 0 );
 
-       for (g = op->o_groups; g; g=g->ga_next) {
-               if (g->ga_be != op->o_bd || g->ga_oc != group_oc ||
-                       g->ga_at != group_at || g->ga_len != gr_ndn->bv_len)
+       for ( g = op->o_groups; g; g = g->ga_next ) {
+               if ( g->ga_be != op->o_bd || g->ga_oc != group_oc ||
+                       g->ga_at != group_at || g->ga_len != gr_ndn->bv_len )
+               {
                        continue;
-               if (strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0)
+               }
+               if ( strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0 ) {
                        break;
+               }
        }
 
-       if (g) {
+       if ( g ) {
                rc = g->ga_res;
                goto done;
        }
@@ -1214,7 +1206,7 @@ backend_group(
                e = target;
                rc = 0;
        } else {
-               rc = be_entry_get_rw(op, gr_ndn, group_oc, group_at, 0, &e );
+               rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e );
        }
        if ( e ) {
 #ifdef LDAP_SLAPI
@@ -1252,16 +1244,16 @@ backend_group(
                                
                                if ( rc == 0 ) {
                                        rc = 1;
-                                       for (i=0; a->a_vals[i].bv_val; i++) {
+                                       for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
                                                if ( ldap_url_parse( a->a_vals[i].bv_val, &ludp ) !=
                                                        LDAP_URL_SUCCESS )
                                                {
                                                        continue;
                                                }
-                                               nbase.bv_val = NULL;
+                                               BER_BVZERO( &nbase );
                                                /* host part must be empty */
                                                /* attrs and extensions parts must be empty */
-                                               if (( ludp->lud_host && *ludp->lud_host ) ||
+                                               if ( ( ludp->lud_host && *ludp->lud_host ) ||
                                                        ludp->lud_attrs || ludp->lud_exts )
                                                {
                                                        goto loopit;
@@ -1272,16 +1264,22 @@ backend_group(
                                                {
                                                        goto loopit;
                                                }
-                                               switch(ludp->lud_scope) {
+                                               switch ( ludp->lud_scope ) {
                                                case LDAP_SCOPE_BASE:
-                                                       if ( !dn_match( &nbase, op_ndn )) goto loopit;
+                                                       if ( !dn_match( &nbase, op_ndn ) ) {
+                                                               goto loopit;
+                                                       }
                                                        break;
                                                case LDAP_SCOPE_ONELEVEL:
-                                                       dnParent(op_ndn, &bv );
-                                                       if ( !dn_match( &nbase, &bv )) goto loopit;
+                                                       dnParent( op_ndn, &bv );
+                                                       if ( !dn_match( &nbase, &bv ) ) {
+                                                               goto loopit;
+                                                       }
                                                        break;
                                                case LDAP_SCOPE_SUBTREE:
-                                                       if ( !dnIsSuffix( op_ndn, &nbase )) goto loopit;
+                                                       if ( !dnIsSuffix( op_ndn, &nbase ) ) {
+                                                               goto loopit;
+                                                       }
                                                        break;
 #ifdef LDAP_SCOPE_SUBORDINATE
                                                case LDAP_SCOPE_SUBORDINATE:
@@ -1303,7 +1301,7 @@ backend_group(
                                                }
 loopit:
                                                ldap_free_urldesc( ludp );
-                                               if ( nbase.bv_val ) {
+                                               if ( !BER_BVISNULL( &nbase ) ) {
                                                        op->o_tmpfree( nbase.bv_val, op->o_tmpmemctx );
                                                }
                                                if ( rc == 0 ) break;
@@ -1334,14 +1332,14 @@ loopit:
 #endif /* LDAP_SLAPI */
 
        if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache ) {
-               g = op->o_tmpalloc(sizeof(GroupAssertion) + gr_ndn->bv_len,
-                       op->o_tmpmemctx);
+               g = op->o_tmpalloc( sizeof( GroupAssertion ) + gr_ndn->bv_len,
+                       op->o_tmpmemctx );
                g->ga_be = op->o_bd;
                g->ga_oc = group_oc;
                g->ga_at = group_at;
                g->ga_res = rc;
                g->ga_len = gr_ndn->bv_len;
-               strcpy(g->ga_ndn, gr_ndn->bv_val);
+               strcpy( g->ga_ndn, gr_ndn->bv_val );
                g->ga_next = op->o_groups;
                op->o_groups = g;
        }
@@ -1370,11 +1368,11 @@ static int backend_compute_output_attr(computed_attr_context *c, Slapi_Attr *a,
                return 1;
        }
 
-       for ( i=0; a->a_vals[i].bv_val; i++ ) ;
+       for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) ;
                        
        v = op->o_tmpalloc( sizeof(struct berval) * (i+1),
                op->o_tmpmemctx );
-       for ( i=0,j=0; a->a_vals[i].bv_val; i++ ) {
+       for ( i = 0, j = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
                if ( op->o_conn && access_allowed( op,
                        e, a->a_desc,
                        &a->a_nvals[i],
@@ -1383,16 +1381,17 @@ static int backend_compute_output_attr(computed_attr_context *c, Slapi_Attr *a,
                }
                ber_dupbv_x( &v[j],
                        &a->a_nvals[i], op->o_tmpmemctx );
-               if (v[j].bv_val ) j++;
+               if ( !BER_BVISNULL( &v[j] ) ) {
+                       j++;
+               }
        }
 
-       if (j == 0) {
+       if ( j == 0 ) {
                op->o_tmpfree( v, op->o_tmpmemctx );
                *vals = NULL;
                rc = 1;
        } else {
-               v[j].bv_val = NULL;
-               v[j].bv_len = 0;
+               BER_BVZERO( &v[j] );
                *vals = v;
                rc = 0;
        }
@@ -1410,22 +1409,41 @@ backend_attribute(
        BerVarray *vals,
        slap_access_t access )
 {
-       Entry *e;
-       Attribute *a;
-       int i, j, rc = LDAP_SUCCESS;
-       AccessControlState acl_state = ACL_STATE_INIT;
-       Backend *be = op->o_bd;
+       Entry                   *e = NULL;
+       Attribute               *a = NULL;
+       int                     freeattr = 0, i, j, rc = LDAP_SUCCESS;
+       AccessControlState      acl_state = ACL_STATE_INIT;
+       Backend                 *be = op->o_bd;
 
        op->o_bd = select_backend( edn, 0, 0 );
 
        if ( target && dn_match( &target->e_nname, edn ) ) {
                e = target;
+
        } else {
-               rc = be_entry_get_rw(op, edn, NULL, entry_at, 0, &e );
+               rc = be_entry_get_rw( op, edn, NULL, entry_at, 0, &e );
        } 
 
        if ( e ) {
                a = attr_find( e->e_attrs, entry_at );
+               if ( a == NULL ) {
+                       SlapReply       rs = { 0 };
+                       AttributeName   anlist[ 2 ];
+
+                       anlist[ 0 ].an_name = entry_at->ad_cname;
+                       anlist[ 0 ].an_desc = entry_at;
+                       BER_BVZERO( &anlist[ 1 ].an_name );
+                       rs.sr_attrs = anlist;
+                       
+                       rs.sr_attr_flags = slap_attr_flags( rs.sr_attrs );
+
+                       rc = backend_operational( op, &rs );
+
+                       if ( rc == LDAP_SUCCESS ) {
+                               a = rs.sr_operational_attrs;
+                       }
+               }
+
                if ( a ) {
                        BerVarray v;
 
@@ -1436,28 +1454,35 @@ backend_attribute(
                                goto freeit;
                        }
 
-                       for ( i=0; a->a_vals[i].bv_val; i++ ) ;
+                       for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )
+                               ;
                        
-                       v = op->o_tmpalloc( sizeof(struct berval) * (i+1),
+                       v = op->o_tmpalloc( sizeof(struct berval) * ( i + 1 ),
                                op->o_tmpmemctx );
-                       for ( i=0,j=0; a->a_vals[i].bv_val; i++ ) {
-                               if ( op->o_conn && access > ACL_NONE && access_allowed( op,
-                                       e, entry_at,
-                                       &a->a_nvals[i],
-                                       access, &acl_state ) == 0 ) {
+                       for ( i = 0,j = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )
+                       {
+                               if ( op->o_conn && access > ACL_NONE && 
+                                               access_allowed( op, e,
+                                                       entry_at,
+                                                       &a->a_nvals[i],
+                                                       access,
+                                                       &acl_state ) == 0 )
+                               {
                                        continue;
                                }
-                               ber_dupbv_x( &v[j],
-                                       &a->a_nvals[i], op->o_tmpmemctx );
-                               if (v[j].bv_val ) j++;
+                               ber_dupbv_x( &v[j], &a->a_nvals[i],
+                                               op->o_tmpmemctx );
+                               if ( !BER_BVISNULL( &v[j] ) ) {
+                                       j++;
+                               }
                        }
-                       if (j == 0) {
+                       if ( j == 0 ) {
                                op->o_tmpfree( v, op->o_tmpmemctx );
                                *vals = NULL;
                                rc = LDAP_INSUFFICIENT_ACCESS;
+
                        } else {
-                               v[j].bv_val = NULL;
-                               v[j].bv_len = 0;
+                               BER_BVZERO( &v[j] );
                                *vals = v;
                                rc = LDAP_SUCCESS;
                        }
@@ -1465,8 +1490,7 @@ backend_attribute(
 #ifdef LDAP_SLAPI
                else if ( op->o_pb ) {
                        /* try any computed attributes */
-                       computed_attr_context ctx;
-                       AttributeName aname;
+                       computed_attr_context   ctx;
 
                        slapi_int_pblock_set_operation( op->o_pb, op );
 
@@ -1477,15 +1501,21 @@ backend_attribute(
                        ctx.cac_acl_state = acl_state;
                        ctx.cac_private = (void *)vals;
 
-                       if ( compute_evaluator( &ctx, entry_at->ad_cname.bv_val, e, backend_compute_output_attr ) == 1)
+                       rc = compute_evaluator( &ctx, entry_at->ad_cname.bv_val, e, backend_compute_output_attr );
+                       if ( rc == 1 ) {
                                rc = LDAP_INSUFFICIENT_ACCESS;
-                       else
+
+                       } else {
                                rc = LDAP_SUCCESS;
+                       }
                }
 #endif /* LDAP_SLAPI */
-freeit:                if (e != target ) {
+freeit:                if ( e != target ) {
                        be_entry_release_r( op, e );
                }
+               if ( freeattr ) {
+                       attr_free( a );
+               }
        }
 
        op->o_bd = be;
@@ -1498,7 +1528,7 @@ int backend_operational(
 {
        Attribute       **ap;
        int             rc = 0;
-       BackendDB *be_orig;
+       BackendDB       *be_orig;
 
        for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
                /* just count them */ ;
index 1efbfcb565fa606064ef17a13f5df63547c09814..6e396a59043930ec36ed447179b5784aab22851e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -279,7 +279,7 @@ over_op_func(
        for (; on; on=on->on_next ) {
                func = &on->on_bi.bi_op_bind;
                if ( func[which] ) {
-                       db.bd_info = (BackendInfo *)on;
+                       op->o_bd->bd_info = (BackendInfo *)on;
                        rc = func[which]( op, rs );
                        if ( rc != SLAP_CB_CONTINUE ) break;
                }
@@ -287,7 +287,7 @@ over_op_func(
 
        func = &oi->oi_orig->bi_op_bind;
        if ( func[which] && rc == SLAP_CB_CONTINUE ) {
-               db.bd_info = oi->oi_orig;
+               op->o_bd->bd_info = oi->oi_orig;
                rc = func[which]( op, rs );
        }
        /* should not fall thru this far without anything happening... */
index 7ad9bf1d50807d5fa151802195551281c2300bde..cbc6abd83e877698fc9db9577efe06e309daa172 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -594,6 +594,7 @@ fe_op_bind( Operation *op, SlapReply *rs )
 
                } else if ( !BER_BVISNULL( &op->orb_edn ) ) {
                        free( op->orb_edn.bv_val );
+                       BER_BVZERO( &op->orb_edn );
                }
 
        } else {
index b1d8023e823feb4fcbd9a1879738bf428cdcb8a0..12dfabb3fead793675b53e96dac05d4eb0a6b457 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7128c258318776024fc94d1b3a9048fdeaf9f979..2b698fa1779ae7abb5067fee2cde715bdc742e1a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 506e34736b544fe232de94023956b90d182bdfc8..ed575fd1e84627994235bfb002dca151583996fc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e37b5ea1e4f7c8c8e4fa25c35ac2cc9b36c95988..7d74c191117517165366d6db370c2b0367f62629 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 by IBM Corporation.
  * All rights reserved.
  *
@@ -62,8 +62,7 @@ static void
 free_comp_filter( ComponentFilter* f );
 
 static int
-test_comp_filter( Syntax *syn, ComponentSyntaxInfo *a, struct berval *bv,
-                       ComponentFilter *f );
+test_comp_filter( Syntax *syn, ComponentSyntaxInfo *a, ComponentFilter *f );
 
 int
 componentCertificateValidate(
@@ -98,59 +97,30 @@ componentFilterMatch (
        struct berval *value, 
        void *assertedValue )
 {
-       struct berval* bv;
-       Attribute *a = (Attribute*)value;
+       ComponentSyntaxInfo *csi_attr = (ComponentSyntaxInfo*)value;
        MatchingRuleAssertion * ma = (MatchingRuleAssertion*)assertedValue;
-       void* assert_nm;
        int num_attr, rc, i;
 
-       if ( !mr || !ma->ma_cf )
-               return LDAP_INAPPROPRIATE_MATCHING;
-       /* Check if the component module is loaded */
-       if ( !attr_converter || !nibble_mem_allocator )
-               return LDAP_INAPPROPRIATE_MATCHING;
+       if ( !mr || !ma->ma_cf ) return LDAP_INAPPROPRIATE_MATCHING;
 
-       /* Check if decoded component trees are already linked */
-       num_attr = 0;
-       if ( !a->a_comp_data ) {
-               for ( ; a->a_vals[num_attr].bv_val != NULL; num_attr++ );
-               if ( num_attr <= 0 )/* no attribute value */
-                       return LDAP_INAPPROPRIATE_MATCHING;
-               num_attr++;
-               /* following malloced will be freed by comp_tree_free () */
-               a->a_comp_data = malloc( sizeof( ComponentData ) + sizeof( ComponentSyntaxInfo* )*num_attr );
-               if ( !a->a_comp_data )
-                       return LDAP_NO_MEMORY;
-               a->a_comp_data->cd_tree = (ComponentSyntaxInfo**)((char*)a->a_comp_data + sizeof(ComponentData));
-               a->a_comp_data->cd_tree[ num_attr - 1] = (ComponentSyntaxInfo*)NULL;
-               a->a_comp_data->cd_mem_op = nibble_mem_allocator ( 1024*16, 1024 );
+       /* Check if the component module is loaded */
+       if ( !attr_converter || !nibble_mem_allocator ) {
+               return LDAP_OTHER;
        }
 
-       for ( bv = a->a_vals, i = 0 ; bv->bv_val != NULL; bv++, i++ ) {
-               /* decodes current attribute into components */
-               if ( num_attr != 0 ) {
-                       a->a_comp_data->cd_tree[i] = attr_converter (a, syntax, bv);
-               }
-               /* decoding error */
-               if ( !a->a_comp_data->cd_tree[i] )
-                       return LDAP_OPERATIONS_ERROR;
+       rc = test_comp_filter( syntax, csi_attr, ma->ma_cf );
 
-               rc = test_comp_filter( syntax, a->a_comp_data->cd_tree[i], bv, ma->ma_cf );
-
-               if ( rc == LDAP_COMPARE_TRUE ) {
-                       *matchp = 0;
-                       return LDAP_SUCCESS;
-               }
-               else if ( rc == LDAP_COMPARE_FALSE ) {
-                       continue;
-               }
-               else {
-                       return LDAP_INAPPROPRIATE_MATCHING;
-               }
+       if ( rc == LDAP_COMPARE_TRUE ) {
+               *matchp = 0;
+               return LDAP_SUCCESS;
+       }
+       else if ( rc == LDAP_COMPARE_FALSE ) {
+               *matchp = 1;
+               return LDAP_SUCCESS;
+       }
+       else {
+               return LDAP_INAPPROPRIATE_MATCHING;
        }
-       *matchp = 1;
-       return LDAP_SUCCESS;
-       
 }
 
 int
@@ -162,7 +132,7 @@ directoryComponentsMatch(
        struct berval *value, 
        void *assertedValue )
 {
-       /* Only for Registeration */
+       /* Only for registration */
        *matchp = 0;
        return LDAP_SUCCESS;
 }
@@ -176,7 +146,7 @@ allComponentsMatch(
        struct berval *value, 
        void *assertedValue )
 {
-       /* Only for Registeration */
+       /* Only for registration */
        *matchp = 0;
        return LDAP_SUCCESS;
 }
@@ -209,7 +179,9 @@ dup_comp_ref ( Operation* op, ComponentReference* cr )
        ci_temp = &dup_cr->cr_list;
        ci_curr = cr->cr_list;
 
-       for ( ; ci_curr ; ci_curr = ci_curr->ci_next, ci_temp = &(*ci_temp)->ci_next ) {
+       for ( ; ci_curr != NULL ;
+               ci_curr = ci_curr->ci_next, ci_temp = &(*ci_temp)->ci_next )
+       {
                *ci_temp = op->o_tmpalloc( sizeof( ComponentId ), op->o_tmpmemctx );
                if ( !ci_temp ) return NULL;
                **ci_temp = *ci_curr;
@@ -265,12 +237,10 @@ dup_comp_filter_item (
        ComponentAssertion* ca;
        int len;
 
-       if ( !in_ca->ca_comp_ref )
-               return SLAPD_DISCONNECT;
+       if ( !in_ca->ca_comp_ref ) return SLAPD_DISCONNECT;
 
        *out_ca = op->o_tmpalloc( sizeof( ComponentAssertion ), op->o_tmpmemctx );
-       if ( !(*out_ca) )
-               return LDAP_NO_MEMORY;
+       if ( !(*out_ca) ) return LDAP_NO_MEMORY;
 
        (*out_ca)->ca_comp_data.cd_tree = NULL;
        (*out_ca)->ca_comp_data.cd_mem_op = NULL;
@@ -281,8 +251,7 @@ dup_comp_filter_item (
 
        (*out_ca)->ca_ma_value.bv_val = assert_bv->bv_val;
        len = get_len_of_next_assert_value ( assert_bv, '$' );
-       if ( len <= 0 )
-               return SLAPD_DISCONNECT;
+       if ( len <= 0 ) return SLAPD_DISCONNECT;
        (*out_ca)->ca_ma_value.bv_len = len;
        
        return LDAP_SUCCESS;
@@ -331,7 +300,9 @@ dup_comp_filter (
 
 
 int
-get_aliased_filter ( Operation* op, MatchingRuleAssertion* ma, AttributeAliasing* aa, const char** text )
+get_aliased_filter( Operation* op,
+       MatchingRuleAssertion* ma, AttributeAliasing* aa,
+       const char** text )
 {
        int rc;
        struct berval assert_bv;
@@ -354,8 +325,8 @@ get_aliased_filter ( Operation* op, MatchingRuleAssertion* ma, AttributeAliasing
 }
 
 int
-get_comp_filter( Operation* op, struct berval* bv, ComponentFilter** filt,
-                const char **text )
+get_comp_filter( Operation* op, struct berval* bv,
+       ComponentFilter** filt, const char **text )
 {
        ComponentAssertionValue cav;
        int rc;
@@ -390,24 +361,30 @@ comp_first_element( ComponentAssertionValue* cav )
        eat_whsp( cav );
        if ( cav_cur_len( cav ) >= 8 && strncmp( cav->cav_ptr, "item", 4 ) == 0 ) {
                return LDAP_COMP_FILTER_ITEM;
-       }
-       else if ( cav_cur_len( cav ) >= 7 && strncmp( cav->cav_ptr, "and", 3 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 7 &&
+               strncmp( cav->cav_ptr, "and", 3 ) == 0 )
+       {
                return LDAP_COMP_FILTER_AND;
-       }
-       else if ( cav_cur_len( cav ) >= 6 && strncmp( cav->cav_ptr, "or" , 2 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 6 &&
+               strncmp( cav->cav_ptr, "or" , 2 ) == 0 )
+       {
                return LDAP_COMP_FILTER_OR;
-       }
-       else if ( cav_cur_len( cav ) >= 7 && strncmp( cav->cav_ptr, "not", 3 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 7 &&
+               strncmp( cav->cav_ptr, "not", 3 ) == 0 )
+       {
                return LDAP_COMP_FILTER_NOT;
-       }
-       else
+
+       } else {
                return LDAP_COMP_FILTER_UNDEFINED;
+       }
 }
 
 static ber_tag_t
 comp_next_element( ComponentAssertionValue* cav )
 {
-
        eat_whsp( cav );
        if ( *(cav->cav_ptr) == ',' ) {
                /* move pointer to the next CA */
@@ -419,7 +396,7 @@ comp_next_element( ComponentAssertionValue* cav )
 
 static int
 get_comp_filter_list( Operation *op, ComponentAssertionValue *cav,
-                       ComponentFilter** f, const char** text )
+       ComponentFilter** f, const char** text )
 {
        ComponentFilter **new;
        int             err;
@@ -427,12 +404,12 @@ get_comp_filter_list( Operation *op, ComponentAssertionValue *cav,
 
        Debug( LDAP_DEBUG_FILTER, "get_comp_filter_list\n", 0, 0, 0 );
        new = f;
-       for ( tag = comp_first_element( cav ); tag != LDAP_COMP_FILTER_UNDEFINED;
+       for ( tag = comp_first_element( cav );
+               tag != LDAP_COMP_FILTER_UNDEFINED;
                tag = comp_next_element( cav ) )
        {
                err = parse_comp_filter( op, cav, new, text );
-               if ( err != LDAP_SUCCESS )
-                       return ( err );
+               if ( err != LDAP_SUCCESS ) return ( err );
                new = &(*new)->cf_next;
        }
        *new = NULL;
@@ -442,7 +419,7 @@ get_comp_filter_list( Operation *op, ComponentAssertionValue *cav,
 
 static int
 get_componentId( Operation *op, ComponentAssertionValue* cav,
-                       ComponentId ** cid, const char** text )
+       ComponentId ** cid, const char** text )
 {
        ber_tag_t type;
        ComponentId _cid;
@@ -483,8 +460,7 @@ get_componentId( Operation *op, ComponentAssertionValue* cav,
                cav->cav_ptr += strlen("content");
                break;
        case LDAP_COMPREF_SELECT :
-               if ( cav->cav_ptr[len] != '(' )
-                       return LDAP_COMPREF_UNDEFINED;
+               if ( cav->cav_ptr[len] != '(' ) return LDAP_COMPREF_UNDEFINED;
                for( ;cav->cav_ptr[len] != ' ' && cav->cav_ptr[len] != '\0' &&
                      cav->cav_ptr[len] != '\"' && cav->cav_ptr[len] != ')'
                        ; len++ );
@@ -500,10 +476,11 @@ get_componentId( Operation *op, ComponentAssertionValue* cav,
                return LDAP_COMPREF_UNDEFINED;
        }
 
-       if ( op )
+       if ( op ) {
                *cid = op->o_tmpalloc( sizeof( ComponentId ), op->o_tmpmemctx );
-       else
+       } else {
                *cid = malloc( sizeof( ComponentId ) );
+       }
        **cid = _cid;
        return LDAP_SUCCESS;
 }
@@ -512,43 +489,54 @@ static int
 peek_componentId_type( ComponentAssertionValue* cav )
 {
        eat_whsp( cav );
-       if ( cav->cav_ptr[0] == '-' )
+
+       if ( cav->cav_ptr[0] == '-' ) {
                return LDAP_COMPREF_FROM_END;
-       else if ( cav->cav_ptr[0] == '(' )
+
+       } else if ( cav->cav_ptr[0] == '(' ) {
                return LDAP_COMPREF_SELECT;
-       else if ( cav->cav_ptr[0] == '*' )
+
+       } else if ( cav->cav_ptr[0] == '*' ) {
                return LDAP_COMPREF_ALL;
-       else if ( cav->cav_ptr[0] == '0' )
+
+       } else if ( cav->cav_ptr[0] == '0' ) {
                return LDAP_COMPREF_COUNT;
-       else if ( cav->cav_ptr[0] > '0' && cav->cav_ptr[0] <= '9' )
+
+       } else if ( cav->cav_ptr[0] > '0' && cav->cav_ptr[0] <= '9' ) {
                return LDAP_COMPREF_FROM_BEGINNING;
-       else if ( (cav->cav_end - cav->cav_ptr) >= 7 &&
+
+       } else if ( (cav->cav_end - cav->cav_ptr) >= 7 &&
                strncmp(cav->cav_ptr,"content",7) == 0 )
+       {
                return LDAP_COMPREF_CONTENT;
-       else if ( (cav->cav_ptr[0] >= 'a' && cav->cav_ptr[0] <= 'z') ||
+       else if ( (cav->cav_ptr[0] >= 'a' && cav->cav_ptr[0] <= 'z') ||
                        (cav->cav_ptr[0] >= 'A' && cav->cav_ptr[0] <= 'Z') )
-                
+       {
                return LDAP_COMPREF_IDENTIFIER;
-       else
-               return LDAP_COMPREF_UNDEFINED;
+       }
+
+       return LDAP_COMPREF_UNDEFINED;
 }
 
 static ber_tag_t
 comp_next_id( ComponentAssertionValue* cav )
 {
-
        if ( *(cav->cav_ptr) == '.' ) {
                cav->cav_ptr++;
                return LDAP_COMPREF_DEFINED;
        }
-       else return LDAP_COMPREF_UNDEFINED;
+
+       return LDAP_COMPREF_UNDEFINED;
 }
 
 
 
 static int
-get_component_reference( Operation *op, ComponentAssertionValue* cav,
-                       ComponentReference** cr, const char** text )
+get_component_reference(
+       Operation *op,
+       ComponentAssertionValue* cav,
+       ComponentReference** cr,
+       const char** text )
 {
        int rc, count = 0;
        ber_int_t type;
@@ -559,45 +547,51 @@ get_component_reference( Operation *op, ComponentAssertionValue* cav,
        eat_whsp( cav );
 
        start = cav->cav_ptr;
-       if ( ( rc = strip_cav_str( cav,"\"") ) != LDAP_SUCCESS )
-               return rc;
-       if ( op )
-               ca_comp_ref = op->o_tmpalloc( sizeof( ComponentReference ), op->o_tmpmemctx );
-       else
+       if ( ( rc = strip_cav_str( cav,"\"") ) != LDAP_SUCCESS ) return rc;
+       if ( op ) {
+               ca_comp_ref = op->o_tmpalloc( sizeof( ComponentReference ),
+                       op->o_tmpmemctx );
+       } else {
                ca_comp_ref = malloc( sizeof( ComponentReference ) );
+       }
 
        if ( !ca_comp_ref ) return LDAP_NO_MEMORY;
 
        cr_list = &ca_comp_ref->cr_list;
 
        for ( type = peek_componentId_type( cav ) ; type != LDAP_COMPREF_UNDEFINED
-               ; type = comp_next_id( cav ), count++ ) {
+               ; type = comp_next_id( cav ), count++ )
+       {
                rc = get_componentId( op, cav, cr_list, text );
                if ( rc == LDAP_SUCCESS ) {
                        if ( count == 0 ) ca_comp_ref->cr_curr = ca_comp_ref->cr_list;
                        cr_list = &(*cr_list)->ci_next;
-               }
-               else if ( rc == LDAP_COMPREF_UNDEFINED )
+
+               } else if ( rc == LDAP_COMPREF_UNDEFINED ) {
                        return rc;
+               }
        }
        ca_comp_ref->cr_len = count;
        end = cav->cav_ptr;
        if ( ( rc = strip_cav_str( cav,"\"") ) != LDAP_SUCCESS ) {
-               if ( op )
+               if ( op ) {
                        op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx );
-               else
+               } else {
                        free( ca_comp_ref );
+               }
                return rc;
        }
 
        if ( rc == LDAP_SUCCESS ) {     
                *cr = ca_comp_ref;
                **cr = *ca_comp_ref;    
-       }
-       else if ( op )
+
+       } else if ( op ) {
                 op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx );
-       else
+
+       } else {
                 free( ca_comp_ref ) ;
+       }
 
        (*cr)->cr_string.bv_val = start;
        (*cr)->cr_string.bv_len = end - start + 1;
@@ -606,9 +600,12 @@ get_component_reference( Operation *op, ComponentAssertionValue* cav,
 }
 
 int
-insert_component_reference( ComponentReference *cr, ComponentReference** cr_list) {
-       if ( !cr )
-               return LDAP_PARAM_ERROR;
+insert_component_reference(
+       ComponentReference *cr,
+       ComponentReference** cr_list)
+{
+       if ( !cr ) return LDAP_PARAM_ERROR;
+
        if ( !(*cr_list) ) {
                *cr_list = cr;
                cr->cr_next = NULL;
@@ -631,59 +628,63 @@ int
 is_component_reference( char* attr ) {
        int i;
        for ( i=0; attr[i] != '\0' ; i++ ) {
-               if ( attr[i] == '.' )
-                       return (1);
+               if ( attr[i] == '.' ) return (1);
        }
        return (0);
 }
 
 int
-extract_component_reference( char* attr, ComponentReference** cr ) {
-        int i, rc;
-        char* cr_ptr;
-        int cr_len;
-        ComponentAssertionValue cav;
+extract_component_reference(
+       char* attr,
+       ComponentReference** cr )
+{
+       int i, rc;
+       char* cr_ptr;
+       int cr_len;
+       ComponentAssertionValue cav;
        char text[1][128];
 
-        for ( i=0; attr[i] != '\0' ; i++ ) {
-                if ( attr[i] == '.' ) break;
-        }
+       for ( i=0; attr[i] != '\0' ; i++ ) {
+               if ( attr[i] == '.' ) break;
+       }
+
+       if (attr[i] != '.' ) return LDAP_PARAM_ERROR;
+       attr[i] = '\0';
 
-        if (attr[i] != '.' )
-                return LDAP_PARAM_ERROR;
-        else
-                attr[i] = '\0';
-        cr_ptr = attr + i + 1 ;
-        cr_len = strlen ( cr_ptr );
-        if ( cr_len <= 0 )
-                return LDAP_PARAM_ERROR;
+       cr_ptr = attr + i + 1 ;
+       cr_len = strlen ( cr_ptr );
+       if ( cr_len <= 0 ) return LDAP_PARAM_ERROR;
 
        /* enclosed between double quotes*/
        cav.cav_ptr = cav.cav_buf = ch_malloc (cr_len+2);
        memcpy( cav.cav_buf+1, cr_ptr, cr_len );
        cav.cav_buf[0] = '"';
        cav.cav_buf[cr_len+1] = '"';
-        cav.cav_end = cr_ptr + cr_len + 2;
+       cav.cav_end = cr_ptr + cr_len + 2;
 
-        rc = get_component_reference ( NULL, &cav, cr, (const char**)text );
-       if ( rc != LDAP_SUCCESS )
-               return rc;
+       rc = get_component_reference ( NULL, &cav, cr, (const char**)text );
+       if ( rc != LDAP_SUCCESS ) return rc;
        (*cr)->cr_string.bv_val = cav.cav_buf;
        (*cr)->cr_string.bv_len = cr_len + 2;
 
        return LDAP_SUCCESS;
 }
+
 static int
-get_ca_use_default( Operation *op, ComponentAssertionValue* cav,
-               int* ca_use_def, const char**  text )
+get_ca_use_default( Operation *op,
+       ComponentAssertionValue* cav,
+       int* ca_use_def, const char**  text )
 {
        strip_cav_str( cav, "useDefaultValues" );
+
        if ( peek_cav_str( cav, "TRUE" ) == LDAP_SUCCESS ) {
                strip_cav_str( cav, "TRUE" );
                *ca_use_def = 1;
+
        } else if ( peek_cav_str( cav, "FALSE" ) == LDAP_SUCCESS ) {
                strip_cav_str( cav, "FALSE" );
                *ca_use_def = 0;
+
        } else {
                return LDAP_INVALID_SYNTAX;
        }
@@ -704,7 +705,9 @@ get_matching_rule( Operation *op, ComponentAssertionValue* cav,
                if ( cav->cav_ptr[count] == ' ' || cav->cav_ptr[count] == ',' ||
                        cav->cav_ptr[count] == '\0' || cav->cav_ptr[count] == '{' ||
                        cav->cav_ptr[count] == '}' || cav->cav_ptr[count] == '\n' )
+               {
                        break;
+               }
        }
 
        if ( count == 0 ) {
@@ -716,7 +719,8 @@ get_matching_rule( Operation *op, ComponentAssertionValue* cav,
        rule_text.bv_val = cav->cav_ptr;
        *mr = mr_bvfind( &rule_text );
        cav->cav_ptr += count;
-       Debug( LDAP_DEBUG_FILTER, "get_matching_rule: %s\n", (*mr)->smr_mrule.mr_oid, 0, 0 );
+       Debug( LDAP_DEBUG_FILTER, "get_matching_rule: %s\n",
+               (*mr)->smr_mrule.mr_oid, 0, 0 );
        if ( *mr == NULL ) {
                *text = "component matching rule not recognized";
                return LDAP_INAPPROPRIATE_MATCHING;
@@ -749,66 +753,82 @@ get_GSER_value( ComponentAssertionValue* cav, struct berval* bv )
                        if ( cav->cav_ptr[count] == '"' ) sequent_dquote++;
                        else sequent_dquote = 0;
 
-                       if ( cav->cav_ptr[count] == '\0' || (cav->cav_ptr+count) > cav->cav_end ) {
+                       if ( cav->cav_ptr[count] == '\0' ||
+                               (cav->cav_ptr+count) > cav->cav_end )
+                       {
                                break;
                        }
                                
-                       if ( ( cav->cav_ptr[count] == '"' && cav->cav_ptr[count-1] != '"') ||
-                       ( sequent_dquote > 2 && (sequent_dquote%2) == 1 ) ) {
+                       if ( ( cav->cav_ptr[count] == '"' &&
+                               cav->cav_ptr[count-1] != '"') ||
+                               ( sequent_dquote > 2 && (sequent_dquote%2) == 1 ) )
+                       {
                                succeed = 1;
                                break;
                        }
                }
                
-               if ( !succeed || cav->cav_ptr[count] != '"' )
+               if ( !succeed || cav->cav_ptr[count] != '"' ) {
                        return LDAP_FILTER_ERROR;
+               }
 
                bv->bv_val = cav->cav_ptr + 1;
                bv->bv_len = count - 1; /* exclude '"' */
-       }
-       else if ( cav->cav_ptr[0] == '\'' ) {
+
+       else if ( cav->cav_ptr[0] == '\'' ) {
                for( count = 1 ; ; count++ ) {
-                       if ( cav->cav_ptr[count] == '\0' || (cav->cav_ptr+count) > cav->cav_end ) {
+                       if ( cav->cav_ptr[count] == '\0' ||
+                               (cav->cav_ptr+count) > cav->cav_end )
+                       {
                                break;
                        }
-                       if ((cav->cav_ptr[count-1] == '\'' && cav->cav_ptr[count] == 'B')||
-                       (cav->cav_ptr[count-1] == '\'' && cav->cav_ptr[count] == 'H') ) {
+                       if ((cav->cav_ptr[count-1] == '\'' && cav->cav_ptr[count] == 'B') ||
+                               (cav->cav_ptr[count-1] == '\'' && cav->cav_ptr[count] == 'H') )
+                       {
                                succeed = 1;
                                break;
                        }
                }
 
-                if ( !succeed || !(cav->cav_ptr[count] == 'H' || cav->cav_ptr[count] == 'B') )
-                        return LDAP_FILTER_ERROR;
+               if ( !succeed ||
+                       !(cav->cav_ptr[count] == 'H' || cav->cav_ptr[count] == 'B') )
+               {
+                       return LDAP_FILTER_ERROR;
+               }
 
                bv->bv_val = cav->cav_ptr + 1;/*the next to '"' */
                bv->bv_len = count - 2;/* exclude "'H" or "'B" */
                                
-       }
-       else if ( cav->cav_ptr[0] == '{' ) {
+       } else if ( cav->cav_ptr[0] == '{' ) {
                for( count = 1, unclosed_brace = 1 ; ; count++ ) {
                        if ( cav->cav_ptr[count] == '{' ) unclosed_brace++;
                        if ( cav->cav_ptr[count] == '}' ) unclosed_brace--;
 
-                       if ( cav->cav_ptr[count] == '\0' || (cav->cav_ptr+count) > cav->cav_end )
+                       if ( cav->cav_ptr[count] == '\0' ||
+                               (cav->cav_ptr+count) > cav->cav_end )
+                       {
                                break;
+                       }
                        if ( unclosed_brace == 0 ) {
                                succeed = 1;
                                break;
                        }
                }
 
-                if ( !succeed || cav->cav_ptr[count] != '}' )
-                        return LDAP_FILTER_ERROR;
+               if ( !succeed || cav->cav_ptr[count] != '}' ) return LDAP_FILTER_ERROR;
 
                bv->bv_val = cav->cav_ptr + 1;/*the next to '"' */
                bv->bv_len = count - 1;/* exclude  "'B" */
-       }
-       else {
+
+       else {
                succeed = 1;
                /*Find  following white space where the value is ended*/
                for( count = 1 ; ; count++ ) {
-                       if ( cav->cav_ptr[count] == '\0' || cav->cav_ptr[count] == ' ' || cav->cav_ptr[count] == '}' || cav->cav_ptr[count] == '{' || (cav->cav_ptr+count) > cav->cav_end ) {
+                       if ( cav->cav_ptr[count] == '\0' ||
+                               cav->cav_ptr[count] == ' ' || cav->cav_ptr[count] == '}' ||
+                               cav->cav_ptr[count] == '{' ||
+                               (cav->cav_ptr+count) > cav->cav_end )
+                       {
                                break;
                        }
                }
@@ -817,14 +837,13 @@ get_GSER_value( ComponentAssertionValue* cav, struct berval* bv )
        }
 
        cav->cav_ptr += bv->bv_len;
-
        return LDAP_SUCCESS;
 }
 
 static int
 get_matching_value( Operation *op, ComponentAssertion* ca,
-                       ComponentAssertionValue* cav, struct berval* bv,
-                       const char**  text )
+       ComponentAssertionValue* cav, struct berval* bv,
+       const char**  text )
 {
        if ( !(ca->ca_ma_rule->smr_usage & (SLAP_MR_COMPONENT)) ) {
                if ( get_GSER_value( cav, bv ) != LDAP_SUCCESS ) {
@@ -847,9 +866,11 @@ peek_cav_str( ComponentAssertionValue* cav, char* str )
        eat_whsp( cav );
        if ( cav_cur_len( cav ) >= strlen( str ) &&
                strncmp( cav->cav_ptr, str, strlen( str ) ) == 0 )
+       {
                return LDAP_SUCCESS;
-       else 
-               return LDAP_INVALID_SYNTAX;
+       }
+
+       return LDAP_INVALID_SYNTAX;
 }
 
 static int
@@ -857,12 +878,13 @@ strip_cav_str( ComponentAssertionValue* cav, char* str)
 {
        eat_whsp( cav );
        if ( cav_cur_len( cav ) >= strlen( str ) &&
-               strncmp( cav->cav_ptr, str, strlen( str ) ) == 0 ) {
+               strncmp( cav->cav_ptr, str, strlen( str ) ) == 0 )
+       {
                cav->cav_ptr += strlen( str );
                return LDAP_SUCCESS;
        }
-       else 
-               return LDAP_INVALID_SYNTAX;
+
+       return LDAP_INVALID_SYNTAX;
 }
 
 /*
@@ -876,21 +898,27 @@ strip_cav_tag( ComponentAssertionValue* cav )
        if ( cav_cur_len( cav ) >= 8 && strncmp( cav->cav_ptr, "item", 4 ) == 0 ) {
                strip_cav_str( cav , "item:" );
                return LDAP_COMP_FILTER_ITEM;
-       }
-       else if ( cav_cur_len( cav ) >= 7 && strncmp( cav->cav_ptr, "and", 3 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 7 &&
+               strncmp( cav->cav_ptr, "and", 3 ) == 0 )
+       {
                strip_cav_str( cav , "and:" );
                return LDAP_COMP_FILTER_AND;
-       }
-       else if ( cav_cur_len( cav ) >= 6 && strncmp( cav->cav_ptr, "or" , 2 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 6 &&
+               strncmp( cav->cav_ptr, "or" , 2 ) == 0 )
+       {
                strip_cav_str( cav , "or:" );
                return LDAP_COMP_FILTER_OR;
-       }
-       else if ( cav_cur_len( cav ) >= 7 && strncmp( cav->cav_ptr, "not", 3 ) == 0 ) {
+
+       } else if ( cav_cur_len( cav ) >= 7 &&
+               strncmp( cav->cav_ptr, "not", 3 ) == 0 )
+       {
                strip_cav_str( cav , "not:" );
                return LDAP_COMP_FILTER_NOT;
        }
-       else
-               return LBER_ERROR;
+
+       return LBER_ERROR;
 }
 
 /*
@@ -1146,14 +1174,13 @@ static int
 test_comp_filter_and(
        Syntax *syn,
        ComponentSyntaxInfo *a,
-       struct berval  *bv,
        ComponentFilter *flist )
 {
        ComponentFilter *f;
        int rtn = LDAP_COMPARE_TRUE;
 
        for ( f = flist ; f != NULL; f = f->cf_next ) {
-               int rc = test_comp_filter( syn, a, bv, f );
+               int rc = test_comp_filter( syn, a, f );
                if ( rc == LDAP_COMPARE_FALSE ) {
                        rtn = rc;
                        break;
@@ -1171,14 +1198,13 @@ static int
 test_comp_filter_or(
        Syntax *syn,
        ComponentSyntaxInfo *a,
-       struct berval     *bv,
        ComponentFilter *flist )
 {
        ComponentFilter *f;
        int rtn = LDAP_COMPARE_TRUE;
 
        for ( f = flist ; f != NULL; f = f->cf_next ) {
-               int rc = test_comp_filter( syn, a, bv, f );
+               int rc = test_comp_filter( syn, a, f );
                if ( rc == LDAP_COMPARE_TRUE ) {
                        rtn = rc;
                        break;
@@ -1194,7 +1220,7 @@ test_comp_filter_or(
 
 int
 csi_value_match( MatchingRule *mr, struct berval* bv_attr,
-               struct berval* bv_assert )
+       struct berval* bv_assert )
 {
        int rc;
        int match;
@@ -1202,16 +1228,14 @@ csi_value_match( MatchingRule *mr, struct berval* bv_attr,
        assert( mr != NULL );
        assert( !(mr->smr_usage & SLAP_MR_COMPONENT) );
 
-       if( !mr->smr_match ) {
-               return LDAP_INAPPROPRIATE_MATCHING;
-       }
+       if( !mr->smr_match ) return LDAP_INAPPROPRIATE_MATCHING;
 
        rc = (mr->smr_match)( &match, 0, NULL /*ad->ad_type->sat_syntax*/,
-                               mr, bv_attr, bv_assert );
-       if ( rc == LDAP_SUCCESS )
-               return match? LDAP_COMPARE_FALSE:LDAP_COMPARE_TRUE;
-       else
-               return rc;
+               mr, bv_attr, bv_assert );
+
+       if ( rc != LDAP_SUCCESS ) return rc;
+
+       return match ? LDAP_COMPARE_FALSE : LDAP_COMPARE_TRUE;
 }
 
 /*
@@ -1221,7 +1245,6 @@ static int
 test_comp_filter_item(
        Syntax *syn,
        ComponentSyntaxInfo *csi_attr,
-       struct berval   *bv,
        ComponentAssertion *ca )
 {
        int rc, len;
@@ -1230,7 +1253,7 @@ test_comp_filter_item(
        if ( strcmp(ca->ca_ma_rule->smr_mrule.mr_oid,
                OID_COMP_FILTER_MATCH ) == 0 && ca->ca_cf ) {
                /* componentFilterMatch inside of componentFilterMatch */
-               rc = test_comp_filter( syn, csi_attr, bv, ca->ca_cf );
+               rc = test_comp_filter( syn, csi_attr, ca->ca_cf );
                return rc;
        }
 
@@ -1246,14 +1269,15 @@ test_comp_filter_item(
                        return LDAP_PROTOCOL_ERROR;
                }
                ca->ca_comp_data.cd_mem_op = assert_nm;
-       }
-       else {
+
+       else {
                assert_nm = ca->ca_comp_data.cd_mem_op;
        }
 
        /* component reference initialization */
-       if ( ca->ca_comp_ref )
+       if ( ca->ca_comp_ref ) {
                ca->ca_comp_ref->cr_curr = ca->ca_comp_ref->cr_list;
+       }
        rc = test_components( attr_nm, assert_nm, csi_attr, ca );
 
        /* free memory used for storing extracted attribute value */
@@ -1265,7 +1289,6 @@ static int
 test_comp_filter(
     Syntax *syn,
     ComponentSyntaxInfo *a,
-    struct berval *bv,
     ComponentFilter *f )
 {
        int     rc;
@@ -1278,13 +1301,13 @@ test_comp_filter(
                rc = f->cf_result;
                break;
        case LDAP_COMP_FILTER_AND:
-               rc = test_comp_filter_and( syn, a, bv, f->cf_and );
+               rc = test_comp_filter_and( syn, a, f->cf_and );
                break;
        case LDAP_COMP_FILTER_OR:
-               rc = test_comp_filter_or( syn, a, bv, f->cf_or );
+               rc = test_comp_filter_or( syn, a, f->cf_or );
                break;
        case LDAP_COMP_FILTER_NOT:
-               rc = test_comp_filter( syn, a, bv, f->cf_not );
+               rc = test_comp_filter( syn, a, f->cf_not );
 
                switch ( rc ) {
                case LDAP_COMPARE_TRUE:
@@ -1296,7 +1319,7 @@ test_comp_filter(
                }
                break;
        case LDAP_COMP_FILTER_ITEM:
-               rc = test_comp_filter_item( syn, a, bv, f->cf_ca );
+               rc = test_comp_filter_item( syn, a, f->cf_ca );
                break;
        default:
                rc = LDAP_PROTOCOL_ERROR;
@@ -1309,8 +1332,7 @@ static void
 free_comp_filter_list( ComponentFilter* f )
 {
        ComponentFilter* tmp;
-       for ( tmp = f; tmp; tmp = tmp->cf_next )
-       {
+       for ( tmp = f; tmp; tmp = tmp->cf_next ) {
                free_comp_filter( tmp );
        }
 }
@@ -1319,7 +1341,9 @@ static void
 free_comp_filter( ComponentFilter* f )
 {
        if ( !f ) {
-               Debug( LDAP_DEBUG_FILTER, "free_comp_filter:Invalid filter so failed to release memory\n", 0, 0, 0 );
+               Debug( LDAP_DEBUG_FILTER,
+                       "free_comp_filter: Invalid filter so failed to release memory\n",
+                       0, 0, 0 );
                return;
        }
        switch ( f->cf_choice ) {
@@ -1331,10 +1355,10 @@ free_comp_filter( ComponentFilter* f )
                free_comp_filter( f->cf_any );
                break;
        case LDAP_COMP_FILTER_ITEM:
-               if ( nibble_mem_free && f->cf_ca->ca_comp_data.cd_mem_op )
+               if ( nibble_mem_free && f->cf_ca->ca_comp_data.cd_mem_op ) {
                        nibble_mem_free( f->cf_ca->ca_comp_data.cd_mem_op );
+               }
                break;
-
        default:
                break;
        }
index 876e96b7998d2c4659b81f44caa7b7ff5785b4e8..5cc3b4c9cb34d1a033c3c4537c884a29939a9a6e 100644 (file)
@@ -1,7 +1,25 @@
+/* component.h */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2004-2005 The OpenLDAP Foundation.
+ * Portions Copyright 2004 by IBM Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+
 #ifndef _H_SLAPD_COMPONENT
 #define _H_SLAPD_COMPONENT
 
 #include "portable.h"
+
 #include <ac/string.h>
 #include <ac/socket.h>
 #include <ldap_pvt.h>
@@ -39,20 +57,20 @@ typedef enum { ASN_BASIC, ASN_COMPOSITE } AsnType;
  */
 #define MAX_ALIASING_ENTRY 128
 typedef struct comp_attribute_aliasing {
-        AttributeDescription*  aa_aliasing_ad;
-        AttributeDescription*  aa_aliased_ad;
-        ComponentFilter*       aa_cf;
+       AttributeDescription*   aa_aliasing_ad;
+       AttributeDescription*   aa_aliased_ad;
+       ComponentFilter*        aa_cf;
        MatchingRule*           aa_mr;
        char*                   aa_cf_str;
 } AttributeAliasing;
                                                                                  
 typedef struct comp_matchingrule_aliasing {
-        MatchingRule*  mra_aliasing_attr;
-        MatchingRule*  mra_aliased_attr;
-        AttributeDescription*  mra_attr;
-        ComponentFilter*       mra_cf;
+       MatchingRule*   mra_aliasing_attr;
+       MatchingRule*   mra_aliased_attr;
+       AttributeDescription*   mra_attr;
+       ComponentFilter*        mra_cf;
        MatchingRule*           mra_mr;
-       char*                   aa_cf_str;
+       char*                   mra_cf_str;
 } MatchingRuleAliasing;
 
 #endif
index d9cffd78ed07fd24bfbaf33eb0740ec9b98a8636..8695fcd11c83a8b6544acdac4fd1ffa4b4dfd7f7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -195,7 +195,7 @@ ConfigTable SystemConfiguration[] = {
   { "ucdata-path",             2,  2,  0,  "path",     ARG_IGNORED,            NULL,                           NULL, NULL, NULL },
   { "sizelimit",               2,  2,  0,  "limit",    ARG_MAGIC|CFG_SIZE,     &config_sizelimit,              NULL, NULL, NULL },
   { "timelimit",               2,  2,  0,  "limit",    ARG_MAGIC|CFG_TIME,     &config_timelimit,              NULL, NULL, NULL },
-  { "limits",                  2,  2,  0,  "limits",   ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic,           NULL, NULL, NULL },
+  { "limits",                  2,  0,  0,  "limits",   ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic,           NULL, NULL, NULL },
   { "overlay",                 2,  2,  0,  "overlay",  ARG_MAGIC,              &config_overlay,                NULL, NULL, NULL },
   { "suffix",                  2,  2,  0,  "suffix",   ARG_DB|ARG_MAGIC,       &config_suffix,                 NULL, NULL, NULL },
   { "maxDerefDepth",           2,  2,  0,  "depth",    ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic,    NULL, NULL, NULL },
@@ -1637,9 +1637,7 @@ add_syncrepl(
 )
 {
        syncinfo_t *si;
-       syncinfo_t *si_entry;
        int     rc = 0;
-       int duplicated_replica_id = 0;
 
        si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
 
@@ -1649,9 +1647,6 @@ add_syncrepl(
        }
 
        si->si_tls = SYNCINFO_TLS_OFF;
-       if ( be->be_rootndn.bv_val ) {
-               ber_dupbv( &si->si_updatedn, &be->be_rootndn );
-       }
        si->si_bindmethod = LDAP_AUTH_SIMPLE;
        si->si_schemachecking = 0;
        ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
@@ -1670,9 +1665,6 @@ add_syncrepl(
        si->si_retryinterval = NULL;
        si->si_retrynum_init = NULL;
        si->si_retrynum = NULL;
-       si->si_syncCookie.ctxcsn = NULL;
-       si->si_syncCookie.octet_str = NULL;
-       si->si_syncCookie.sid = -1;
        si->si_manageDSAit = 0;
        si->si_tlimit = 0;
        si->si_slimit = 0;
@@ -1682,28 +1674,20 @@ add_syncrepl(
 
        rc = parse_syncrepl_line( cargv, cargc, si );
 
-       LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
-               if ( si->si_rid == si_entry->si_rid ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "add_syncrepl: duplicated replica id\n",0, 0, 0 );
-                       duplicated_replica_id = 1;
-                       break;
-               }
-       }
-
-       if ( rc < 0 || duplicated_replica_id ) {
+       if ( rc < 0 ) {
                Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
                syncinfo_free( si );    
                return 1;
        } else {
                Debug( LDAP_DEBUG_CONFIG,
                        "Config: ** successfully added syncrepl \"%s\"\n",
-                       si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
+                       BER_BVISNULL( &si->si_provideruri ) ?
+                       "(null)" : si->si_provideruri.bv_val, 0, 0 );
                if ( !si->si_schemachecking ) {
                        SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
                }
                si->si_be = be;
-               LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
+               be->be_syncinfo = si;
                return 0;
        }
 }
@@ -1721,7 +1705,6 @@ add_syncrepl(
 #define SLIMITSTR              "sizelimit"
 #define TLIMITSTR              "timelimit"
 #define SCHEMASTR              "schemachecking"
-#define UPDATEDNSTR            "updatedn"
 #define BINDMETHSTR            "bindmethod"
 #define SIMPLESTR                      "simple"
 #define SASLSTR                                "sasl"
@@ -1748,6 +1731,7 @@ add_syncrepl(
 #define LMREQSTR               "req"
 #define SRVTABSTR              "srvtab"
 #define SUFFIXSTR              "suffix"
+#define UPDATEDNSTR            "updatedn"
 
 /* mandatory */
 #define GOT_ID                 0x0001
@@ -1787,13 +1771,7 @@ parse_syncrepl_line(
                                        STRLENOF( PROVIDERSTR "=" ) ) )
                {
                        val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
-                       si->si_provideruri = ch_strdup( val );
-                       si->si_provideruri_bv = (BerVarray)
-                               ch_calloc( 2, sizeof( struct berval ));
-                       ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
-                               1, &si->si_provideruri_bv[0] );
-                       si->si_provideruri_bv[1].bv_len = 0;
-                       si->si_provideruri_bv[1].bv_val = NULL;
+                       ber_str2bv( val, 0, 1, &si->si_provideruri );
                        gots |= GOT_PROVIDER;
                } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
                                        STRLENOF(STARTTLSSTR "=") ) )
@@ -1804,23 +1782,6 @@ parse_syncrepl_line(
                        } else {
                                si->si_tls = SYNCINFO_TLS_ON;
                        }
-               } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
-                                       STRLENOF( UPDATEDNSTR "=" ) ) )
-               {
-                       struct berval   updatedn = BER_BVNULL;
-                       int             rc;
-
-                       val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
-                       ber_str2bv( val, 0, 0, &updatedn );
-                       ch_free( si->si_updatedn.bv_val );
-                       rc = dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
-                       if ( rc != LDAP_SUCCESS ) {
-                               fprintf( stderr, "Error: parse_syncrepl_line: "
-                                       "update DN \"%s\" is invalid: %d (%s)\n",
-                                       updatedn, rc, ldap_err2string( rc ) );
-                               return -1;
-                       }
-                       
                } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
                                STRLENOF( BINDMETHSTR "=" ) ) )
                {
index 04a4f0900b2695ba8f02bf05263868358e9b6a6e..0abd270013dec9350448289962ccb256b451ed04 100644 (file)
@@ -3,7 +3,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 63784d8419f31cf2d330b346504b7616be1e5b7e..d59d403e7a09126e192d283251cbe8cc7965e3e6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1061,27 +1061,11 @@ operations_error:
 
        ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx_null );
 
-#if 0  /* DELETE ME */
-       if ( op->o_cancel != SLAP_CANCEL_ACK &&
-               ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
-       {
-               slap_sl_mem_detach( ctx, memctx );
-       } else if ( op->o_sync_slog_size != -1 ) {
-               slap_sl_mem_detach( ctx, memctx );
-               LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
-               LDAP_STAILQ_NEXT(op, o_next) = NULL;
-               conn->c_n_ops_executing--;
-               conn->c_n_ops_completed++;
-
-       } else
-#endif
-       {
-               LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
-               LDAP_STAILQ_NEXT(op, o_next) = NULL;
-               slap_op_free( op );
-               conn->c_n_ops_executing--;
-               conn->c_n_ops_completed++;
-       }
+       LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
+       LDAP_STAILQ_NEXT(op, o_next) = NULL;
+       slap_op_free( op );
+       conn->c_n_ops_executing--;
+       conn->c_n_ops_completed++;
 
        switch( tag ) {
        case LBER_ERROR:
@@ -1426,7 +1410,7 @@ connection_input(
        }
 #endif
        if(tag == LDAP_REQ_BIND) {
-               /* immediately abandon all exiting operations upon BIND */
+               /* immediately abandon all existing operations upon BIND */
                connection_abandon( conn );
        }
 
@@ -1655,8 +1639,6 @@ int connection_write(ber_socket_t s)
 
        c = connection_get( s );
 
-       slapd_clr_write( s, 0);
-
        if( c == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                        "connection_write(%ld): no connection!\n",
@@ -1666,6 +1648,8 @@ int connection_write(ber_socket_t s)
                return -1;
        }
 
+       slapd_clr_write( s, 0);
+
        c->c_n_write++;
 
        Debug( LDAP_DEBUG_TRACE,
index 60db9aa4119ab73f03fccf55d3a1fe19eb7ce2fb..8d0114917245a9cce44f0e43a217d687f8d4ee76 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,10 +37,7 @@ static SLAP_CTRL_PARSE_FN parsePermissiveModify;
 static SLAP_CTRL_PARSE_FN parseDomainScope;
 static SLAP_CTRL_PARSE_FN parseTreeDelete;
 static SLAP_CTRL_PARSE_FN parseSearchOptions;
-
-#ifdef LDAP_CONTROL_SUBENTRIES
 static SLAP_CTRL_PARSE_FN parseSubentries;
-#endif
 
 #undef sc_mask /* avoid conflict with Irix 6.5 <sys/signal.h> */
 
@@ -127,10 +124,10 @@ static struct slap_control control_defs[] = {
                SLAP_CTRL_MODIFY, NULL,
                parsePermissiveModify, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
-#ifdef LDAP_CONTROL_X_TREE_DELETE
+#ifdef SLAP_CONTROL_X_TREE_DELETE
        { LDAP_CONTROL_X_TREE_DELETE,
                (int)offsetof(struct slap_control_ids, sc_treeDelete),
-               SLAP_CTRL_DELETE, NULL,
+               SLAP_CTRL_HIDE|SLAP_CTRL_DELETE, NULL,
                parseTreeDelete, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
 #ifdef LDAP_CONTORL_X_SEARCH_OPTIONS
@@ -830,13 +827,6 @@ static int parsePagedResults (
                return LDAP_PROTOCOL_ERROR;
        }
 
-#if 0  /* DELETE ME */
-       if ( op->o_sync != SLAP_CONTROL_NONE ) {
-               rs->sr_text = "paged results control specified with sync control";
-               return LDAP_PROTOCOL_ERROR;
-       }
-#endif
-
        if ( BER_BVISEMPTY( &ctrl->ldctl_value ) ) {
                rs->sr_text = "paged results control value is empty (or absent)";
                return LDAP_PROTOCOL_ERROR;
@@ -1313,7 +1303,10 @@ static int parseSearchOptions (
        }
 
        if ( search_flags & ~(LDAP_SEARCH_FLAG_DOMAIN_SCOPE) ) {
-               /* Other search flags not recognised so far */
+               /* Other search flags not recognised so far,
+                * including:
+                *              LDAP_SEARCH_FLAG_PHANTOM_ROOM
+                */
                rs->sr_text = "searchOptions contained unrecongized flag";
                return LDAP_UNWILLING_TO_PERFORM;
        }
index 4280b740e6978818b6a2c0a0c2712fbc8a9c13c0..4459cb66b0973686a9ff326c5a15cd7a81903b90 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3e99830e3ceb1e949545e4541f4eee44dbd4800b..defcac2e89dec319756c4d99f707dc9e1b4b078c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
index 625747e9249e7654246f939b5b2b2cab23b73a4b..17122347577d820caa66eb702dcd9c7c0724da1f 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1844,6 +1844,7 @@ slapd_daemon_task(
                                }
                                slapd_close( wd );
                        }
+                       SLAP_EVENT_CLR_WRITE( wd );
                }
 
                for ( i = 0; nrfds > 0; i++ )
index 61375da9ec73e3416205100076b341aae2891320..a1004f7967a57a0160130e35eb52617ed0ef0e48 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 42d4be5990c03a2a82ed90a4c9b4b24926bfc5ef..6ed1b0cda032e9a15af34ea0547824779e2a15ea 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 13fee4fc2872975a9d868ad076fcaca123da37a4..11dfa830229c7c618bb19ea9087c7d9b6ab5896a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,8 @@ const Entry slap_entry_root = {
        NOID, { 0, "" }, { 0, "" }, NULL, 0, { 0, "" }, NULL
 };
 
+static const struct berval dn_bv = BER_BVC("dn");
+
 int entry_destroy(void)
 {
        if ( ebuf ) free( ebuf );
@@ -62,13 +64,14 @@ str2entry( char *s )
 {
        int rc;
        Entry           *e;
-       char            *type;
+       struct berval   type;
        struct berval   vals[2];
        struct berval   nvals[2], *nvalsp;
        AttributeDescription *ad, *ad_prev;
        const char *text;
        char    *next;
        int             attr_cnt;
+       int             freeval;
 
        /*
         * LDIF is used as the string format.
@@ -114,60 +117,57 @@ str2entry( char *s )
                        break;
                }
 
-               if ( ldif_parse_line( s, &type, &vals[0].bv_val, &vals[0].bv_len ) != 0 ) {
+               if ( ldif_parse_line2( s, &type, vals, &freeval ) != 0 ) {
                        Debug( LDAP_DEBUG_TRACE,
                                "<= str2entry NULL (parse_line)\n", 0, 0, 0 );
                        continue;
                }
 
-               if ( strcasecmp( type, "dn" ) == 0 ) {
-                       free( type );
+               if ( type.bv_len == dn_bv.bv_len &&
+                       strcasecmp( type.bv_val, dn_bv.bv_val ) == 0 ) {
 
                        if ( e->e_dn != NULL ) {
                                Debug( LDAP_DEBUG_ANY, "str2entry: "
                                        "entry %ld has multiple DNs \"%s\" and \"%s\"\n",
                                        (long) e->e_id, e->e_dn, vals[0].bv_val );
-                               free( vals[0].bv_val );
+                               if ( freeval ) free( vals[0].bv_val );
                                entry_free( e );
                                return NULL;
                        }
 
                        rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname, NULL );
+                       if ( freeval ) free( vals[0].bv_val );
                        if( rc != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY, "str2entry: "
                                        "entry %ld has invalid DN \"%s\"\n",
                                        (long) e->e_id, vals[0].bv_val, 0 );
                                entry_free( e );
-                               free( vals[0].bv_val );
                                return NULL;
                        }
-                       free( vals[0].bv_val );
                        continue;
                }
 
                ad_prev = ad;
                ad = NULL;
-               rc = slap_str2ad( type, &ad, &text );
+               rc = slap_bv2ad( &type, &ad, &text );
 
                if( rc != LDAP_SUCCESS ) {
                        Debug( slapMode & SLAP_TOOL_MODE
                                ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE,
-                               "<= str2entry: str2ad(%s): %s\n", type, text, 0 );
+                               "<= str2entry: str2ad(%s): %s\n", type.bv_val, text, 0 );
                        if( slapMode & SLAP_TOOL_MODE ) {
                                entry_free( e );
-                               free( vals[0].bv_val );
-                               free( type );
+                               if ( freeval ) free( vals[0].bv_val );
                                return NULL;
                        }
 
-                       rc = slap_str2undef_ad( type, &ad, &text );
+                       rc = slap_bv2undef_ad( &type, &ad, &text );
                        if( rc != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY,
                                        "<= str2entry: str2undef_ad(%s): %s\n",
-                                               type, text, 0 );
+                                               type.bv_val, text, 0 );
                                entry_free( e );
-                               free( vals[0].bv_val );
-                               free( type );
+                               if ( freeval ) free( vals[0].bv_val );
                                return NULL;
                        }
                }
@@ -200,8 +200,7 @@ str2entry( char *s )
                                        ad->ad_cname.bv_val, attr_cnt,
                                        ad->ad_type->sat_syntax->ssyn_oid );
                                entry_free( e );
-                               free( vals[0].bv_val );
-                               free( type );
+                               if ( freeval ) free( vals[0].bv_val );
                                return NULL;
                        }
 
@@ -212,14 +211,14 @@ str2entry( char *s )
                                        ad->ad_cname.bv_val, attr_cnt,
                                        ad->ad_type->sat_syntax->ssyn_oid );
                                entry_free( e );
-                               free( vals[0].bv_val );
-                               free( type );
+                               if ( freeval ) free( vals[0].bv_val );
                                return NULL;
                        }
 
                        if( pretty ) {
-                               free( vals[0].bv_val );
+                               if ( freeval ) free( vals[0].bv_val );
                                vals[0] = pval;
+                               freeval = 1;
                        }
                }
 
@@ -240,8 +239,7 @@ str2entry( char *s )
                                        "<= str2entry NULL (smr_normalize %d)\n", rc, 0, 0 );
 
                                entry_free( e );
-                               free( vals[0].bv_val );
-                               free( type );
+                               if ( freeval ) free( vals[0].bv_val );
                                return NULL;
                        }
 
@@ -256,13 +254,11 @@ str2entry( char *s )
                        Debug( LDAP_DEBUG_ANY,
                                "<= str2entry NULL (attr_merge)\n", 0, 0, 0 );
                        entry_free( e );
-                       free( vals[0].bv_val );
-                       free( type );
+                       if ( freeval ) free( vals[0].bv_val );
                        return( NULL );
                }
 
-               free( type );
-               free( vals[0].bv_val );
+               if ( freeval ) free( vals[0].bv_val );
                free( nvals[0].bv_val );
 
                attr_cnt++;
index 9a010e812a9764faf0e475f9ad453e4c5880adcd..6d3237cae4b796b0de47efe423bc699a51dae28a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -183,6 +183,7 @@ do_extended(
 
        op->o_bd = frontendDB;
        rs->sr_err = frontendDB->be_extended( op, rs );
+
 done:
        return rs->sr_err;
 }
index df96a225f44ffbb9beb68e6df99105b59aea9e30..0bfc702e6a03d3469633317f62c67e7e0deea4dc 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 80b44f22d94de9150b47f448cb48c28384477280..66ffc4f6413d12686585d7af68aa375906d8d5d9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -154,6 +154,9 @@ static int test_mra_filter(
        Attribute       *a;
        void            *memctx;
        BER_MEMFREE_FN  *memfree;
+#ifdef LDAP_COMP_MATCH
+       int i, num_attr_vals;
+#endif
 
        if ( op == NULL ) {
                memctx = NULL;
@@ -195,18 +198,33 @@ static int test_mra_filter(
                        struct berval *bv;
 #ifdef LDAP_COMP_MATCH
                        /* Component Matching */
-                       if( mra->ma_cf &&
-                               mra->ma_rule->smr_usage & SLAP_MR_COMPONENT )
-                       {
-                               int ret;
-                               int rc;
-                               const char *text;
-
-                               rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
-                                       (struct berval *)a,(void*) mra , &text );
-                               if ( rc != LDAP_SUCCESS ) return rc;
-                               if ( ret == 0 ) return LDAP_COMPARE_TRUE;
-                               else return LDAP_COMPARE_FALSE;
+                       if( mra->ma_cf && mra->ma_rule->smr_usage & SLAP_MR_COMPONENT ) {
+                               num_attr_vals = 0;
+                               if ( !a->a_comp_data ) {
+                                       for ( ;
+                                               a->a_vals[num_attr_vals].bv_val != NULL;
+                                               num_attr_vals++ )
+                                       {
+                                               /* empty */;
+                                       }
+                                       if ( num_attr_vals <= 0 ) {
+                                               /* no attribute value */
+                                               return LDAP_INAPPROPRIATE_MATCHING;
+                                       }
+                                       num_attr_vals++;
+
+                                       /* following malloced will be freed by comp_tree_free () */
+                                       a->a_comp_data = malloc( sizeof( ComponentData ) +
+                                               sizeof( ComponentSyntaxInfo* )*num_attr_vals );
+
+                                       if ( !a->a_comp_data ) return LDAP_NO_MEMORY;
+                                       a->a_comp_data->cd_tree = (ComponentSyntaxInfo**)
+                                               ((char*)a->a_comp_data + sizeof(ComponentData));
+                                       a->a_comp_data->cd_tree[num_attr_vals - 1] =
+                                               (ComponentSyntaxInfo*) NULL;
+                                       a->a_comp_data->cd_mem_op =
+                                               nibble_mem_allocator( 1024*16, 1024 );
+                               }
                        }
 #endif
 
@@ -218,14 +236,35 @@ static int test_mra_filter(
                        } else {
                                bv = a->a_vals;
                        }
-
+#ifdef LDAP_COMP_MATCH
+                       i = 0;
+#endif
                        for ( ; bv->bv_val != NULL; bv++ ) {
                                int ret;
                                int rc;
                                const char *text;
        
-                               rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
-                                       bv, &mra->ma_value, &text );
+#ifdef LDAP_COMP_MATCH
+                               if( mra->ma_cf &&
+                                       mra->ma_rule->smr_usage & SLAP_MR_COMPONENT ) {
+                                       /* Check if decoded component trees are already linked */
+                                       if ( num_attr_vals ) {
+                                               a->a_comp_data->cd_tree[i] = attr_converter(
+                                                       a, a->a_desc->ad_type->sat_syntax, bv );
+                                       }
+                                       /* decoding error */
+                                       if ( !a->a_comp_data->cd_tree[i] ) {
+                                               return LDAP_OPERATIONS_ERROR;
+                                       }
+                                       rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
+                                               (struct berval*)a->a_comp_data->cd_tree[i++],
+                                               (void*)mra, &text );
+                               } else 
+#endif
+                               {
+                                       rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
+                                               bv, &mra->ma_value, &text );
+                               }
 
                                if( rc != LDAP_SUCCESS ) return rc;
                                if ( ret == 0 ) return LDAP_COMPARE_TRUE;
@@ -544,7 +583,7 @@ test_presence_filter(
                 * XXX: fairly optimistic: if the function is defined,
                 * then PRESENCE must succeed, because hasSubordinate
                 * is boolean-valued; I think we may live with this 
-                * simplification by now
+                * simplification by now.
                 */
                if ( op && op->o_bd && op->o_bd->be_has_subordinates ) {
                        return LDAP_COMPARE_TRUE;
index 1495edd176aef17af8fbfd45d05f22007f754930..e1fca24d32d4eb01ffc1aea3dca32948316b20ce 100644 (file)
@@ -1,7 +1,7 @@
 /* frontend.c - routines for dealing with frontend */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,8 +69,6 @@ frontend_init( void )
        /* FIXME: do we need this? */
        frontendDB->be_pcl_mutexp = &frontendDB->be_pcl_mutex;
        ldap_pvt_thread_mutex_init( frontendDB->be_pcl_mutexp );
-
-       LDAP_STAILQ_INIT( &frontendDB->be_syncinfo );
 #endif
 
        /* suffix */
index 5039069fd8a07cae574ea31604acfef80f5c8662..8cba81ec5eac8adc004b830bb79770cb2c1f21f1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3bfc4c630f0629c6fe865995b136b203ddd52df0..09ea1dc5c54a5b0e0172f830c0892b590432e851 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b7a3fc3bac0a9d8e2094767c8c043049dba22550..1c34f10d3ed526714d827c571029479e5e95ffbb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2fe5afe2f5f1fadbf07522306dae7ef14459af07..a8d1e441dabbf4ec2b82c6247fe631c06fd7d26e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6f6cefea3430f4024604d77824511bc045fe00e6..5ecf2590f799c9c4c5f52edaa29b985b5a397f1b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
 #include "../../libraries/liblber/lber-int.h" /* get ber_strndup() */
 #include "lutil_ldap.h"
 
-#if 0
-struct sync_cookie *slap_sync_cookie = NULL;
-#else
 struct slap_sync_cookie_s slap_sync_cookie =
        LDAP_STAILQ_HEAD_INITIALIZER( slap_sync_cookie );
-#endif
 
 void
 slap_compose_sync_cookie(
        Operation *op,
        struct berval *cookie,
        struct berval *csn,
-       int sid,
        int rid )
 {
        char cookiestr[ LDAP_LUTIL_CSNSTR_BUFSIZE + 20 ];
 
-       if ( csn->bv_val == NULL ) {
-               if ( sid == -1 ) {
-                       if ( rid == -1 ) {
-                               cookiestr[0] = '\0';
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "rid=%03d", rid );
-                       }
+       if ( BER_BVISNULL( csn )) {
+               if ( rid == -1 ) {
+                       cookiestr[0] = '\0';
                } else {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "sid=%03d", sid );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "sid=%03d,rid=%03d", sid, rid );
-                       }
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "rid=%03d", rid );
                }
        } else {
-               if ( sid == -1 ) {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s", csn->bv_val );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,rid=%03d", csn->bv_val, rid );
-                       }
+               if ( rid == -1 ) {
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "csn=%s", csn->bv_val );
                } else {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,sid=%03d", csn->bv_val, sid );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,sid=%03d,rid=%03d", csn->bv_val, sid, rid );
-                       }
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "csn=%s,rid=%03d", csn->bv_val, rid );
                }
        }
        ber_str2bv( cookiestr, strlen(cookiestr), 1, cookie );
@@ -92,14 +67,14 @@ slap_sync_cookie_free(
        if ( cookie == NULL )
                return;
 
-       if ( cookie->ctxcsn ) {
-               ber_bvarray_free( cookie->ctxcsn );
-               cookie->ctxcsn = NULL;
+       if ( !BER_BVISNULL( &cookie->ctxcsn )) {
+               ch_free( cookie->ctxcsn.bv_val );
+               BER_BVZERO( &cookie->ctxcsn );
        }
 
-       if ( cookie->octet_str ) {
-               ber_bvarray_free( cookie->octet_str );
-               cookie->octet_str = NULL;
+       if ( !BER_BVISNULL( &cookie->octet_str )) {
+               ch_free( cookie->octet_str.bv_val );
+               BER_BVZERO( &cookie->octet_str );
        }
 
        if ( free_cookie ) {
@@ -118,17 +93,14 @@ slap_parse_sync_cookie(
        char *csn_str;
        int csn_str_len;
        int valid = 0;
-       char *sid_ptr;
-       char *sid_str;
        char *rid_ptr;
        char *rid_str;
        char *cval;
-       struct berval ctxcsn;
 
        if ( cookie == NULL )
                return -1;
 
-       while (( csn_ptr = strstr( cookie->octet_str[0].bv_val, "csn=" )) != NULL ) {
+       while (( csn_ptr = strstr( cookie->octet_str.bv_val, "csn=" )) != NULL ) {
                AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp;
                slap_syntax_validate_func *validate;
                struct berval stamp;
@@ -153,25 +125,12 @@ slap_parse_sync_cookie(
                break;
        }
        if ( valid ) {
-               ber_str2bv( csn_str, csn_str_len, 1, &ctxcsn );
-               ber_bvarray_add( &cookie->ctxcsn, &ctxcsn );
+               ber_str2bv( csn_str, csn_str_len, 1, &cookie->ctxcsn );
        } else {
-               cookie->ctxcsn = NULL;
+               BER_BVZERO( &cookie->ctxcsn );
        }
 
-       if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) {
-               sid_str = SLAP_STRNDUP( sid_ptr,
-                                                       SLAP_SYNC_SID_SIZE + sizeof("sid=") - 1 );
-               if ( (cval = strchr( sid_str, ',' )) != NULL ) {
-                       *cval = '\0';
-               }
-               cookie->sid = atoi( sid_str + sizeof("sid=") - 1 );
-               ch_free( sid_str );
-       } else {
-               cookie->sid = -1;
-       }
-
-       if (( rid_ptr = strstr( cookie->octet_str->bv_val, "rid=" )) != NULL ) {
+       if (( rid_ptr = strstr( cookie->octet_str.bv_val, "rid=" )) != NULL ) {
                rid_str = SLAP_STRNDUP( rid_ptr,
                                                        SLAP_SYNC_RID_SIZE + sizeof("rid=") - 1 );
                if ( (cval = strchr( rid_str, ',' )) != NULL ) {
@@ -193,8 +152,6 @@ slap_init_sync_cookie_ctxcsn(
        char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE + 4 ];
        struct berval octet_str = BER_BVNULL;
        struct berval ctxcsn = BER_BVNULL;
-       struct berval ctxcsn_dup = BER_BVNULL;
-       struct berval slap_syncCookie;
 
        if ( cookie == NULL )
                return -1;
@@ -203,15 +160,12 @@ slap_init_sync_cookie_ctxcsn(
                                        "csn=%4d%02d%02d%02d%02d%02dZ#%06x#%02x#%06x",
                                        1900, 1, 1, 0, 0, 0, 0, 0, 0 );
        octet_str.bv_val = csnbuf;
-       build_new_dn( &slap_syncCookie, &cookie->octet_str[0], &octet_str, NULL );
-       ber_bvarray_free( cookie->octet_str );
-       cookie->octet_str = NULL;
-       ber_bvarray_add( &cookie->octet_str, &slap_syncCookie );
+       ch_free( cookie->octet_str.bv_val );
+       ber_dupbv( &cookie->octet_str, &octet_str );
 
        ctxcsn.bv_val = octet_str.bv_val + 4;
        ctxcsn.bv_len = octet_str.bv_len - 4;
-       ber_dupbv( &ctxcsn_dup, &ctxcsn );
-       ber_bvarray_add( &cookie->ctxcsn, &ctxcsn_dup );
+       ber_dupbv( &cookie->ctxcsn, &ctxcsn );
 
        return 0;
 }
@@ -230,29 +184,24 @@ slap_dup_sync_cookie(
                return NULL;
 
        if ( dst ) {
-               ber_bvarray_free( dst->ctxcsn );
-               ber_bvarray_free( dst->octet_str );
+               ch_free( dst->ctxcsn.bv_val );
+               ch_free( dst->octet_str.bv_val );
+               BER_BVZERO( &dst->ctxcsn );
+               BER_BVZERO( &dst->octet_str );
                new = dst;
        } else {
                new = ( struct sync_cookie * )
                                ch_calloc( 1, sizeof( struct sync_cookie ));
        }
 
-       new->sid = src->sid;
        new->rid = src->rid;
 
-       if ( src->ctxcsn ) {
-               for ( i=0; src->ctxcsn[i].bv_val; i++ ) {
-                       ber_dupbv( &tmp_bv, &src->ctxcsn[i] );
-                       ber_bvarray_add( &new->ctxcsn, &tmp_bv );
-               }
+       if ( !BER_BVISNULL( &src->ctxcsn )) {
+               ber_dupbv( &new->ctxcsn, &src->ctxcsn );
        }
 
-       if ( src->octet_str ) {
-               for ( i=0; src->octet_str[i].bv_val; i++ ) {
-                       ber_dupbv( &tmp_bv, &src->octet_str[i] );
-                       ber_bvarray_add( &new->octet_str, &tmp_bv );
-               }
+       if ( !BER_BVISNULL( &src->octet_str )) {
+               ber_dupbv( &new->octet_str, &src->octet_str );
        }
 
        return new;
index ab5130e4dcf68430ddc187314d8cca6d20ca3c52..49892a049ab8d727d286cc0c24a2c6c614ced13f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -494,8 +494,12 @@ limits_parse(
                        struct berval   oc, ad;
 
                        oc.bv_val = pattern + 1;
+                       pattern = strchr( pattern, '=' );
+                       if ( pattern == NULL ) {
+                               return -1;
+                       }
 
-                       ad.bv_val = strchr(pattern, '/');
+                       ad.bv_val = strchr( oc.bv_val, '/' );
                        if ( ad.bv_val != NULL ) {
                                const char      *text = NULL;
                                int             rc;
@@ -503,18 +507,14 @@ limits_parse(
                                oc.bv_len = ad.bv_val - oc.bv_val;
 
                                ad.bv_val++;
-                               ad.bv_len = strlen( ad.bv_val );
+                               ad.bv_len = pattern - ad.bv_val;
                                rc = slap_bv2ad( &ad, &group_ad, &text );
                                if ( rc != LDAP_SUCCESS ) {
                                        goto no_ad;
                                }
 
-                               pattern = ad.bv_val + ad.bv_len;
-
                        } else {
-                               oc.bv_len = strlen( oc.bv_val );
-
-                               pattern = oc.bv_val + oc.bv_len;
+                               oc.bv_len = pattern - oc.bv_val;
                        }
 
                        group_oc = oc_bvfind( &oc );
index 6e1ad3e1063f5d091fa20d88abde952d42147f00..1a8fc52a5786a9b9f092cc258867c4588d276d95 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -74,9 +74,10 @@ lock_fopen( const char *fname, const char *type, FILE **lfp )
 int
 lock_fclose( FILE *fp, FILE *lfp )
 {
+       int rc = fclose( fp );
        /* unlock */
        ldap_unlockf( fileno(lfp) );
        fclose( lfp );
 
-       return( fclose( fp ) );
+       return( rc );
 }
index d61c128392a6fade34dfb069b67f04453d9c7241..d458acb033e11974ad473f9420b665e098fbffce 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 98df13d80f2d631015543262d5dad5658e5aff5b..b95765ef93fa1bd7145916a02073b5731147d5c4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0aadd943c464f480adf5415caf40faf9ea52cfc2..88a120bd74fd9297b4517d54ee8c1ce43393bfdc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4e03e8a595664d0abd204721fb0170b9f68da3d9..44f97d059e9ff8d81f2a59bc1ea0f60c906c8f2d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -181,7 +181,6 @@ do_modrdn(
        rs->sr_err = frontendDB->be_modrdn( op, rs );
 
 cleanup:
-
        slap_graduate_commit_csn( op );
 
        op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
@@ -190,8 +189,10 @@ cleanup:
        op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );        
        op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );       
 
-       if ( pnewSuperior.bv_val ) op->o_tmpfree( pnewSuperior.bv_val, op->o_tmpmemctx );
-       if ( nnewSuperior.bv_val ) op->o_tmpfree( nnewSuperior.bv_val, op->o_tmpmemctx );
+       if ( !BER_BVISNULL( &pnewSuperior ) ) 
+               op->o_tmpfree( pnewSuperior.bv_val, op->o_tmpmemctx );
+       if ( !BER_BVISNULL( &nnewSuperior ) )
+               op->o_tmpfree( nnewSuperior.bv_val, op->o_tmpmemctx );
 
        return rs->sr_err;
 }
index a36cb5f17fe2908ee81e9deddfabc24cb5c44f03..6e7d7ec1c5b8e1e42f227d37253cf8a831bac9dd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 445c8180dd09615977fedc8171d4932c47860c6e..67175aaf2ebcf16c40f99a976e4f00dd4be199ee 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e810c3764871f5eb85c89f645245cc279ad9a332..89381cc38bb0114e6c37a39ed51fe2dc36747999 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b518e72735f5d3e1eb499fc2b5f530ebb03464c2..9337c39d1b4942b1eb2d1e44b9279d5738f4c5f1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f6eb4401aec50da51e087bbe82104025e7ed5a02..ce3480602cfd2cee72c4408e1816b2b1ec02dba8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 651041f93486f8ca10dad35905cf2bb151373e85..b7ac0ba4e0e6b1c0b2e127e1a21be9127e2dd08a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 15e5ac61c6127972b64f391f11cd601185859ba5..8e6bdad4cb7e724a9983c970e6bfac6991bc2551 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b7c180e4eec11399e993d08ccc8d5e2e7b95c0e7..e65fd4d7ad9c5e3dd3411d26128e7ce6cdf23077 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -108,16 +108,6 @@ slap_op_free( Operation *op )
        op->o_hdr = (Opheader *)(op+1);
        op->o_controls = (void **)(op->o_hdr+1);
 
-#if 0  /* DELETE ME */
-       slap_sync_cookie_free( &op->o_sync_state, 0 );
-       if ( op->o_sync_csn.bv_val != NULL ) {
-               ch_free( op->o_sync_csn.bv_val );
-       }
-       op->o_sync_state.sid = -1;
-       op->o_sync_slog_size = -1;
-       op->o_sync_state.rid = -1;
-#endif
-
        ldap_pvt_thread_mutex_lock( &slap_op_mutex );
        LDAP_STAILQ_INSERT_HEAD( &slap_free_ops, op, o_next );
        ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
@@ -155,14 +145,6 @@ slap_op_alloc(
        op->o_opid = id;
        op->o_res_ber = NULL;
 
-#if 0  /* DELETE ME */
-       op->o_sync_state.sid = -1;
-       op->o_sync_slog_size = -1;
-       op->o_sync_state.rid = -1;
-       LDAP_STAILQ_FIRST( &op->o_sync_slog_list ) = NULL;
-       op->o_sync_slog_list.stqh_last = &LDAP_STAILQ_FIRST( &op->o_sync_slog_list );
-#endif
-
 #if defined( LDAP_SLAPI )
        if ( slapi_plugins_used ) {
                op->o_pb = slapi_pblock_new();
index b64bc22cd2d72f48b9b9292514f6949bb2fabf54..f938076f0c5f3de69abb341473209ade25cc4168 100644 (file)
@@ -1,7 +1,7 @@
 /* operational.c - routines to deal with on-the-fly operational attrs */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 5e2210eb9f126ed834b2747854d925f399b91b5a..9f95972edc29e1c6eed49e797d7890c39224122e 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2003-2004 The OpenLDAP Foundation.
+## Copyright 2003-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,6 @@
 ## <http://www.OpenLDAP.org/license.html>.
 
 SRCS = overlays.c \
-       chain.c \
        denyop.c \
        dyngroup.c \
        glue.c \
@@ -26,7 +25,6 @@ SRCS = overlays.c \
        syncprov.c \
        unique.c
 OBJS = overlays.lo \
-       chain.lo \
        denyop.lo \
        dyngroup.lo \
        glue.lo \
@@ -53,9 +51,6 @@ PROGRAMS = @SLAPD_DYNAMIC_OVERLAYS@
 XINCPATH = -I.. -I$(srcdir)/..
 XDEFS = $(MODULES_CPPFLAGS)
 
-chain.la : chain.lo $(@PLAT@_LINK_LIBS)
-       $(LTLINK_MOD) -module -o $@ chain.lo version.lo $(LINK_LIBS)
-
 denyop.la : denyop.lo $(@PLAT@_LINK_LIBS)
        $(LTLINK_MOD) -module -o $@ denyop.lo version.lo $(LINK_LIBS)
 
diff --git a/servers/slapd/overlays/chain.c b/servers/slapd/overlays/chain.c
deleted file mode 100644 (file)
index 1b3ac75..0000000
+++ /dev/null
@@ -1,494 +0,0 @@
-/* chain.c - chain LDAP operations */
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 2003-2004 The OpenLDAP Foundation.
- * Portions Copyright 2003 Howard Chu.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Howard Chu for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#if defined(SLAPD_LDAP) 
-
-#ifdef SLAPD_OVER_CHAIN
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/socket.h>
-
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-
-static BackendInfo *lback;
-
-static int
-ldap_chain_chk_referrals( Operation *op, SlapReply *rs )
-{
-       return LDAP_SUCCESS;
-}
-
-static int
-ldap_chain_operational( Operation *op, SlapReply *rs )
-{
-       /* trap entries generated by back-ldap.
-        * FIXME: we need a better way to recognize them; a cleaner
-        * solution would be to be able to intercept the response
-        * of be_operational(), so that we can divert only those
-        * calls that fail because operational attributes were
-        * requested for entries that do not belong to the underlying
-        * database.  This fix is likely to intercept also entries
-        * generated by back-perl and so. */
-       if ( rs->sr_entry->e_private == NULL ) {
-               return 0;
-       }
-
-       return SLAP_CB_CONTINUE;
-}
-
-static int
-ldap_chain_cb_response( Operation *op, SlapReply *rs )
-{
-       assert( op->o_tag == LDAP_REQ_SEARCH );
-
-       if ( rs->sr_type == REP_SEARCH ) {
-               Attribute       **ap = &rs->sr_entry->e_attrs;
-
-               for ( ; *ap != NULL; ap = &(*ap)->a_next ) {
-                       /* will be generated later by frontend
-                        * (a cleaner solution would be that
-                        * the frontend checks if it already exists */
-                       if ( ad_cmp( (*ap)->a_desc, slap_schema.si_ad_entryDN ) == 0 )
-                       {
-                               Attribute *a = *ap;
-
-                               *ap = (*ap)->a_next;
-                               attr_free( a );
-
-                               /* there SHOULD be one only! */
-                               break;
-                       }
-               }
-               
-               return SLAP_CB_CONTINUE;
-       }
-
-       return 0;
-}
-
-static int
-ldap_chain_response( Operation *op, SlapReply *rs )
-{
-       slap_overinst   *on = (slap_overinst *) op->o_bd->bd_info;
-       void            *private = op->o_bd->be_private;
-       slap_callback   *sc = op->o_callback;
-       LDAPControl     **prev = op->o_ctrls;
-       LDAPControl     **ctrls = NULL, authz;
-       int             i, nctrls, rc = 0;
-       int             cache = op->o_do_not_cache;
-       char            *authzid = NULL;
-       BerVarray       ref;
-       struct berval   ndn = op->o_ndn;
-
-       struct ldapinfo li, *lip = (struct ldapinfo *)on->on_bi.bi_private;
-
-       if ( rs->sr_err != LDAP_REFERRAL && rs->sr_type != REP_SEARCHREF )
-               return SLAP_CB_CONTINUE;
-
-       ref = rs->sr_ref;
-       rs->sr_ref = NULL;
-
-       op->o_callback = NULL;
-
-       if ( lip->url == NULL ) {
-               /* if we parse the URI then by no means 
-                * we can cache stuff or reuse connections, 
-                * because in back-ldap there's no caching
-                * based on the URI value, which is supposed
-                * to be set once for all (correct?) */
-               op->o_do_not_cache = 1;
-
-               /* FIXME: we're setting the URI of the first referral;
-                * what if there are more?  Is this something we should
-                * worry about? */
-               li = *lip;
-               op->o_bd->be_private = &li;
-
-               if ( rs->sr_type != REP_SEARCHREF ) {
-                       LDAPURLDesc     *srv;
-                       char            *save_dn;
-
-                       /* parse reference and use 
-                        * proto://[host][:port]/ only */
-                       rc = ldap_url_parse_ext( ref[0].bv_val, &srv );
-                       if ( rc != LDAP_URL_SUCCESS) {
-                               /* error */
-                               return 1;
-                       }
-
-                       /* remove DN essentially because later on 
-                        * ldap_initialize() will parse the URL 
-                        * as a comma-separated URL list */
-                       save_dn = srv->lud_dn;
-                       srv->lud_dn = "";
-                       srv->lud_scope = LDAP_SCOPE_DEFAULT;
-                       li.url = ldap_url_desc2str( srv );
-                       srv->lud_dn = save_dn;
-                       ldap_free_urldesc( srv );
-
-                       if ( li.url == NULL ) {
-                               /* error */
-                               return 1;
-                       }
-               }
-
-       } else {
-               op->o_bd->be_private = on->on_bi.bi_private;
-       }
-
-       /* Chaining is performed by a privileged user on behalf
-        * of a normal user, using the ProxyAuthz control. However,
-        * Binds are done separately, on an anonymous session.
-        */
-       if ( op->o_tag != LDAP_REQ_BIND ) {
-               for ( i = 0; prev && prev[i]; i++ )
-                       /* count and set prev to the last one */ ;
-               nctrls = i;
-
-               /* Add an extra NULL slot */
-               if ( !prev ) {
-                       i++;
-               }
-
-               ctrls = op->o_tmpalloc((i + 1)*sizeof(LDAPControl *),
-                       op->o_tmpmemctx);
-               for ( i = 0; i < nctrls; i++ ) {
-                       ctrls[i] = prev[i];
-               }
-               ctrls[nctrls] = &authz;
-               ctrls[nctrls + 1] = NULL;
-               authz.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
-               authz.ldctl_iscritical = 1;
-               authz.ldctl_value = op->o_dn;
-               if ( !BER_BVISEMPTY( &op->o_dn ) ) {
-                       authzid = op->o_tmpalloc( op->o_dn.bv_len + STRLENOF("dn:"),
-                               op->o_tmpmemctx );
-                       strcpy(authzid, "dn:");
-                       strcpy(authzid + STRLENOF("dn:"), op->o_dn.bv_val);
-                       authz.ldctl_value.bv_len = op->o_dn.bv_len + STRLENOF("dn:");
-                       authz.ldctl_value.bv_val = authzid;
-               }
-               op->o_ctrls = ctrls;
-               op->o_ndn = op->o_bd->be_rootndn;
-       }
-
-       switch ( op->o_tag ) {
-       case LDAP_REQ_BIND: {
-               struct berval   rndn = op->o_req_ndn;
-               Connection      *conn = op->o_conn;
-
-               op->o_req_ndn = slap_empty_bv;
-
-               op->o_conn = NULL;
-               rc = lback->bi_op_bind( op, rs );
-               op->o_req_ndn = rndn;
-               op->o_conn = conn;
-               }
-               break;
-       case LDAP_REQ_ADD:
-               {
-               int             cleanup_attrs = 0;
-
-               if ( op->ora_e->e_attrs == NULL ) {
-                       char            textbuf[ SLAP_TEXT_BUFLEN ];
-                       size_t          textlen = sizeof( textbuf );
-
-                       /* global overlay; create entry */
-                       /* NOTE: this is a hack to use the chain overlay
-                        * as global.  I expect to be able to remove this
-                        * soon by using slap_mods2entry() earlier in
-                        * do_add(), adding the operational attrs later
-                        * if required. */
-                       rs->sr_err = slap_mods2entry( op->ora_modlist,
-                                       &op->ora_e, 0, 1,
-                                       &rs->sr_text, textbuf, textlen );
-                       if ( rs->sr_err != LDAP_SUCCESS ) {
-                               send_ldap_result( op, rs );
-                               rc = 1;
-                               break;
-                       }
-               }
-               rc = lback->bi_op_add( op, rs );
-               if ( cleanup_attrs ) {
-                       attrs_free( op->ora_e->e_attrs );
-                       op->ora_e->e_attrs = NULL;
-               }
-               break;
-               }
-       case LDAP_REQ_DELETE:
-               rc = lback->bi_op_delete( op, rs );
-               break;
-       case LDAP_REQ_MODRDN:
-               rc = lback->bi_op_modrdn( op, rs );
-               break;
-       case LDAP_REQ_MODIFY:
-               rc = lback->bi_op_modify( op, rs );
-               break;
-       case LDAP_REQ_COMPARE:
-               rc = lback->bi_op_compare( op, rs );
-               break;
-       case LDAP_REQ_SEARCH:
-               if ( rs->sr_type == REP_SEARCHREF ) {
-                       struct berval   *curr = ref,
-                                       odn = op->o_req_dn,
-                                       ondn = op->o_req_ndn;
-                       slap_callback   sc2 = { 0 };
-                       int             tmprc = 0;
-                       ber_len_t       refcnt = 0;
-                       BerVarray       newref = NULL;
-
-                       sc2.sc_response = ldap_chain_cb_response;
-                       op->o_callback = &sc2;
-
-                       rs->sr_type = REP_SEARCH;
-
-                       /* copy the private info because we need to modify it */
-                       for ( ; !BER_BVISNULL( &curr[0] ); curr++ ) {
-                               LDAPURLDesc     *srv;
-                               char            *save_dn;
-
-                               /* parse reference and use
-                                * proto://[host][:port]/ only */
-                               tmprc = ldap_url_parse_ext( curr[0].bv_val, &srv );
-                               if ( tmprc != LDAP_URL_SUCCESS ) {
-                                       /* error */
-                                       rc = 1;
-                                       goto end_of_searchref;
-                               }
-
-                               /* remove DN essentially because later on 
-                                * ldap_initialize() will parse the URL 
-                                * as a comma-separated URL list */
-                               save_dn = srv->lud_dn;
-                               srv->lud_dn = "";
-                               srv->lud_scope = LDAP_SCOPE_DEFAULT;
-                               li.url = ldap_url_desc2str( srv );
-                               if ( li.url != NULL ) {
-                                       ber_str2bv_x( save_dn, 0, 1, &op->o_req_dn,
-                                                       op->o_tmpmemctx );
-                                       ber_dupbv_x( &op->o_req_ndn, &op->o_req_dn,
-                                                       op->o_tmpmemctx );
-                               }
-
-                               srv->lud_dn = save_dn;
-                               ldap_free_urldesc( srv );
-
-                               if ( li.url == NULL ) {
-                                       /* error */
-                                       rc = 1;
-                                       goto end_of_searchref;
-                               }
-
-
-                               /* FIXME: should we also copy filter and scope?
-                                * according to RFC3296, no */
-                               tmprc = lback->bi_op_search( op, rs );
-
-                               ldap_memfree( li.url );
-                               li.url = NULL;
-
-                               op->o_tmpfree( op->o_req_dn.bv_val,
-                                               op->o_tmpmemctx );
-                               op->o_tmpfree( op->o_req_ndn.bv_val,
-                                               op->o_tmpmemctx );
-
-                               if ( tmprc ) {
-                                       /* error */
-                                       rc = 1;
-                                       goto end_of_searchref;
-                               }
-
-                               if ( rs->sr_err != LDAP_SUCCESS ) {
-                                       /* if search was not successful,
-                                        * at least return the referral! */
-                                       /* FIXME: assumes referrals 
-                                        * are always created via
-                                        * referral_rewrite() and freed via
-                                        * ber_bvarray_free( rs->sr_ref ) */
-                                       newref = ch_realloc( newref, sizeof( struct berval ) * (refcnt + 2) );
-                                       ber_dupbv( &newref[ refcnt ], &curr[ 0 ] );
-                                       refcnt++;
-                                       BER_BVZERO( &newref[ refcnt ] );
-                               }
-                       }
-
-end_of_searchref:;
-                       op->o_req_dn = odn;
-                       op->o_req_ndn = ondn;
-                       rs->sr_type = REP_SEARCHREF;
-                       rs->sr_entry = NULL;
-
-                       /* if the error was bad, it was already returned
-                        * by back-ldap; destroy the referrals left;
-                        * otherwise, let the frontend return them. */
-                       if ( newref ) {
-                               if ( rc == 0 ) {
-                                       rc = SLAP_CB_CONTINUE;
-                                       if ( ref != default_referral ) {
-                                               ber_bvarray_free( ref );
-                                       }
-                                       ref = newref;
-
-                               } else {
-                                       ber_bvarray_free( newref );
-                               }
-                       }
-                       
-               } else {
-                       rc = lback->bi_op_search( op, rs );
-               }
-               break;
-       case LDAP_REQ_EXTENDED:
-               rc = lback->bi_extended( op, rs );
-               break;
-       default:
-               rc = SLAP_CB_CONTINUE;
-               break;
-       }
-       op->o_do_not_cache = cache;
-       op->o_ctrls = prev;
-       op->o_bd->be_private = private;
-       op->o_callback = sc;
-       op->o_ndn = ndn;
-       if ( ctrls ) {
-               op->o_tmpfree( ctrls, op->o_tmpmemctx );
-       }
-       if ( authzid ) {
-               op->o_tmpfree( authzid, op->o_tmpmemctx );
-       }
-       rs->sr_ref = ref;
-       if ( lip->url == NULL && li.url != NULL ) {
-               ldap_memfree( li.url );
-       }
-
-       return rc;
-}
-
-static int
-ldap_chain_config(
-       BackendDB       *be,
-       const char      *fname,
-       int             lineno,
-       int             argc,
-       char    **argv
-)
-{
-       slap_overinst   *on = (slap_overinst *) be->bd_info;
-       void            *private = be->be_private;
-       char            *argv0 = NULL;
-       int             rc;
-
-       be->be_private = on->on_bi.bi_private;
-       if ( strncasecmp( argv[ 0 ], "chain-", sizeof( "chain-" ) - 1 ) == 0 ) {
-               argv0 = argv[ 0 ];
-               argv[ 0 ] = &argv[ 0 ][ sizeof( "chain-" ) - 1 ];
-       }
-       rc = lback->bi_db_config( be, fname, lineno, argc, argv );
-       if ( argv0 ) {
-               argv[ 0 ] = argv0;
-       }
-       
-       be->be_private = private;
-       return rc;
-}
-
-static int
-ldap_chain_init(
-       BackendDB *be
-)
-{
-       slap_overinst *on = (slap_overinst *) be->bd_info;
-       void *private = be->be_private;
-       int rc;
-
-       be->be_private = NULL;
-       rc = lback->bi_db_init( be );
-       on->on_bi.bi_private = be->be_private;
-       be->be_private = private;
-
-       return rc;
-}
-
-static int
-ldap_chain_destroy(
-       BackendDB *be
-)
-{
-       slap_overinst *on = (slap_overinst *) be->bd_info;
-       void *private = be->be_private;
-       int rc;
-
-       be->be_private = on->on_bi.bi_private;
-       rc = lback->bi_db_destroy( be );
-       on->on_bi.bi_private = be->be_private;
-       be->be_private = private;
-       return rc;
-}
-
-static slap_overinst ldapchain;
-
-int
-chain_init()
-{
-       lback = backend_info( "ldap" );
-
-       if ( !lback ) {
-               return -1;
-       }
-
-       ldapchain.on_bi.bi_type = "chain";
-       ldapchain.on_bi.bi_db_init = ldap_chain_init;
-       ldapchain.on_bi.bi_db_config = ldap_chain_config;
-       ldapchain.on_bi.bi_db_destroy = ldap_chain_destroy;
-       
-       /* ... otherwise the underlying backend's function would be called,
-        * likely passing an invalid entry; on the contrary, the requested
-        * operational attributes should have been returned while chasing
-        * the referrals.  This all in all is a bit messy, because part
-        * of the operational attributes are generated by they backend;
-        * part by the frontend; back-ldap should receive all the available
-        * ones from the remote server, but then, on it own, it strips those
-        * it assumes will be (re)generated by the frontend (e.g.
-        * subschemaSubentry.) */
-       ldapchain.on_bi.bi_operational = ldap_chain_operational;
-       
-       ldapchain.on_response = ldap_chain_response;
-
-
-       ldapchain.on_bi.bi_chk_referrals = ldap_chain_chk_referrals;
-
-       return overlay_register( &ldapchain );
-}
-
-#if SLAPD_OVER_CHAIN == SLAPD_MOD_DYNAMIC
-int init_module(int argc, char *argv[]) {
-       return chain_init();
-}
-#endif /* SLAPD_OVER_CHAIN == SLAPD_MOD_DYNAMIC */
-
-#endif /* SLAPD_OVER_CHAIN */
-
-#endif /* ! defined(SLAPD_LDAP) */
index 32e474118d8b540573d53b7cc17ef6dd55364aad..84bb00947ca329b3cd1647c6ad0ac036e86d663f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Howard Chu.
  * All rights reserved.
  *
index 8ebdb904fa9ca020e5bb2ba8c58ed8a53fa453e0..759a831d8db262db76325d46881f0c2d0a9b8de7 100644 (file)
@@ -1,7 +1,7 @@
 /* denyop.c - Denies operations */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7b26b972709a6d5b3db3d388edd4eb990be71e80..d16f4df0e1b5912d9050b648758bc508a163b7f5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Copyright 2003 by Howard Chu.
  * All rights reserved.
  *
index ea11792f07c4117acb7ced65b9b2d90bb34d9453..c5852e8914bd1fbcde388114edfc553031f102ee 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 09a674df3dc58c486076fdda99c5760ac7815e5f..454239c0bcf63d8f7f01fed73e4247aad03dd1cd 100644 (file)
@@ -1,7 +1,7 @@
 /* lastmod.c - returns last modification info */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fe8b3187583b1a7fa4b814467ec90197b02781e8..3e73167b208b315af15cafa3c1b8e23e3caa6959 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Copyright 2003 by Howard Chu.
  * All rights reserved.
  *
@@ -23,9 +23,6 @@
 
 #include "slap.h"
 
-#if SLAPD_OVER_CHAIN == SLAPD_MOD_STATIC
-extern int chain_init();
-#endif
 #if SLAPD_OVER_DENYOP == SLAPD_MOD_STATIC
 extern int denyop_init();
 #endif
@@ -61,9 +58,6 @@ static struct {
        char *name;
        int (*func)();
 } funcs[] = {
-#if SLAPD_OVER_CHAIN == SLAPD_MOD_STATIC
-       { "LDAP Chain Response", chain_init },
-#endif
 #if SLAPD_OVER_DENYOP == SLAPD_MOD_STATIC
        { "Deny Operation", denyop_init },
 #endif
index 35a344ef3a705cf8303529ed0aeaec3b01d0fa2e..b078908da5f287bb588fa237c100b08c9eb055bd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * Portions Copyright 2003 Symas Corporation.
  * All rights reserved.
index 259870bdde3ad2fee88ce0ce8cdae8570aded0b1..11bd2ca7eebdf00ca26758296be5a596eafaffb9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Howard Chu, Symas Corporation.
  * Portions Copyright 2004 Hewlett-Packard Company.
  * All rights reserved.
@@ -1143,7 +1143,7 @@ ppolicy_add(
                        }
                }
                /* If password aging is in effect, set the pwdChangedTime */
-               if (( pp.pwdMaxAge || pp.pwdMinAge ) && !be_isupdate( op )) {
+               if (( pp.pwdMaxAge || pp.pwdMinAge ) && !be_shadow_update( op )) {
                        struct berval timestamp;
                        char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
                        struct tm *ltm;
@@ -1173,7 +1173,6 @@ ppolicy_modify( Operation *op, SlapReply *rs )
        PassPolicy              pp;
        Modifications           *mods = NULL, *modtail, *ml, *delmod, *addmod;
        Attribute               *pa, *ha, *ra, at;
-       int                     repl_user = be_isupdate( op );
        const char              *txt;
        pw_hist                 *tl = NULL, *p;
        int                     zapReset, send_ctrl = 0;
@@ -1376,7 +1375,8 @@ ppolicy_modify( Operation *op, SlapReply *rs )
                const char *txt;
                
                bv = oldpw.bv_val ? &oldpw : delmod->sml_values;
-               rc = slap_passwd_check( op->o_conn, pa, bv, &txt );
+               /* FIXME: no access checking? */
+               rc = slap_passwd_check( op, NULL, pa, bv, &txt );
                if (rc != LDAP_SUCCESS) {
                        Debug( LDAP_DEBUG_TRACE,
                                "old password check failed: %s\n", txt, 0, 0 );
@@ -1420,7 +1420,8 @@ ppolicy_modify( Operation *op, SlapReply *rs )
                /*
                 * Last check - the password history.
                 */
-               if (slap_passwd_check( op->o_conn, pa, bv, &txt ) == LDAP_SUCCESS) {
+               /* FIXME: no access checking? */
+               if (slap_passwd_check( op, NULL, pa, bv, &txt ) == LDAP_SUCCESS) {
                        /*
                         * This is bad - it means that the user is attempting
                         * to set the password to the same as the old one.
@@ -1442,7 +1443,8 @@ ppolicy_modify( Operation *op, SlapReply *rs )
                cr[1].bv_val = NULL;
                for(p=tl; p; p=p->next) {
                        cr[0] = p->pw;
-                       rc = slap_passwd_check( op->o_conn, &at, bv, &txt );
+                       /* FIXME: no access checking? */
+                       rc = slap_passwd_check( op, NULL, &at, bv, &txt );
                        
                        if (rc != LDAP_SUCCESS) continue;
                        
@@ -1454,7 +1456,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
        }
 
 do_modify:
-       if ((pwmod) && (!repl_user)) {
+       if ((pwmod) && (!be_shadow_update( op ))) {
                struct berval timestamp;
                char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
                struct tm *ltm;
index 7917eebf50496248e26c068d621b7bd13534600a..4f522d789c6ff850844aa037f6e5c5ee36b40b24 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Symas Corporation.
  * All rights reserved.
  *
index 1c1da03a810ae0d57c6452f6c1adc9871dd8b2d4..f627cd9ad458f01df0d4ef3aca1a77ed62683dd4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -34,7 +34,6 @@ rwm_op_dn_massage( Operation *op, SlapReply *rs, void *cookie )
                        (struct ldaprwmap *)on->on_bi.bi_private;
 
        struct berval           dn = BER_BVNULL,
-                               *dnp = NULL,
                                ndn = BER_BVNULL;
        int                     rc = 0;
        dncookie                dc;
@@ -56,28 +55,32 @@ rwm_op_dn_massage( Operation *op, SlapReply *rs, void *cookie )
         * and the caller sets op->o_req_dn = op->o_req_ndn,
         * only rewrite the op->o_req_ndn and use it as 
         * op->o_req_dn as well */
+       ndn = op->o_req_ndn;
        if ( op->o_req_dn.bv_val != op->o_req_ndn.bv_val ) {
-               dnp = &dn;
+               dn = op->o_req_dn;
+               rc = rwm_dn_massage_pretty_normalize( &dc, &op->o_req_dn, &dn, &ndn );
+       } else {
+               rc = rwm_dn_massage_normalize( &dc, &op->o_req_ndn, &ndn );
        }
 
-       rc = rwm_dn_massage( &dc, &op->o_req_dn, dnp, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                return rc;
        }
 
-       if ( ( dnp && dn.bv_val == op->o_req_dn.bv_val ) ||
-               ( !dnp && ndn.bv_val == op->o_req_ndn.bv_val ) ) {
+       if ( ( op->o_req_dn.bv_val != op->o_req_ndn.bv_val && dn.bv_val == op->o_req_dn.bv_val )
+                       || ndn.bv_val == op->o_req_ndn.bv_val )
+       {
                return LDAP_SUCCESS;
        }
 
        op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-       if ( dnp ) {
+       op->o_req_ndn = ndn;
+       if ( op->o_req_dn.bv_val != op->o_req_ndn.bv_val ) {
                op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
                op->o_req_dn = dn;
        } else {
                op->o_req_dn = ndn;
        }
-       op->o_req_ndn = ndn;
 
        return LDAP_SUCCESS;
 }
@@ -93,6 +96,7 @@ rwm_op_add( Operation *op, SlapReply *rs )
                                i;
        Attribute               **ap = NULL;
        char                    *olddn = op->o_req_dn.bv_val;
+       int                     isupdate;
 
 #ifdef ENABLE_REWRITE
        rc = rwm_op_dn_massage( op, rs, "addDN" );
@@ -115,11 +119,12 @@ rwm_op_add( Operation *op, SlapReply *rs )
        }
 
        /* Count number of attributes in entry */ 
+       isupdate = be_shadow_update( op );
        for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) {
                struct berval   mapped;
                Attribute       *a;
 
-               if ( (*ap)->a_desc->ad_type->sat_no_user_mod ) {
+               if ( !isupdate && (*ap)->a_desc->ad_type->sat_no_user_mod ) {
                        goto next_attr;
                }
 
@@ -337,6 +342,7 @@ rwm_op_modify( Operation *op, SlapReply *rs )
        struct ldaprwmap        *rwmap = 
                        (struct ldaprwmap *)on->on_bi.bi_private;
 
+       int                     isupdate;
        Modifications           **mlp;
        int                     rc;
 
@@ -352,11 +358,12 @@ rwm_op_modify( Operation *op, SlapReply *rs )
                return -1;
        }
 
+       isupdate = be_shadow_update( op );
        for ( mlp = &op->oq_modify.rs_modlist; *mlp; ) {
                int             is_oc = 0;
                Modifications   *ml;
 
-               if ( (*mlp)->sml_desc->ad_type->sat_no_user_mod  ) {
+               if ( !isupdate && (*mlp)->sml_desc->ad_type->sat_no_user_mod  ) {
                        goto next_mod;
                }
 
@@ -494,7 +501,9 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                dc.tofrom = 0;
                dc.normalized = 0;
 #endif /* ! ENABLE_REWRITE */
-               rc = rwm_dn_massage( &dc, op->orr_newSup, &newSup, &nnewSup );
+               newSup = *op->orr_newSup;
+               nnewSup = *op->orr_nnewSup;
+               rc = rwm_dn_massage_pretty_normalize( &dc, op->orr_newSup, &newSup, &nnewSup );
                if ( rc != LDAP_SUCCESS ) {
                        op->o_bd->bd_info = (BackendInfo *)on->on_info;
                        send_ldap_error( op, rs, rc, "newSuperiorDN massage error" );
@@ -709,7 +718,8 @@ rwm_matched( Operation *op, SlapReply *rs )
        dc.normalized = 0;
 #endif /* ! ENABLE_REWRITE */
        ber_str2bv( rs->sr_matched, 0, 0, &dn );
-       rc = rwm_dn_massage( &dc, &dn, &mdn, NULL );
+       mdn = dn;
+       rc = rwm_dn_massage_pretty( &dc, &dn, &mdn );
        if ( rc != LDAP_SUCCESS ) {
                rs->sr_err = rc;
                rs->sr_text = "Rewrite error";
@@ -739,6 +749,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first )
        dncookie                dc;
        int                     rc;
        Attribute               **ap;
+       int                     isupdate;
 
        /*
         * Rewrite the dn attrs, if needed
@@ -764,6 +775,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first )
         * an error (because multiple instances of attrs in 
         * response are not valid), or merge the values (what
         * about duplicate values?) */
+       isupdate = be_shadow_update( op );
        for ( ap = a_first; *ap; ) {
                struct ldapmapping      *m;
                int                     drop_missing;
@@ -781,7 +793,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first )
                        goto cleanup_attr;
                }
 
-               if ( (*ap)->a_desc->ad_type->sat_no_user_mod 
+               if ( !isupdate && (*ap)->a_desc->ad_type->sat_no_user_mod 
                        && (*ap)->a_desc->ad_type != slap_schema.si_at_undefined )
                {
                        goto next_attr;
@@ -938,7 +950,9 @@ rwm_send_entry( Operation *op, SlapReply *rs )
         * from the one known to the meta, and a DN with unknown
         * attributes is returned.
         */
-       rc = rwm_dn_massage( &dc, &e->e_name, &dn, &ndn );
+       dn = e->e_name;
+       ndn = e->e_nname;
+       rc = rwm_dn_massage_pretty_normalize( &dc, &e->e_name, &dn, &ndn );
        if ( rc != LDAP_SUCCESS ) {
                rc = 1;
                goto fail;
index 4b01146498c69f0bd9eada7995e04214f644ff15..59e440c58744beb2a70b0c8a07b0f22714d008d1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -96,8 +96,10 @@ typedef struct dncookie {
 #endif /* !ENABLE_REWRITE */
 } dncookie;
 
-int rwm_dn_massage( dncookie *dc, struct berval *in,
-       struct berval *dn, struct berval *ndn );
+int rwm_dn_massage( dncookie *dc, struct berval *in, struct berval *dn );
+int rwm_dn_massage_pretty( dncookie *dc, struct berval *in, struct berval *pdn );
+int rwm_dn_massage_normalize( dncookie *dc, struct berval *in, struct berval *ndn );
+int rwm_dn_massage_pretty_normalize( dncookie *dc, struct berval *in, struct berval *pdn, struct berval *ndn );
 
 /* attributeType/objectClass mapping */
 int rwm_mapping_cmp (const void *, const void *);
index 8ec26196f063f6670b8274c743b5378415d462d6..ed3121fede40c91da2a28b3cb70fbb4fc253498c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
index bcf5f6a28a7510d6e085337683420577ff5cd729..931687b70d9a900c91d678110030ccbf592c7c82 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
 
 /* FIXME: after rewriting, we should also remap attributes ...  */
 
+/*
+ * massages "in" and normalizes it into "ndn"
+ *
+ * "ndn" may be untouched if no massaging occurred and its value was not null
+ */
+int
+rwm_dn_massage_normalize(
+       dncookie *dc,
+       struct berval *in,
+       struct berval *ndn )
+{
+       int             rc;
+       struct berval   mdn = BER_BVNULL;
+       
+       /* massage and normalize a DN */
+       rc = rwm_dn_massage( dc, in, &mdn );
+       if ( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
+       if ( mdn.bv_val == in->bv_val && !BER_BVISNULL( ndn ) ) {
+               return rc;
+       }
+
+       rc = dnNormalize( 0, NULL, NULL, &mdn, ndn, NULL );
+
+       if ( mdn.bv_val != in->bv_val ) {
+               ch_free( mdn.bv_val );
+       }
+
+       return rc;
+}
+
+/*
+ * massages "in" and prettifies it into "pdn"
+ *
+ * "pdn" may be untouched if no massaging occurred and its value was not null
+ */
+int
+rwm_dn_massage_pretty(
+       dncookie *dc,
+       struct berval *in,
+       struct berval *pdn )
+{
+       int             rc;
+       struct berval   mdn = BER_BVNULL;
+       
+       /* massage and pretty a DN */
+       rc = rwm_dn_massage( dc, in, &mdn );
+       if ( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
+       if ( mdn.bv_val == in->bv_val && !BER_BVISNULL( pdn ) ) {
+               return rc;
+       }
+
+       rc = dnPretty( NULL, &mdn, pdn, NULL );
+
+       if ( mdn.bv_val != in->bv_val ) {
+               ch_free( mdn.bv_val );
+       }
+
+       return rc;
+}
+
+/*
+ * massages "in" and prettifies and normalizes it into "pdn" and "ndn"
+ *
+ * "pdn" may be untouched if no massaging occurred and its value was not null;
+ * "ndn" may be untouched if no massaging occurred and its value was not null;
+ * if no massage occurred and "ndn" value was not null, it is filled
+ * with the normaized value of "pdn", much like ndn = dnNormalize( pdn )
+ */
+int
+rwm_dn_massage_pretty_normalize(
+       dncookie *dc,
+       struct berval *in,
+       struct berval *pdn,
+       struct berval *ndn )
+{
+       int             rc;
+       struct berval   mdn = BER_BVNULL;
+       
+       /* massage, pretty and normalize a DN */
+       rc = rwm_dn_massage( dc, in, &mdn );
+       if ( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
+       if ( mdn.bv_val == in->bv_val && !BER_BVISNULL( pdn ) ) {
+               if ( BER_BVISNULL( ndn ) ) {
+                       rc = dnNormalize( 0, NULL, NULL, &mdn, ndn, NULL );
+               }
+               return rc;
+       }
+
+       rc = dnPrettyNormal( NULL, &mdn, pdn, ndn, NULL );
+
+       if ( mdn.bv_val != in->bv_val ) {
+               ch_free( mdn.bv_val );
+       }
+
+       return rc;
+}
+
 #ifdef ENABLE_REWRITE
+/*
+ * massages "in" into "dn"
+ * 
+ * "dn" may contain the value of "in" if no massage occurred
+ */
 int
 rwm_dn_massage(
        dncookie *dc,
        struct berval *in,
-       struct berval *dn,
-       struct berval *ndn
+       struct berval *dn
 )
 {
        int             rc = 0;
        struct berval   mdn;
 
+       assert( dc );
        assert( in );
-
-       if ( dn == NULL && ndn == NULL ) {
-               return LDAP_OTHER;
-       }
+       assert( dn );
 
        rc = rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
                        ( in->bv_len ? in->bv_val : "" ), 
                        dc->conn, &mdn.bv_val );
        switch ( rc ) {
        case REWRITE_REGEXEC_OK:
-               if ( !BER_BVISNULL( &mdn ) ) {
-
+               if ( !BER_BVISNULL( &mdn ) && mdn.bv_val != in->bv_val ) {
                        mdn.bv_len = strlen( mdn.bv_val );
-                       
-                       if ( dn != NULL && ndn != NULL ) {
-                               rc = dnPrettyNormal( NULL, &mdn, dn, ndn, NULL );
-
-                       } else if ( dn != NULL ) {
-                               rc = dnPretty( NULL, &mdn, dn, NULL );
-
-                       } else if ( ndn != NULL) {
-                               rc = dnNormalize( 0, NULL, NULL, &mdn, ndn, NULL );
-                       }
-
-                       if ( mdn.bv_val != in->bv_val ) {
-                               ch_free( mdn.bv_val );
-                       }
-
+                       *dn = mdn;
                } else {
-                       /* we assume the input string is already in pretty form,
-                        * and that the normalized version is already available */
-                       if ( dn ) {
-                               *dn = *in;
-                               if ( ndn ) {
-                                       BER_BVZERO( ndn );
-                               }
-                       } else {
-                               *ndn = *in;
-                       }
-                       rc = LDAP_SUCCESS;
+                       *dn = *in;
                }
+               rc = LDAP_SUCCESS;
 
                Debug( LDAP_DEBUG_ARGS,
                        "[rw] %s: \"%s\" -> \"%s\"\n",
-                       dc->ctx, in->bv_val, dn ? dn->bv_val : ndn->bv_val );
+                       dc->ctx, in->bv_val, dn->bv_val );
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
@@ -125,39 +209,25 @@ rwm_dn_massage(
 int
 rwm_dn_massage(
        dncookie *dc,
-       struct berval *tmpin,
-       struct berval *dn,
-       struct berval *ndn
+       struct berval *in,
+       struct berval *dn
 )
 {
        int             i, src, dst;
-       struct berval   pretty = BER_BVNULL,
-                       normal = BER_BVNULL,
-                       *in = tmpin;
+       struct berval   tmpin;
 
-       if ( dn == NULL && ndn == NULL ) {
-               return LDAP_OTHER;
-       }
+       assert( dc );
+       assert( in );
+       assert( dn );
 
-       if ( in == NULL || BER_BVISNULL( in ) ) {
-               if ( dn ) {
-                       BER_BVZERO( dn );
-               }
-               if ( ndn ) {
-                       BER_BVZERO( ndn );
-               }
+       BER_BVZERO( dn );
+
+       if ( BER_BVISNULL( in ) ) {
                return LDAP_SUCCESS;
        }
 
        if ( dc->rwmap == NULL || dc->rwmap->rwm_suffix_massage == NULL ) {
-               if ( dn ) {
-                       *dn = *in;
-                       if ( ndn ) {
-                               BER_BVZERO( ndn );
-                       }
-               } else {
-                       *ndn = *in;
-               }
+               *dn = *in;
                return LDAP_SUCCESS;
        }
 
@@ -165,6 +235,8 @@ rwm_dn_massage(
                src = 0 + dc->normalized;
                dst = 2 + dc->normalized;
 
+               tmpin = *in;
+
        } else {
                int     rc;
 
@@ -174,39 +246,31 @@ rwm_dn_massage(
                /* DN from remote server may be in arbitrary form.
                 * Pretty it so we can parse reliably.
                 */
-               if ( dc->normalized && dn == NULL ) {
-                       rc = dnNormalize( 0, NULL, NULL, in, &normal, NULL );
-
-               } else if ( !dc->normalized && ndn == NULL ) {
-                       rc = dnPretty( NULL, in, &pretty, NULL );
+               if ( dc->normalized ) {
+                       rc = dnNormalize( 0, NULL, NULL, in, &tmpin, NULL );
 
                } else {
-                       rc = dnPrettyNormal( NULL, in, &pretty, &normal, NULL );
+                       rc = dnPretty( NULL, in, &tmpin, NULL );
                }
 
                if ( rc != LDAP_SUCCESS ) {
                        return rc;
                }
-
-               if ( dc->normalized && !BER_BVISNULL( &normal ) ) {
-                       in = &normal;
-
-               } else if ( !dc->normalized && !BER_BVISNULL( &pretty ) ) {
-                       in = &pretty;
-               }
        }
 
        for ( i = 0;
-               dc->rwmap->rwm_suffix_massage[i].bv_val != NULL;
-               i += 4 ) {
+                       !BER_BVISNULL( &dc->rwmap->rwm_suffix_massage[i] );
+                       i += 4 )
+       {
                int aliasLength = dc->rwmap->rwm_suffix_massage[i+src].bv_len;
-               int diff = in->bv_len - aliasLength;
+               int diff = tmpin.bv_len - aliasLength;
 
                if ( diff < 0 ) {
                        /* alias is longer than dn */
                        continue;
 
-               } else if ( diff > 0 && ( !DN_SEPARATOR(in->bv_val[diff-1]))) {
+               } else if ( diff > 0 && ( !DN_SEPARATOR(tmpin.bv_val[diff-1])))
+               {
                        /* FIXME: DN_SEPARATOR() is intended to work
                         * on a normalized/pretty DN, so that ';'
                         * is never used as a DN separator */
@@ -214,45 +278,28 @@ rwm_dn_massage(
                        /* At a DN Separator */
                }
 
-               if ( !strcmp( dc->rwmap->rwm_suffix_massage[i+src].bv_val, &in->bv_val[diff] ) ) {
-                       struct berval   *out;
-
-                       if ( dn ) {
-                               out = dn;
-                       } else {
-                               out = ndn;
-                       }
-                       out->bv_len = diff + dc->rwmap->rwm_suffix_massage[i+dst].bv_len;
-                       out->bv_val = ch_malloc( out->bv_len + 1 );
-                       strncpy( out->bv_val, in->bv_val, diff );
-                       strcpy( &out->bv_val[diff], dc->rwmap->rwm_suffix_massage[i+dst].bv_val );
+               if ( !strcmp( dc->rwmap->rwm_suffix_massage[i+src].bv_val,
+                                       &tmpin.bv_val[diff] ) )
+               {
+                       dn->bv_len = diff + dc->rwmap->rwm_suffix_massage[i+dst].bv_len;
+                       dn->bv_val = ch_malloc( dn->bv_len + 1 );
+                       strncpy( dn->bv_val, tmpin.bv_val, diff );
+                       strcpy( &dn->bv_val[diff], dc->rwmap->rwm_suffix_massage[i+dst].bv_val );
                        Debug( LDAP_DEBUG_ARGS,
                                "rwm_dn_massage:"
                                " converted \"%s\" to \"%s\"\n",
-                               in->bv_val, out->bv_val, 0 );
-                       if ( dn && ndn ) {
-                               rc = dnNormalize( 0, NULL, NULL, dn, ndn, NULL );
-                       }
+                               in->bv_val, dn->bv_val, 0 );
 
                        break;
                }
        }
 
-       if ( !BER_BVISNULL( &pretty ) ) {
-               ch_free( pretty.bv_val );
-       }
-
-       if ( !BER_BVISNULL( &normal ) ) {
-               ch_free( normal.bv_val );
+       if ( tmpin.bv_val != in->bv_val ) {
+               ch_free( tmpin.bv_val );
        }
 
-       in = tmpin;
-
        /* Nothing matched, just return the original DN */
-       if ( dc->normalized && BER_BVISNULL( ndn ) ) {
-               *ndn = *in;
-
-       } else if ( !dc->normalized && BER_BVISNULL( dn ) ) {
+       if ( BER_BVISNULL( dn ) ) {
                *dn = *in;
        }
 
index 033e84b51c0aebfc57f5d339ef37d5685b4b6e93..966266162264b884ee2434af2c49d10a8747715c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -360,7 +360,7 @@ map_attr_value(
                struct berval           *mapped_value,
                int                     remap )
 {
-       struct berval           vtmp;
+       struct berval           vtmp = BER_BVNULL;
        int                     freeval = 0;
 
        rwm_map( &dc->rwmap->rwm_at, &ad->ad_cname, mapped_attr, remap );
@@ -388,7 +388,8 @@ map_attr_value(
                fdc.ctx = "searchFilterAttrDN";
 #endif /* ENABLE_REWRITE */
 
-               rc = rwm_dn_massage( &fdc, value, NULL, &vtmp );
+               vtmp = *value;
+               rc = rwm_dn_massage_normalize( &fdc, value, &vtmp );
                switch ( rc ) {
                case LDAP_SUCCESS:
                        if ( vtmp.bv_val != value->bv_val ) {
@@ -762,7 +763,8 @@ rwm_referral_rewrite(
        int                     i, last;
 
        dncookie                dc;
-       struct berval           dn, ndn, *ndnp = NULL;
+       struct berval           dn = BER_BVNULL,
+                               ndn = BER_BVNULL;
 
        assert( a_vals );
 
@@ -779,16 +781,16 @@ rwm_referral_rewrite(
        dc.normalized = 0;
 #endif /* ! ENABLE_REWRITE */
 
-       for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ );
+       for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ )
+               ;
+       last--;
+       
        if ( pa_nvals != NULL ) {
-               ndnp = &ndn;
-
                if ( *pa_nvals == NULL ) {
-                       *pa_nvals = ch_malloc( last * sizeof(struct berval) );
-                       memset( *pa_nvals, 0, last * sizeof(struct berval) );
+                       *pa_nvals = ch_malloc( ( last + 2 ) * sizeof(struct berval) );
+                       memset( *pa_nvals, 0, ( last + 2 ) * sizeof(struct berval) );
                }
        }
-       last--;
 
        for ( i = 0; !BER_BVISNULL( &a_vals[i] ); i++ ) {
                struct berval   olddn, oldval;
@@ -804,9 +806,26 @@ rwm_referral_rewrite(
                        }
                        continue;
                }
+
+               /* FIXME: URLs like "ldap:///dc=suffix" if passed
+                * thru ldap_url_parse() and ldap_url_desc2str() 
+                * get rewritten as "ldap:///dc=suffix??base";
+                * we don't want this to occur... */
+               if ( ludp->lud_scope == LDAP_SCOPE_BASE ) {
+                       ludp->lud_scope = LDAP_SCOPE_DEFAULT;
+               }
+
                ber_str2bv( ludp->lud_dn, 0, 0, &olddn );
 
-               rc = rwm_dn_massage( &dc, &olddn, &dn, ndnp );
+               dn = olddn;
+               if ( pa_nvals ) {
+                       ndn = olddn;
+                       rc = rwm_dn_massage_pretty_normalize( &dc, &olddn,
+                                       &dn, &ndn );
+               } else {
+                       rc = rwm_dn_massage_pretty( &dc, &olddn, &dn );
+               }
+
                switch ( rc ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
@@ -834,9 +853,12 @@ rwm_referral_rewrite(
 
                                ludp->lud_dn = dn.bv_val;
                                newurl = ldap_url_desc2str( ludp );
+                               ludp->lud_dn = olddn.bv_val;
+                               ch_free( dn.bv_val );
                                if ( newurl == NULL ) {
                                        /* FIXME: leave attr untouched
-                                        * even if ldap_url_desc2str failed... */
+                                        * even if ldap_url_desc2str failed...
+                                        */
                                        break;
                                }
 
@@ -846,9 +868,12 @@ rwm_referral_rewrite(
                                if ( pa_nvals ) {
                                        ludp->lud_dn = ndn.bv_val;
                                        newurl = ldap_url_desc2str( ludp );
+                                       ludp->lud_dn = olddn.bv_val;
+                                       ch_free( ndn.bv_val );
                                        if ( newurl == NULL ) {
                                                /* FIXME: leave attr untouched
-                                                * even if ldap_url_desc2str failed... */
+                                                * even if ldap_url_desc2str failed...
+                                                */
                                                ch_free( a_vals[i].bv_val );
                                                a_vals[i] = oldval;
                                                break;
@@ -901,12 +926,12 @@ rwm_dnattr_rewrite(
        int                     i, last;
 
        dncookie                dc;
-       struct berval           dn, *dnp = NULL, ndn, *ndnp = NULL;
+       struct berval           dn = BER_BVNULL,
+                               ndn = BER_BVNULL;
        BerVarray               in;
 
        if ( a_vals ) {
                in = a_vals;
-               dnp = &dn;
 
        } else {
                if ( pa_nvals == NULL || *pa_nvals == NULL ) {
@@ -929,20 +954,30 @@ rwm_dnattr_rewrite(
 #endif /* ! ENABLE_REWRITE */
 
        for ( last = 0; !BER_BVISNULL( &in[last] ); last++ );
+       last--;
        if ( pa_nvals != NULL ) {
-               ndnp = &ndn;
-
                if ( *pa_nvals == NULL ) {
-                       *pa_nvals = ch_malloc( last * sizeof(struct berval) );
-                       memset( *pa_nvals, 0, last * sizeof(struct berval) );
+                       *pa_nvals = ch_malloc( ( last + 2 ) * sizeof(struct berval) );
+                       memset( *pa_nvals, 0, ( last + 2 ) * sizeof(struct berval) );
                }
        }
-       last--;
 
        for ( i = 0; !BER_BVISNULL( &in[i] ); i++ ) {
                int             rc;
 
-               rc = rwm_dn_massage( &dc, &in[i], dnp, ndnp );
+               if ( a_vals ) {
+                       dn = in[i];
+                       if ( pa_nvals ) {
+                               ndn = (*pa_nvals)[i];
+                               rc = rwm_dn_massage_pretty_normalize( &dc, &in[i], &dn, &ndn );
+                       } else {
+                               rc = rwm_dn_massage_pretty( &dc, &in[i], &dn );
+                       }
+               } else {
+                       ndn = in[i];
+                       rc = rwm_dn_massage_normalize( &dc, &in[i], &ndn );
+               }
+
                switch ( rc ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
@@ -979,8 +1014,6 @@ rwm_dnattr_rewrite(
                                }
                                
                        } else {
-                               assert( ndnp != NULL );
-
                                if ( !BER_BVISNULL( &ndn ) && ndn.bv_val != (*pa_nvals)[i].bv_val ) {
                                        ch_free( (*pa_nvals)[i].bv_val );
                                        (*pa_nvals)[i] = ndn;
@@ -1022,9 +1055,18 @@ rwm_referral_result_rewrite(
                        continue;
                }
 
+               /* FIXME: URLs like "ldap:///dc=suffix" if passed
+                * thru ldap_url_parse() and ldap_url_desc2str()
+                * get rewritten as "ldap:///dc=suffix??base";
+                * we don't want this to occur... */
+               if ( ludp->lud_scope == LDAP_SCOPE_BASE ) {
+                       ludp->lud_scope = LDAP_SCOPE_DEFAULT;
+               }
+
                ber_str2bv( ludp->lud_dn, 0, 0, &olddn );
-               
-               rc = rwm_dn_massage( dc, &olddn, &dn, NULL );
+
+               dn = olddn;
+               rc = rwm_dn_massage_pretty( dc, &olddn, &dn );
                switch ( rc ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
@@ -1050,7 +1092,8 @@ rwm_referral_result_rewrite(
                                newurl = ldap_url_desc2str( ludp );
                                if ( newurl == NULL ) {
                                        /* FIXME: leave attr untouched
-                                        * even if ldap_url_desc2str failed... */
+                                        * even if ldap_url_desc2str failed...
+                                        */
                                        break;
                                }
 
@@ -1083,7 +1126,8 @@ rwm_dnattr_result_rewrite(
                struct berval   dn;
                int             rc;
                
-               rc = rwm_dn_massage( dc, &a_vals[i], &dn, NULL );
+               dn = a_vals[i];
+               rc = rwm_dn_massage_pretty( dc, &a_vals[i], &dn );
                switch ( rc ) {
                case LDAP_UNWILLING_TO_PERFORM:
                        /*
index db237817084fe41cb1cc216d2f08cf6a5bf3a1f8..be2efda0f108506a21b0f29ae8596de24f415c05 100644 (file)
@@ -1,7 +1,7 @@
 /* seqmod.c - sequenced modifies */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 221828839330f2a6c7757c7a08ea81989440099d..8b5ca2077b01eb9d74fef2787dbddc13a2db0d38 100644 (file)
@@ -2,7 +2,7 @@
 /* syncprov.c - syncrepl provider */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,6 @@ typedef struct syncops {
        struct berval   s_base;         /* ndn of search base */
        ID              s_eid;          /* entryID of search base */
        Operation       *s_op;          /* search op */
-       int             s_sid;
        int             s_rid;
        struct berval s_filterstr;
        int             s_flags;        /* search status */
@@ -84,6 +83,7 @@ typedef struct sync_control {
 #define SLAP_SYNC_REFRESH_AND_PERSIST  (LDAP_SYNC_REFRESH_AND_PERSIST<<SLAP_CONTROL_SHIFT)
 
 #define        PS_IS_REFRESHING        0x01
+#define        PS_IS_DETACHED          0x02
 
 /* Record of which searches matched at premodify step */
 typedef struct syncmatches {
@@ -100,8 +100,6 @@ typedef struct slog_entry {
 } slog_entry;
 
 typedef struct sessionlog {
-       struct sessionlog *sl_next;
-       int             sl_sid;
        struct berval   sl_mincsn;
        int             sl_num;
        int             sl_size;
@@ -525,7 +523,7 @@ findmax_cb( Operation *op, SlapReply *rs )
                Attribute *a = attr_find( rs->sr_entry->e_attrs,
                        slap_schema.si_ad_entryCSN );
 
-               if ( a && ber_bvcmp( &a->a_vals[0], maxcsn )) {
+               if ( a && ber_bvcmp( &a->a_vals[0], maxcsn ) > 0 ) {
                        maxcsn->bv_len = a->a_vals[0].bv_len;
                        strcpy( maxcsn->bv_val, a->a_vals[0].bv_val );
                }
@@ -609,12 +607,12 @@ syncprov_findcsn( Operation *op, int mode )
        AttributeAssertion eq;
        int i, rc = LDAP_SUCCESS;
        fpres_cookie pcookie;
-       sync_control *srs;
+       sync_control *srs = NULL;
 
        if ( mode != FIND_MAXCSN ) {
                srs = op->o_controls[slap_cids.sc_LDAPsync];
 
-               if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) {
+               if ( srs->sr_state.ctxcsn.bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) {
                        return LDAP_OTHER;
                }
        }
@@ -644,12 +642,13 @@ syncprov_findcsn( Operation *op, int mode )
                fop.ors_slimit = SLAP_NO_LIMIT;
                cb.sc_private = &maxcsn;
                cb.sc_response = findmax_cb;
+               strcpy( cbuf, si->si_ctxcsn.bv_val );
                maxcsn.bv_val = cbuf;
-               maxcsn.bv_len = 0;
+               maxcsn.bv_len = si->si_ctxcsn.bv_len;
                break;
        case FIND_CSN:
                cf.f_choice = LDAP_FILTER_LE;
-               cf.f_av_value = *srs->sr_state.ctxcsn;
+               cf.f_av_value = srs->sr_state.ctxcsn;
                fbuf.bv_len = sprintf( buf, "(entryCSN<=%s)",
                        cf.f_av_value.bv_val );
                fop.ors_attrsonly = 1;
@@ -663,7 +662,7 @@ syncprov_findcsn( Operation *op, int mode )
                af.f_next = NULL;
                af.f_and = &cf;
                cf.f_choice = LDAP_FILTER_LE;
-               cf.f_av_value = *srs->sr_state.ctxcsn;
+               cf.f_av_value = srs->sr_state.ctxcsn;
                cf.f_next = op->ors_filter;
                fop.ors_filter = &af;
                filter2bv_x( &fop, fop.ors_filter, &fop.ors_filterstr );
@@ -696,10 +695,8 @@ syncprov_findcsn( Operation *op, int mode )
 
        switch( mode ) {
        case FIND_MAXCSN:
-               if ( maxcsn.bv_len ) {
-                       strcpy( si->si_ctxcsnbuf, maxcsn.bv_val );
-                       si->si_ctxcsn.bv_len = maxcsn.bv_len;
-               }
+               strcpy( si->si_ctxcsnbuf, maxcsn.bv_val );
+               si->si_ctxcsn.bv_len = maxcsn.bv_len;
                break;
        case FIND_CSN:
                /* If matching CSN was not found, invalidate the context. */
@@ -771,8 +768,7 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry *e, int mode
        }
 
        ctrls[1] = NULL;
-       slap_compose_sync_cookie( op, &cookie, &opc->sctxcsn,
-               so->s_sid, so->s_rid );
+       slap_compose_sync_cookie( op, &cookie, &opc->sctxcsn, so->s_rid );
 
        e_uuid.e_attrs = &a_uuid;
        a_uuid.a_desc = slap_schema.si_ad_entryUUID;
@@ -829,12 +825,14 @@ syncprov_free_syncop( syncops *so )
                return;
        }
        ldap_pvt_thread_mutex_unlock( &so->s_mutex );
-       filter_free( so->s_op->ors_filter );
-       for ( ga = so->s_op->o_groups; ga; ga=gnext ) {
-               gnext = ga->ga_next;
-               ch_free( ga );
+       if ( so->s_flags & PS_IS_DETACHED ) {
+               filter_free( so->s_op->ors_filter );
+               for ( ga = so->s_op->o_groups; ga; ga=gnext ) {
+                       gnext = ga->ga_next;
+                       ch_free( ga );
+               }
+               ch_free( so->s_op );
        }
-       ch_free( so->s_op );
        ch_free( so->s_base.bv_val );
        for ( sr=so->s_res; sr; sr=srnext ) {
                srnext = sr->s_next;
@@ -847,15 +845,19 @@ syncprov_free_syncop( syncops *so )
 static int
 syncprov_drop_psearch( syncops *so, int lock )
 {
-       if ( lock )
-               ldap_pvt_thread_mutex_lock( &so->s_op->o_conn->c_mutex );
-       so->s_op->o_conn->c_n_ops_executing--;
-       so->s_op->o_conn->c_n_ops_completed++;
-       LDAP_STAILQ_REMOVE( &so->s_op->o_conn->c_ops, so->s_op, slap_op,
-               o_next );
-       if ( lock )
-               ldap_pvt_thread_mutex_unlock( &so->s_op->o_conn->c_mutex );
+       if ( so->s_flags & PS_IS_DETACHED ) {
+               if ( lock )
+                       ldap_pvt_thread_mutex_lock( &so->s_op->o_conn->c_mutex );
+               so->s_op->o_conn->c_n_ops_executing--;
+               so->s_op->o_conn->c_n_ops_completed++;
+               LDAP_STAILQ_REMOVE( &so->s_op->o_conn->c_ops, so->s_op, slap_op,
+                       o_next );
+               if ( lock )
+                       ldap_pvt_thread_mutex_unlock( &so->s_op->o_conn->c_mutex );
+       }
        syncprov_free_syncop( so );
+
+       return 0;
 }
 
 static int
@@ -882,12 +884,7 @@ syncprov_op_abandon( Operation *op, SlapReply *rs )
                        rs->sr_err = LDAP_CANCELLED;
                        send_ldap_result( so->s_op, rs );
                }
-               /* Our cloned searches have no ctrls set.
-                * we don't want to muck with real search ops
-                * from the frontend.
-                */
-               if ( ! so->s_op->o_sync )
-                       syncprov_drop_psearch( so, 0 );
+               syncprov_drop_psearch( so, 0 );
        }
        return SLAP_CB_CONTINUE;
 }
@@ -926,10 +923,6 @@ syncprov_matchops( Operation *op, opcookie *opc, int saveit )
                e = op->ora_e;
        }
 
-       /* Never replicate these */
-       if ( is_entry_syncConsumerSubentry( e )) {
-               goto done;
-       }
        if ( saveit ) {
                ber_dupbv_x( &opc->sdn, &e->e_name, op->o_tmpmemctx );
                ber_dupbv_x( &opc->sndn, &e->e_nname, op->o_tmpmemctx );
@@ -1057,6 +1050,8 @@ syncprov_op_cleanup( Operation *op, SlapReply *rs )
                op->o_tmpfree( opc->sdn.bv_val, op->o_tmpmemctx );
        op->o_callback = cb->sc_next;
        op->o_tmpfree(cb, op->o_tmpmemctx);
+
+       return 0;
 }
 
 static void
@@ -1098,7 +1093,8 @@ syncprov_add_slog( Operation *op, struct berval *csn )
        sessionlog *sl;
        slog_entry *se;
 
-       for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
+       sl = si->si_logs;
+       {
                /* Allocate a record. UUIDs are not NUL-terminated. */
                se = ch_malloc( sizeof( slog_entry ) + opc->suuid.bv_len + 
                        csn->bv_len + 1 );
@@ -1298,6 +1294,13 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                        }
                }
 
+               /* Don't do any processing for consumer contextCSN updates */
+               if ( SLAP_SYNC_SHADOW( op->o_bd ) && 
+                       op->o_msgid == SLAP_SYNC_UPDATE_MSGID ) {
+                       ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex );
+                       return SLAP_CB_CONTINUE;
+               }
+
                si->si_numops++;
                if ( si->si_chkops || si->si_chktime ) {
                        int do_check=0;
@@ -1585,6 +1588,7 @@ syncprov_detach_op( Operation *op, syncops *so )
        op->o_conn->c_n_ops_executing++;
        op->o_conn->c_n_ops_completed--;
        LDAP_STAILQ_INSERT_TAIL( &op->o_conn->c_ops, op2, o_next );
+       so->s_flags |= PS_IS_DETACHED;
        ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
 }
 
@@ -1608,11 +1612,12 @@ syncprov_search_response( Operation *op, SlapReply *rs )
                        Debug( LDAP_DEBUG_ANY, "bogus referral in context\n",0,0,0 );
                        return SLAP_CB_CONTINUE;
                }
-               if ( srs->sr_state.ctxcsn ) {
+               if ( !BER_BVISNULL( &srs->sr_state.ctxcsn )) {
                        Attribute *a = attr_find( rs->sr_entry->e_attrs,
                                slap_schema.si_ad_entryCSN );
+                       
                        /* Don't send the ctx entry twice */
-                       if ( bvmatch( &a->a_nvals[0], srs->sr_state.ctxcsn ))
+                       if ( a && bvmatch( &a->a_nvals[0], &srs->sr_state.ctxcsn ) )
                                return LDAP_SUCCESS;
                }
                rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2,
@@ -1625,7 +1630,7 @@ syncprov_search_response( Operation *op, SlapReply *rs )
 
                slap_compose_sync_cookie( op, &cookie,
                        &op->ors_filter->f_and->f_ava->aa_value,
-                       srs->sr_state.sid, srs->sr_state.rid );
+                       srs->sr_state.rid );
 
                /* Is this a regular refresh? */
                if ( !ss->ss_so ) {
@@ -1745,7 +1750,6 @@ syncprov_op_search( Operation *op, SlapReply *rs )
                sop = ch_malloc( sizeof( syncops ));
                *sop = so;
                ldap_pvt_thread_mutex_init( &sop->s_mutex );
-               sop->s_sid = srs->sr_state.sid;
                sop->s_rid = srs->sr_state.rid;
                sop->s_inuse = 1;
 
@@ -1763,13 +1767,13 @@ syncprov_op_search( Operation *op, SlapReply *rs )
        ctxcsn.bv_val = csnbuf;
        
        /* If we have a cookie, handle the PRESENT lookups */
-       if ( srs->sr_state.ctxcsn ) {
+       if ( !BER_BVISNULL( &srs->sr_state.ctxcsn )) {
                sessionlog *sl;
 
                /* The cookie was validated when it was parsed, just use it */
 
                /* If just Refreshing and nothing has changed, shortcut it */
-               if ( bvmatch( srs->sr_state.ctxcsn, &ctxcsn )) {
+               if ( bvmatch( &srs->sr_state.ctxcsn, &ctxcsn )) {
                        nochange = 1;
                        if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
                                LDAPControl     *ctrls[2];
@@ -1787,14 +1791,13 @@ syncprov_op_search( Operation *op, SlapReply *rs )
                        goto shortcut;
                }
                /* Do we have a sessionlog for this search? */
-               for ( sl=si->si_logs; sl; sl=sl->sl_next )
-                       if ( sl->sl_sid == srs->sr_state.sid ) break;
+               sl=si->si_logs;
                if ( sl ) {
                        ldap_pvt_thread_mutex_lock( &sl->sl_mutex );
-                       if ( ber_bvcmp( srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) {
+                       if ( ber_bvcmp( &srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) {
                                do_present = 0;
                                /* mutex is unlocked in playlog */
-                               syncprov_playlog( op, rs, sl, srs->sr_state.ctxcsn, &ctxcsn );
+                               syncprov_playlog( op, rs, sl, &srs->sr_state.ctxcsn, &ctxcsn );
                        } else {
                                ldap_pvt_thread_mutex_unlock( &sl->sl_mutex );
                        }
@@ -1842,7 +1845,7 @@ shortcut:
                fava->f_choice = LDAP_FILTER_GE;
                fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx );
                fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN;
-               ber_dupbv_x( &fava->f_ava->aa_value, srs->sr_state.ctxcsn, op->o_tmpmemctx );
+               ber_dupbv_x( &fava->f_ava->aa_value, &srs->sr_state.ctxcsn, op->o_tmpmemctx );
        }
        fava->f_next = op->ors_filter;
        op->ors_filter = fand;
@@ -1946,44 +1949,30 @@ syncprov_db_config(
 
        } else if ( strcasecmp( argv[0], "syncprov-sessionlog" ) == 0 ) {
                sessionlog *sl;
-               int sid, size;
-               if ( argc != 3 ) {
+               int size;
+               if ( argc != 2 ) {
                        fprintf( stderr, "%s: line %d: wrong number of arguments in "
-                               "\"syncprov-sessionlog <sid> <size>\"\n", fname, lineno );
+                               "\"syncprov-sessionlog <size>\"\n", fname, lineno );
                        return -1;
                }
-               sid = atoi( argv[1] );
-               if ( sid < 0 || sid > 999 ) {
-                       fprintf( stderr,
-                               "%s: line %d: session log id %d is out of range [0..999]\n",
-                               fname, lineno, sid );
-                       return -1;
-               }
-               size = atoi( argv[2] );
+               size = atoi( argv[1] );
                if ( size < 0 ) {
                        fprintf( stderr,
                                "%s: line %d: session log size %d is negative\n",
                                fname, lineno, size );
                        return -1;
                }
-               for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
-                       if ( sl->sl_sid == sid ) {
-                               sl->sl_size = size;
-                               break;
-                       }
-               }
+               sl = si->si_logs;
                if ( !sl ) {
                        sl = ch_malloc( sizeof( sessionlog ) + LDAP_LUTIL_CSNSTR_BUFSIZE );
                        sl->sl_mincsn.bv_val = (char *)(sl+1);
                        sl->sl_mincsn.bv_len = 0;
-                       sl->sl_sid = sid;
-                       sl->sl_size = size;
                        sl->sl_num = 0;
                        sl->sl_head = sl->sl_tail = NULL;
-                       sl->sl_next = si->si_logs;
                        ldap_pvt_thread_mutex_init( &sl->sl_mutex );
                        si->si_logs = sl;
                }
+               sl->sl_size = size;
                return 0;
        }
 
@@ -2228,7 +2217,7 @@ static int syncprov_parseCtrl (
        sr = op->o_tmpcalloc( 1, sizeof(struct sync_control), op->o_tmpmemctx );
        sr->sr_rhint = rhint;
        if (!BER_BVISNULL(&cookie)) {
-               ber_bvarray_add( &sr->sr_state.octet_str, &cookie );
+               ber_dupbv( &sr->sr_state.octet_str, &cookie );
                slap_parse_sync_cookie( &sr->sr_state );
        }
 
index fc40e4104d106c2837ac97f8dd80a295b8152f61..e9f60fb8e1e0dd9fddec51bc18880a4ac7317ee9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Symas Corporation.
  * All rights reserved.
  *
index 51b42411711abf833bbd44501d51ee76520e1717..bc48e0133b91017cf5ef9b24526958bb5bb53616 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -113,6 +113,11 @@ int passwd_extop(
                goto error_return;
        }
 
+       /* check for referrals */
+       if ( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
+               rc = rs->sr_err;
+               goto error_return;
+       }
 
 #ifndef SLAPD_MULTIMASTER
        /* This does not apply to multi-master case */
@@ -384,25 +389,37 @@ struct berval * slap_passwd_return(
        return bv;
 }
 
+/*
+ * if "e" is provided, access to each value of the password is checked first
+ */
 int
 slap_passwd_check(
-       Connection *conn,
-       Attribute *a,
-       struct berval *cred,
-       const char **text )
+       Operation       *op,
+       Entry           *e,
+       Attribute       *a,
+       struct berval   *cred,
+       const char      **text )
 {
-       int result = 1;
-       struct berval *bv;
+       int                     result = 1;
+       struct berval           *bv;
+       AccessControlState      acl_state = ACL_STATE_INIT;
 
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
        ldap_pvt_thread_mutex_lock( &passwd_mutex );
 #ifdef SLAPD_SPASSWD
-       lutil_passwd_sasl_conn = conn->c_sasl_authctx;
+       lutil_passwd_sasl_conn = op->o_conn->c_sasl_authctx;
 #endif
 #endif
 
        for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) {
-               if( !lutil_passwd( bv, cred, NULL, text ) ) {
+               /* if e is provided, check access */
+               if ( e && access_allowed( op, e, a->a_desc, bv,
+                                       ACL_AUTH, &acl_state ) == 0 )
+               {
+                       continue;
+               }
+               
+               if ( !lutil_passwd( bv, cred, NULL, text ) ) {
                        result = 0;
                        break;
                }
index f5894a62e41cc32fd1810983ff45bbbb812bf10a..ae35892417e599040daaf90a46abe8846ac37e8a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cc8f4fa494e11d13ad3cfe0dad4f430aedfaeaa8..2f91d7928f2deb98a6a1a3a35ddcfe6020a60585 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -246,7 +246,6 @@ LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be,
 LDAP_SLAPD_F (int) be_isroot LDAP_P(( Operation *op ));
 LDAP_SLAPD_F (int) be_isroot_dn LDAP_P(( Backend *be, struct berval *ndn ));
 LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Operation *op ));
-LDAP_SLAPD_F (int) be_sync_update LDAP_P(( Operation *op ));
 LDAP_SLAPD_F (int) be_slurp_update LDAP_P(( Operation *op ));
 #define be_isupdate( op ) be_slurp_update( (op) )
 LDAP_SLAPD_F (int) be_shadow_update LDAP_P(( Operation *op ));
@@ -296,6 +295,8 @@ LDAP_SLAPD_F (int) backend_operational LDAP_P((
        SlapReply *rs 
 ));
 
+LDAP_SLAPD_V(BackendInfo) slap_binfo[]; 
+
 /*
  * backglue.c
  */
@@ -752,7 +753,7 @@ LDAP_SLAPD_V (int)  krbv4_ldap_auth();
  * ldapsync.c
  */
 LDAP_SLAPD_F (void) slap_compose_sync_cookie LDAP_P((
-                               Operation *, struct berval *, struct berval *, int, int ));
+                               Operation *, struct berval *, struct berval *, int ));
 LDAP_SLAPD_F (void) slap_sync_cookie_free LDAP_P((
                                struct sync_cookie *, int free_cookie ));
 LDAP_SLAPD_F (int) slap_parse_sync_cookie LDAP_P((
@@ -1000,10 +1001,11 @@ LDAP_SLAPD_F (int) overlay_init( void );
 LDAP_SLAPD_F (SLAP_EXTOP_MAIN_FN) passwd_extop;
 
 LDAP_SLAPD_F (int) slap_passwd_check(
-       Connection                      *conn,
-       Attribute                       *attr,
+       Operation               *op,
+       Entry                   *e,
+       Attribute               *a,
        struct berval           *cred,
-       const char                      **text );
+       const char              **text );
 
 LDAP_SLAPD_F (void) slap_passwd_generate( struct berval * );
 
@@ -1015,18 +1017,18 @@ LDAP_SLAPD_F (void) slap_passwd_hash(
 LDAP_SLAPD_F (void) slap_passwd_hash_type(
        struct berval           *cred,
        struct berval           *hash,
-       char                            *htype,
+       char                    *htype,
        const char              **text );
 
 LDAP_SLAPD_F (struct berval *) slap_passwd_return(
        struct berval           *cred );
 
 LDAP_SLAPD_F (int) slap_passwd_parse(
-       struct berval *reqdata,
-       struct berval *id,
-       struct berval *oldpass,
-       struct berval *newpass,
-       const char **text );
+       struct berval           *reqdata,
+       struct berval           *id,
+       struct berval           *oldpass,
+       struct berval           *newpass,
+       const char              **text );
 
 /*
  * phonetic.c
@@ -1293,8 +1295,6 @@ LDAP_SLAPD_F (Entry*) slap_create_syncrepl_entry LDAP_P((
                                        struct berval *, struct berval * ));
 LDAP_SLAPD_F (struct berval *) slap_uuidstr_from_normalized LDAP_P((
                                        struct berval *, struct berval *, void * ));
-LDAP_SLAPD_F (int) syncrepl_isupdate LDAP_P(( Operation * ));
-LDAP_SLAPD_F (int) syncrepl_isupdate_dn LDAP_P(( Backend *, struct berval * ));
 LDAP_SLAPD_F (void) syncinfo_free LDAP_P(( syncinfo_t * ));
 
 /* syntax.c */
index 039e1957f3c00554564c8e81be3e87fcf7e94d07..ce3e4529f216c8a5e5b43e64c8cfad39e1da21c6 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -200,63 +200,70 @@ BerVarray referral_rewrite(
        struct berval *target,
        int scope )
 {
-       int i;
-       BerVarray refs;
-       struct berval *iv, *jv;
+       int             i;
+       BerVarray       refs;
+       struct berval   *iv, *jv;
 
-       if( in == NULL ) return NULL;
+       if ( in == NULL ) {
+               return NULL;
+       }
 
-       for( i=0; in[i].bv_val != NULL ; i++ ) {
+       for ( i = 0; !BER_BVISNULL( &in[i] ); i++ ) {
                /* just count them */
        }
 
-       if( i < 1 ) return NULL;
+       if ( i < 1 ) {
+               return NULL;
+       }
 
-       refs = SLAP_MALLOC( (i+1) * sizeof( struct berval ) );
-       if( refs == NULL ) {
+       refs = SLAP_MALLOC( ( i + 1 ) * sizeof( struct berval ) );
+       if ( refs == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                        "referral_rewrite: SLAP_MALLOC failed\n", 0, 0, 0 );
                return NULL;
        }
 
-       for( iv=in,jv=refs; iv->bv_val != NULL ; iv++ ) {
-               LDAPURLDesc *url;
-               int rc = ldap_url_parse_ext( iv->bv_val, &url );
-
-               if( rc == LDAP_URL_ERR_BADSCHEME ) {
+       for ( iv = in, jv = refs; !BER_BVISNULL( iv ); iv++ ) {
+               LDAPURLDesc     *url;
+               char            *dn;
+               int             rc;
+               
+               rc = ldap_url_parse_ext( iv->bv_val, &url );
+               if ( rc == LDAP_URL_ERR_BADSCHEME ) {
                        ber_dupbv( jv++, iv );
                        continue;
 
-               } else if( rc != LDAP_URL_SUCCESS ) {
+               } else if ( rc != LDAP_URL_SUCCESS ) {
                        continue;
                }
 
-               {
-                       char *dn = url->lud_dn;
-                       url->lud_dn = referral_dn_muck(
-                               ( dn && *dn ) ? dn : NULL,
+               dn = url->lud_dn;
+               url->lud_dn = referral_dn_muck( ( dn && *dn ) ? dn : NULL,
                                base, target );
+               ldap_memfree( dn );
 
-                       ldap_memfree( dn );
-               }
-
-               if( url->lud_scope == LDAP_SCOPE_DEFAULT ) {
+               if ( url->lud_scope == LDAP_SCOPE_DEFAULT ) {
                        url->lud_scope = scope;
                }
 
                jv->bv_val = ldap_url_desc2str( url );
-               jv->bv_len = strlen( jv->bv_val );
+               if ( jv->bv_val != NULL ) {
+                       jv->bv_len = strlen( jv->bv_val );
 
-               ldap_free_urldesc( url );
+               } else {
+                       ber_dupbv( jv, iv );
+               }
                jv++;
+
+               ldap_free_urldesc( url );
        }
 
-       if( jv == refs ) {
+       if ( jv == refs ) {
                ch_free( refs );
                refs = NULL;
 
        } else {
-               jv->bv_val = NULL;
+               BER_BVZERO( jv );
        }
 
        return refs;
index 9cf8c1cac165cd3c9cff5f647c9fc7707516b8a2..28a2100a57ca14d7298a81d71a0928d575da56d1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9a05fb06a52f39a7fe1e65a7e663f223b77c2c65..9c9d2ea587cc8660726e6a8f70e2c3fdbe8186ad 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 642decbc88d850bc63855f95d17e01595b4f307c..46e77968ce0b33418d6264eea9167986bc654a45 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,10 @@ static struct berval supportedFeatures[] = {
        BER_BVC(LDAP_FEATURE_ABSOLUTE_FILTERS),         /* (&) and (|) search filters */
        BER_BVC(LDAP_FEATURE_LANGUAGE_TAG_OPTIONS), /* Language Tag Options */
        BER_BVC(LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS),/* Language Range Options */
-
-#ifdef LDAP_DEVEL
+#ifdef LDAP_FEATURE_SUBORDINATE_SCOPE
        BER_BVC(LDAP_FEATURE_SUBORDINATE_SCOPE),        /* "children" search scope */
+#endif
+#ifdef LDAP_FEATURE_MODIFY_INCREMENT
        BER_BVC(LDAP_FEATURE_MODIFY_INCREMENT),         /* Modify/increment */
 #endif
        {0,NULL}
index 0587c62e92def1d53a688a20ec70322be89ff616..a5f9d6718f6a3de5b39074b3c3faf540a4af6e62 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a770ef62a812f0cece2c7efe4d330cf63964b5ee..1c0c1339c6c87d752f12b2641748b26363bbc916 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 2000 Mark Adamson, Carnegie Mellon.
  * All rights reserved.
  *
@@ -700,7 +700,9 @@ static int slap_authz_regexp( struct berval *in, struct berval *out,
                if ( !BER_BVISNULL( out ) ) {
                        char *val = out->bv_val;
                        ber_str2bv_x( val, 0, 1, out, ctx );
-                       free( val );
+                       if ( val != in->bv_val ) {
+                               free( val );
+                       }
                } else {
                        ber_dupbv_x( out, in, ctx );
                }
index 69d243b04d5dc4fb540fc7483b212111b121f6eb..bd1601ce0da03b76c69c08a3afba93f3b84c9248 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9fd0a17d5564a47c8f31c1cb92b8a7c34117921d..958a8ab40b028aa93a3d323e3f7c4555a1288a6a 100644 (file)
@@ -4,16 +4,16 @@ with slapd(8).
 File                    Description
 ----                    -----------
 collective.schema       Collective attributes (experimental)
-corba.schema            Corba Object (RFC 2714)
+corba.schema            Corba Object
 core.schema             OpenLDAP "core"
 cosine.schema           COSINE Pilot
-duaconf.schema          Client Configuration (experimental)
+dyngroup.schema                        Dynamic Group (experimental)
 inetorgperson.schema    InetOrgPerson
-java.schema             Java Object (RFC 2713)
+java.schema             Java Object
 misc.schema             Miscellaneous Schema (experimental)
 nis.schema              Network Information Service
 openldap.schema         OpenLDAP Project (FYI)
-ppolicy.schema          Password Policy Schema (experimental)
+ppolicy.schema          Password Policy Schema (work in progress)
 
 Additional "generally useful" schema definitions can be submitted
 using the OpenLDAP Issue Tracking System <http://www.openldap.org/its/>.
@@ -24,7 +24,7 @@ technical specification (e.g., an RFC) for the schema.
 
 This notice applies to all files in this directory.
 
-Copyright 1998-2004 The OpenLDAP Foundation, Redwood City, California, USA
+Copyright 1998-2005 The OpenLDAP Foundation, Redwood City, California, USA
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/servers/slapd/schema/collective.schema b/servers/slapd/schema/collective.schema
deleted file mode 100644 (file)
index 1472af7..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-# collective.schema -- Collective attribute schema
-# $OpenLDAP$
-## This work is part of OpenLDAP Software <http://www.openldap.org/>.
-##
-## Copyright 1998-2004 The OpenLDAP Foundation.
-## All rights reserved.
-##
-## Redistribution and use in source and binary forms, with or without
-## modification, are permitted only as authorized by the OpenLDAP
-## Public License.
-##
-## A copy of this license is available in the file LICENSE in the
-## top-level directory of the distribution or, alternatively, at
-## <http://www.OpenLDAP.org/license.html>.
-#
-## Portions Copyright (C) The Internet Society (2003).  All Rights Reserved.
-## Please see full copyright statement below.
-
-# From draft-zeilenga-ldap-collective-xx.txt [portions trimmed]:
-#                      Collective Attributes in LDAP
-
-#Abstract
-#
-#  X.500 collective attributes allow common characteristics to be shared
-#  between collections of entries.  This document summarizes the X.500
-#  information model for collective attributes and describes use of
-#  collective attributes in LDAP (Lightweight Directory Access Protocol).
-#  This document provides schema definitions for collective attributes
-#  for use in LDAP.
-
-#3. Collective Attribute Types
-#
-#  A userApplications attribute type can be defined to be COLLECTIVE
-#  [RFC2252].  This indicates that the same attribute values will appear
-#  in the entries of an entry collection subject to the use of the
-#  collectiveExclusions attribute and other administrative controls.
-#
-#  Collective attribute types are commonly defined as subtypes of non-
-#  collective attribute types.  By convention, collective attributes are
-#  named by prefixing the name of their non-collective supertype with
-#  "c-".  For example, the collective telephone attribute is named
-#  c-TelephoneNumber after its non-collective supertype telephoneNumber.
-#
-#  Non-collective attributes types SHALL NOT subtype collective
-#  attributes.
-#
-#  Collective attributes SHALL NOT be SINGLE-VALUED.  Collective
-#  attribute types SHALL NOT appear in the attribute types of an object
-#  class definition.
-#
-#  Operational attributes SHALL NOT be defined to be collective.
-#
-#  The remainder of section provides a summary of collective attributes
-#  derived from those defined in [X.520].  Implementations of this
-#  specification SHOULD support the following collective attributes and
-#  MAY support additional collective attributes.
-#
-#
-#3.1. Collective Locality Name
-#
-#  The c-l attribute type specifies a locality name for a collection of
-#  entries.
-#
-attributeType      ( 2.5.4.7.1 NAME 'c-l'
-       SUP l COLLECTIVE )
-#
-#
-#3.2. Collective State or Province Name
-#
-#  The c-st attribute type specifies a state or province name for a
-#  collection of entries.
-#
-attributeType      ( 2.5.4.8.1 NAME 'c-st'
-       SUP st COLLECTIVE )
-#
-#
-#3.3. Collective Street Address
-#
-#  The c-street attribute type specifies a street address for a
-#  collection of entries.
-#
-attributeType      ( 2.5.4.9.1 NAME 'c-street'
-       SUP street COLLECTIVE )
-#
-#
-#3.4. Collective Organization Name
-#
-#  The c-o attribute type specifies an organization name for a collection
-#  of entries.
-#
-attributeType      ( 2.5.4.10.1 NAME 'c-o'
-       SUP o COLLECTIVE )
-#
-#
-#3.5. Collective Organizational Unit Name
-#
-#  The c-ou attribute type specifies an organizational unit name for a
-#  collection of entries.
-#
-attributeType      ( 2.5.4.11.1 NAME 'c-ou'
-       SUP ou COLLECTIVE )
-#
-#
-#3.6. Collective Postal Address
-#
-#  The c-PostalAddress attribute type specifies a postal address for a
-#  collection of entries.
-#
-attributeType      ( 2.5.4.16.1 NAME 'c-PostalAddress'
-       SUP postalAddress COLLECTIVE )
-#
-#
-#3.7. Collective Postal Code
-#
-#  The c-PostalCode attribute type specifies a postal code for a
-#  collection of entries.
-#
-attributeType      ( 2.5.4.17.1 NAME 'c-PostalCode'
-       SUP postalCode COLLECTIVE )
-#
-#
-#3.8. Collective Post Office Box
-#
-#  The c-PostOfficeBox attribute type specifies a post office box for a
-#  collection of entries.
-#
-attributeType ( 2.5.4.18.1 NAME 'c-PostOfficeBox'
-       SUP postOfficeBox COLLECTIVE )
-#
-#
-#3.9. Collective Physical Delivery Office Name
-#
-#  The c-PhysicalDeliveryOfficeName attribute type specifies a physical
-#  delivery office name for a collection of entries.
-#
-attributeType ( 2.5.4.19.1 NAME 'c-PhysicalDeliveryOfficeName'
-       SUP physicalDeliveryOfficeName COLLECTIVE )
-#
-#
-#3.10. Collective Telephone Number
-#
-#  The c-TelephoneNumber attribute type specifies a telephone number for
-#  a collection of entries.
-#
-attributeType ( 2.5.4.20.1 NAME 'c-TelephoneNumber'
-       SUP telephoneNumber COLLECTIVE )
-#
-#
-#3.11. Collective Telex Number
-#
-#  The c-TelexNumber attribute type specifies a telex number for a
-#  collection of entries.
-#
-attributeType ( 2.5.4.21.1 NAME 'c-TelexNumber'
-       SUP telexNumber COLLECTIVE )
-#
-#
-#3.13. Collective Facsimile Telephone Number
-#
-#  The c-FacsimileTelephoneNumber attribute type specifies a facsimile
-#  telephone number for a collection of entries.
-#
-attributeType ( 2.5.4.23.1 NAME 'c-FacsimileTelephoneNumber'
-       SUP facsimileTelephoneNumber COLLECTIVE )
-#
-#
-#3.14. Collective International ISDN Number
-#
-#  The c-InternationalISDNNumber attribute type specifies an
-#  international ISDN number for a collection of entries.
-#
-attributeType ( 2.5.4.25.1 NAME 'c-InternationalISDNNumber'
-       SUP internationalISDNNumber COLLECTIVE )
-
-# Full Copyright
-#
-# Copyright (C) The Internet Society (2003). All Rights Reserved.
-# 
-# This document and translations of it may be copied and furnished
-# to others, and derivative works that comment on or otherwise explain
-# it or assist in its implmentation may be prepared, copied, published
-# and distributed, in whole or in part, without restriction of any
-# kind, provided that the above copyright notice and this paragraph
-# are included on all such copies and derivative works.  However,
-# this document itself may not be modified in any way, such as by
-# removing the copyright notice or references to the Internet Society
-# or other Internet organizations, except as needed for the  purpose
-# of developing Internet standards in which case the procedures for
-# copyrights defined in the Internet Standards process must be followed,
-# or as required to translate it into languages other than English.
index 0bdcdb802e40cc5207779e852907e31edbad9c56..6cf26f22f3834e84dc1bedf1554a9e929c3f5a4a 100644 (file)
@@ -4,7 +4,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 #
-## Portions Copyright (C) The Internet Society (1999).  All Rights Reserved.
+## Portions Copyright (C) The Internet Society (1999).
 ## Please see full copyright statement below.
 
 
index 8c6603074e51953ac2af44191110189a985b43c3..9a23e7b255ed6ba35d0f903402a17e92d9816312 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -127,9 +127,9 @@ attributetype ( 2.5.4.13 NAME 'description'
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )
 
-# Obsoleted by enhancedSearchGuide
+# Deprecated by enhancedSearchGuide
 attributetype ( 2.5.4.14 NAME 'searchGuide'
-       DESC 'RFC2256: search guide, obsoleted by enhancedSearchGuide'
+       DESC 'RFC2256: search guide, deprecated by enhancedSearchGuide'
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 )
 
 attributetype ( 2.5.4.15 NAME 'businessCategory'
@@ -339,6 +339,9 @@ attributetype ( 2.5.4.54 NAME 'dmdName'
        DESC 'RFC2256: name of DMD'
        SUP name )
 
+attributetype ( 2.5.4.65 NAME 'pseudonym'
+       DESC 'X.520(4th): pseudonym for the object'
+       SUP name )
 
 # Standard object classes from RFC2256
 
@@ -573,7 +576,7 @@ attributetype ( 0.9.2342.19200300.100.1.37
 # RFC 2459 -- deprecated in favor of 'mail' (in cosine.schema)
 attributetype ( 1.2.840.113549.1.9.1
        NAME ( 'email' 'emailAddress' 'pkcs9email' )
-       DESC 'RFC2459: legacy attribute for email addresses in DNs'
+       DESC 'RFC3280: legacy attribute for email addresses in DNs'
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} )
index 4ef23418d514d3118788cb48c51b3805da2310f8..d97a5c1b8708e5548fae2678302f46140f8bbcb0 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -421,7 +421,7 @@ attributetype ( 0.9.2342.19200300.100.1.22 NAME 'otherMailbox'
 #            uTCTimeSyntax
 #    ::= {pilotAttributeType 23}
 #
-## OBSOLETE
+## Deprecated in favor of modifyTimeStamp
 #attributetype ( 0.9.2342.19200300.100.1.23 NAME 'lastModifiedTime'
 #      DESC 'RFC1274: time of last modify, replaced by modifyTimestamp'
 #      OBSOLETE
@@ -439,7 +439,7 @@ attributetype ( 0.9.2342.19200300.100.1.22 NAME 'otherMailbox'
 #            distinguishedNameSyntax
 #    ::= {pilotAttributeType 24}
 #
-## OBSOLETE
+## Deprecated in favor of modifiersName
 #attributetype ( 0.9.2342.19200300.100.1.24 NAME 'lastModifiedBy'
 #      DESC 'RFC1274: last modifier, replaced by modifiersName'
 #      OBSOLETE
diff --git a/servers/slapd/schema/duaconf.schema b/servers/slapd/schema/duaconf.schema
deleted file mode 100644 (file)
index c1fc5de..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-# $OpenLDAP$
-## This work is part of OpenLDAP Software <http://www.openldap.org/>.
-##
-## Copyright 1998-2004 The OpenLDAP Foundation.
-## All rights reserved.
-##
-## Redistribution and use in source and binary forms, with or without
-## modification, are permitted only as authorized by the OpenLDAP
-## Public License.
-##
-## A copy of this license is available in the file LICENSE in the
-## top-level directory of the distribution or, alternatively, at
-## <http://www.OpenLDAP.org/license.html>.
-
-## Notes:
-## - The matching rule for attributes followReferrals and dereferenceAliases
-##   has been changed to booleanMatch since their syntax is boolean
-## - There was a typo in the name of the dereferenceAliases attributeType
-##   in the DUAConfigProfile objectClass definition
-## - Credit goes to the original Authors
-
-# 
-# Application Working Group                                      M. Ansari
-# INTERNET-DRAFT                                    Sun Microsystems, Inc.
-# Expires Febuary 2003                                           L. Howard
-#                                                  PADL Software Pty. Ltd.
-#                                                          B. Joslin [ed.]
-#                                                  Hewlett-Packard Company
-# 
-#                                                     September 15th, 2003
-# Intended Category: Informational
-# 
-# 
-#                  A Configuration Schema for LDAP Based
-#                          Directory User Agents
-#                   <draft-joslin-config-schema-07.txt>
-#
-#Status of this Memo
-#
-#    This memo provides information for the Internet community.  This
-#    memo does not specify an Internet standard of any kind.  Distribu-
-#    tion of this memo is unlimited.
-#         
-#    This document is an Internet-Draft and is in full conformance with
-#    all provisions of Section 10 of RFC2026.
-#    
-#    This document is an Internet-Draft. Internet-Drafts are working  
-#    documents of the Internet Engineering Task Force (IETF), its areas,
-#    and its working groups. Note that other groups may also distribute
-#    working documents as Internet-Drafts.
-#    
-#    Internet-Drafts are draft documents valid for a maximum of six
-#    months.  Internet-Drafts may be updated, replaced, or made obsolete
-#    by other documents at any time. It is not appropriate to use 
-#    Internet-Drafts as reference material or to cite them other than as
-#    a "working draft" or "work in progress".                
-#         
-#    To learn the current status of any Internet-Draft, please check the
-#    1id-abstracts.txt listing contained in the Internet-Drafts Shadow 
-#    Directories on ds.internic.net (US East Coast), nic.nordu.net      
-#    (Europe), ftp.isi.edu (US West Coast), or munnari.oz.au (Pacific
-#    Rim).
-#    
-#    Distribution of this document is unlimited.
-# 
-# 
-# Abstract
-# 
-#      This document describes a mechanism for global configuration of
-#      similar directory user agents.  This document defines a schema for
-#      configuration of these DUAs that may be discovered using the Light-
-#      weight Directory Access Protocol in RFC 2251[17].  A set of attri-
-#      bute types and an objectclass are proposed, along with specific
-#      guidelines for interpreting them.  A significant feature of the
-#      global configuration policy for DUAs is a mechanism that allows
-#      DUAs to re-configure their schema to that of the end user's
-#      environment.  This configuration is achieved through attribute and
-#      objectclass mapping.  This document is intended to be a skeleton
-#      for future documents that describe configuration of specific DUA
-#      services.
-# 
-# 
-# [trimmed]
-# 
-# 
-# 2.  General Issues
-# 
-#      The schema defined by this document is defined under the "DUA Con-
-#      figuration Schema."  This schema is derived from the OID: iso (1)
-#      org (3) dod (6) internet (1) private (4) enterprises (1) Hewlett-
-#      Packard Company (11) directory (1) LDAP-UX Integration Project (3)
-#      DUA Configuration Schema (1).  This OID is represented in this
-#      document by the keystring "DUAConfSchemaOID"
-#      (1.3.6.1.4.1.11.1.3.1).
-objectidentifier DUAConfSchemaOID 1.3.6.1.4.1.11.1.3.1
-# 
-# 2.2 Attributes
-# 
-#      The attributes and classes defined in this document are summarized
-#      below.
-# 
-#      The following attributes are defined in this document:
-# 
-#           preferredServerList
-#           defaultServerList
-#           defaultSearchBase
-#           defaultSearchScope
-#           authenticationMethod
-#           credentialLevel
-#           serviceSearchDescriptor
-# 
-# 
-# 
-# Joslin                                                         [Page 3]
-# Internet-Draft          DUA Configuration Schema            October 2002
-# 
-# 
-#           serviceCredentialLevel
-#           serviceAuthenticationMethod
-#           attributeMap
-#           objectclassMap
-#           searchTimeLimit
-#           bindTimeLimit
-#           followReferrals
-#           dereferenceAliases
-#           profileTTL
-# 
-# 2.3 Object Classes
-# 
-#      The following object class is defined in this document:
-# 
-#           DUAConfigProfile
-# 
-# 
-attributeType ( DUAConfSchemaOID:1.0 NAME 'defaultServerList'
-            DESC 'Default LDAP server host address used by a DUA'
-            EQUALITY caseIgnoreMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.1 NAME 'defaultSearchBase'
-            DESC 'Default LDAP base DN used by a DUA'
-            EQUALITY distinguishedNameMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.2 NAME 'preferredServerList'
-            DESC 'Preferred LDAP server host addresses to be used by a
-            DUA'
-            EQUALITY caseIgnoreMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.3 NAME 'searchTimeLimit'
-            DESC 'Maximum time in seconds a DUA should allow for a
-            search to complete'
-            EQUALITY integerMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.4 NAME 'bindTimeLimit'
-            DESC 'Maximum time in seconds a DUA should allow for the
-            bind operation to complete'
-            EQUALITY integerMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.5 NAME 'followReferrals'
-            DESC 'Tells DUA if it should follow referrals
-            returned by a DSA search result'
-            EQUALITY booleanMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.16 NAME 'dereferenceAliases'
-            DESC 'Tells DUA if it should dereference aliases'
-            EQUALITY booleanMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.6 NAME 'authenticationMethod'
-            DESC 'A keystring which identifies the type of
-            authentication method used to contact the DSA'
-            EQUALITY caseIgnoreMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.7 NAME 'profileTTL'
-            DESC 'Time to live, in seconds, before a client DUA
-            should re-read this configuration profile'
-            EQUALITY integerMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.14 NAME 'serviceSearchDescriptor'
-            DESC 'LDAP search descriptor list used by a DUA'
-            EQUALITY caseExactMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
-
-attributeType ( DUAConfSchemaOID:1.9 NAME 'attributeMap'
-            DESC 'Attribute mappings used by a DUA'
-            EQUALITY caseIgnoreIA5Match
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
-
-attributeType ( DUAConfSchemaOID:1.10 NAME 'credentialLevel'
-            DESC 'Identifies type of credentials a DUA should
-            use when binding to the LDAP server'
-            EQUALITY caseIgnoreIA5Match
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.11 NAME 'objectclassMap'
-            DESC 'Objectclass mappings used by a DUA'
-            EQUALITY caseIgnoreIA5Match
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
-
-attributeType ( DUAConfSchemaOID:1.12 NAME 'defaultSearchScope'
-            DESC 'Default search scope used by a DUA'
-            EQUALITY caseIgnoreIA5Match
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
-            SINGLE-VALUE )
-
-attributeType ( DUAConfSchemaOID:1.13 NAME 'serviceCredentialLevel'
-            DESC 'Identifies type of credentials a DUA
-            should use when binding to the LDAP server for a
-            specific service'
-            EQUALITY caseIgnoreIA5Match
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
-
-attributeType ( DUAConfSchemaOID:1.15 NAME 'serviceAuthenticationMethod'
-            DESC 'Authentication method used by a service of the DUA'
-            EQUALITY caseIgnoreMatch
-            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
-# 
-# 4.  Class Definition
-# 
-#      The objectclass below is constructed from the attributes defined in
-#      3, with the exception of the cn attribute, which is defined in RFC
-#      2256 [8].  cn is used to represent the name of the DUA configura-
-#      tion profile.
-# 
-objectClass ( DUAConfSchemaOID:2.5 NAME 'DUAConfigProfile'
-          SUP top STRUCTURAL
-          DESC 'Abstraction of a base configuration for a DUA'
-          MUST ( cn )
-          MAY ( defaultServerList $ preferredServerList $
-                defaultSearchBase $ defaultSearchScope $
-                searchTimeLimit $ bindTimeLimit $
-                credentialLevel $ authenticationMethod $
-                followReferrals $ dereferenceAliases $
-                serviceSearchDescriptor $ serviceCredentialLevel $
-                serviceAuthenticationMethod $ objectclassMap $
-                attributeMap $ profileTTL ) )
index 108f3bf26449ab73f391c20bee0c870c8e7d8240..d0b955fd39abf74c2b40f1ede4cb9d2242265033 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 #
-# Dynamic Group schema, as defined by Netscape
+# Dynamic Group schema (experimental), as defined by Netscape.  See
+# http://enterprise.netscape.com/docs/enterprise/60/admin/esusrgrp.htm#1019520
+# for details.
 #
 # depends upon:
 #      core.schema
+#
+# These definitions are considered experimental due to the lack of
+# a formal specification (e.g., RFC).
+#
+# Not recommended for production use!  Use with caution!
 
 objectIdentifier NetscapeRoot 2.16.840.1.113730
 
index aa6471211738efbacd1890e8d0dad23f624f7d54..95d3459ff3b7c23706a430a61bbf8adf50a11992 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 17260b7c45abd3d131dab6159c4771f20cb3b4d8..0757aa29c80c283a9266178f33d5c41aff071988 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 3cd8faaa1b1ea21247f62ddc81e48b3e37e2878e..00ea6711b66bf743aabd2924756c0488609a2fbe 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -21,8 +21,8 @@
 # Use with extreme caution!
 
 #-----------------------------------------------------------
-#
 # draft-lachman-laser-ldap-mail-routing-02.txt !!!EXPIRED!!!
+#      (a work in progress)
 #
 attributetype ( 2.16.840.1.113730.3.1.13
        NAME 'mailLocalAddress'
@@ -54,8 +54,8 @@ objectclass ( 2.16.840.1.113730.3.2.147
        MAY     ( mailLocalAddress $ mailHost $ mailRoutingAddress ) )
 
 #-----------------------------------------------------------
-#
 # draft-srivastava-ldap-mail-00.txt !!!EXPIRED!!!
+#      (a work in progress)
 #
 attributetype ( 1.3.6.1.4.1.42.2.27.2.1.15
        NAME 'rfc822MailMember'
@@ -64,8 +64,8 @@ attributetype ( 1.3.6.1.4.1.42.2.27.2.1.15
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
 
 #-----------------------------------------------------------
-# 
 # !!!no I-D!!!
+#      (a work in progress)
 #
 objectclass ( 1.3.6.1.4.1.42.2.27.1.2.5
        NAME 'nisMailAlias'
index 055ccf419f87a506ed530742ebab9afb5283c622..0f07b9621339d969c658e12775a77f44fae13f29 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 2f520afe8ce6cb6223c035868d7da48f9aef65fc..c82e60a6ee8ea7215d71d2ffc95e6750f3d039dd 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 02e68552292d0224c5d2d8f7208b52d6051f08d5..183dca5754aa880132b0910727aba603c7f0eaaa 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 #
-## Portions Copyright (C) The Internet Society (2004).  All Rights Reserved.
+## Portions Copyright (C) The Internet Society (2004).
 ## Please see full copyright statement below.
 
-# Definitions from Draft behera-ldap-password-policy-07
+# Definitions from Draft behera-ldap-password-policy-07 (a work in progress)
 #      Password Policy for LDAP Directories
-
 # With extensions from Hewlett-Packard:
 #      pwdCheckModule etc.
 
-# 
+# Contents of this file are subject to change (including deletion)
+# without notice.
+#
+# Not recommended for production use!
+# Use with extreme caution!
+
 # Internet-Draft                                                P. Behera
 # draft behera-ldap-password-policy-07.txt                      L. Poitou
 # Intended Category: Proposed Standard                   Sun Microsystems
index 0da634d81246dd7093d3a421630c2f87efd27117..d76593475873fb1d3815261825f904dc93bae520 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -684,6 +684,8 @@ int structural_class(
                return LDAP_OBJECT_CLASS_VIOLATION;
        }
 
+       *text = NULL;
+
        return LDAP_SUCCESS;
 }
 
index 6cbf98af2e433c028332a262d4631c12b03a061a..a9df65cf9612e29045e32396b5acf082d7f44d9e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -161,6 +161,7 @@ octetStringOrderingMatch(
        return LDAP_SUCCESS;
 }
 
+void
 hashDigestify(
        HASH_CONTEXT *HASHcontext,
        unsigned char *HASHdigest,
@@ -204,7 +205,7 @@ int octetStringIndexer(
        digest.bv_val = (char *)HASHdigest;
        digest.bv_len = sizeof(HASHdigest);
 
-       for( i=0; values[i].bv_val != NULL; i++ ) {
+       for( i=0; !BER_BVISNULL( &values[i] ); i++ ) {
                /* just count them */
        }
 
@@ -216,14 +217,13 @@ int octetStringIndexer(
        slen = syntax->ssyn_oidlen;
        mlen = mr->smr_oidlen;
 
-       for( i=0; values[i].bv_val != NULL; i++ ) {
+       for( i=0; !BER_BVISNULL( &values[i] ); i++ ) {
                hashDigestify( &HASHcontext, HASHdigest, prefix, 0,
                        syntax, mr, (unsigned char *)values[i].bv_val, values[i].bv_len );
                ber_dupbv_x( &keys[i], &digest, ctx );
        }
 
-       keys[i].bv_val = NULL;
-       keys[i].bv_len = 0;
+       BER_BVZERO( &keys[i] );
 
        *keysp = keys;
 
@@ -259,8 +259,7 @@ int octetStringFilter(
                syntax, mr, (unsigned char *)value->bv_val, value->bv_len );
 
        ber_dupbv_x( keys, &digest, ctx );
-       keys[1].bv_val = NULL;
-       keys[1].bv_len = 0;
+       BER_BVZERO( &keys[1] );
 
        *keysp = keys;
 
@@ -283,20 +282,20 @@ octetStringSubstringsMatch(
        ber_len_t inlen = 0;
 
        /* Add up asserted input length */
-       if( sub->sa_initial.bv_val ) {
+       if ( !BER_BVISNULL( &sub->sa_initial ) ) {
                inlen += sub->sa_initial.bv_len;
        }
-       if( sub->sa_any ) {
-               for(i=0; sub->sa_any[i].bv_val != NULL; i++) {
+       if ( sub->sa_any ) {
+               for ( i = 0; !BER_BVISNULL( &sub->sa_any[i] ); i++ ) {
                        inlen += sub->sa_any[i].bv_len;
                }
        }
-       if( sub->sa_final.bv_val ) {
+       if ( !BER_BVISNULL( &sub->sa_final ) ) {
                inlen += sub->sa_final.bv_len;
        }
 
-       if( sub->sa_initial.bv_val ) {
-               if( inlen > left.bv_len ) {
+       if ( !BER_BVISNULL( &sub->sa_initial ) ) {
+               if ( inlen > left.bv_len ) {
                        match = 1;
                        goto done;
                }
@@ -304,7 +303,7 @@ octetStringSubstringsMatch(
                match = memcmp( sub->sa_initial.bv_val, left.bv_val,
                        sub->sa_initial.bv_len );
 
-               if( match != 0 ) {
+               if ( match != 0 ) {
                        goto done;
                }
 
@@ -313,8 +312,8 @@ octetStringSubstringsMatch(
                inlen -= sub->sa_initial.bv_len;
        }
 
-       if( sub->sa_final.bv_val ) {
-               if( inlen > left.bv_len ) {
+       if ( !BER_BVISNULL( &sub->sa_final ) ) {
+               if ( inlen > left.bv_len ) {
                        match = 1;
                        goto done;
                }
@@ -323,7 +322,7 @@ octetStringSubstringsMatch(
                        &left.bv_val[left.bv_len - sub->sa_final.bv_len],
                        sub->sa_final.bv_len );
 
-               if( match != 0 ) {
+               if ( match != 0 ) {
                        goto done;
                }
 
@@ -331,19 +330,19 @@ octetStringSubstringsMatch(
                inlen -= sub->sa_final.bv_len;
        }
 
-       if( sub->sa_any ) {
-               for(i=0; sub->sa_any[i].bv_val; i++) {
+       if ( sub->sa_any ) {
+               for ( i = 0; !BER_BVISNULL( &sub->sa_any[i] ); i++ ) {
                        ber_len_t idx;
                        char *p;
 
 retry:
-                       if( inlen > left.bv_len ) {
+                       if ( inlen > left.bv_len ) {
                                /* not enough length */
                                match = 1;
                                goto done;
                        }
 
-                       if( sub->sa_any[i].bv_len == 0 ) {
+                       if ( BER_BVISEMPTY( &sub->sa_any[i] ) ) {
                                continue;
                        }
 
@@ -356,7 +355,7 @@ retry:
 
                        idx = p - left.bv_val;
 
-                       if( idx >= left.bv_len ) {
+                       if ( idx >= left.bv_len ) {
                                /* this shouldn't happen */
                                return LDAP_OTHER;
                        }
@@ -364,7 +363,7 @@ retry:
                        left.bv_val = p;
                        left.bv_len -= idx;
 
-                       if( sub->sa_any[i].bv_len > left.bv_len ) {
+                       if ( sub->sa_any[i].bv_len > left.bv_len ) {
                                /* not enough left */
                                match = 1;
                                goto done;
@@ -374,7 +373,7 @@ retry:
                                sub->sa_any[i].bv_val,
                                sub->sa_any[i].bv_len );
 
-                       if( match != 0 ) {
+                       if ( match != 0 ) {
                                left.bv_val++;
                                left.bv_len--;
                                goto retry;
@@ -413,9 +412,9 @@ octetStringSubstringsIndexer(
        digest.bv_val = (char *)HASHdigest;
        digest.bv_len = sizeof(HASHdigest);
 
-       nkeys=0;
+       nkeys = 0;
 
-       for( i=0; values[i].bv_val != NULL; i++ ) {
+       for ( i = 0; !BER_BVISNULL( &values[i] ); i++ ) {
                /* count number of indices to generate */
                if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
                        if( values[i].bv_len >= index_substr_if_maxlen ) {
@@ -453,8 +452,8 @@ octetStringSubstringsIndexer(
        slen = syntax->ssyn_oidlen;
        mlen = mr->smr_oidlen;
 
-       nkeys=0;
-       for( i=0; values[i].bv_val != NULL; i++ ) {
+       nkeys = 0;
+       for ( i = 0; !BER_BVISNULL( &values[i] ); i++ ) {
                ber_len_t j,max;
 
                if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
@@ -497,7 +496,7 @@ octetStringSubstringsIndexer(
        }
 
        if( nkeys > 0 ) {
-               keys[nkeys].bv_val = NULL;
+               BER_BVZERO( &keys[nkeys] );
                *keysp = keys;
        } else {
                ch_free( keys );
@@ -531,7 +530,7 @@ octetStringSubstringsFilter (
        sa = (SubstringsAssertion *) assertedValue;
 
        if( flags & SLAP_INDEX_SUBSTR_INITIAL &&
-               sa->sa_initial.bv_val != NULL &&
+               !BER_BVISNULL( &sa->sa_initial ) &&
                sa->sa_initial.bv_len >= index_substr_if_minlen )
        {
                nkeys++;
@@ -542,9 +541,9 @@ octetStringSubstringsFilter (
                }
        }
 
-       if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
+       if ( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
                ber_len_t i;
-               for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) {
+               for( i=0; !BER_BVISNULL( &sa->sa_any[i] ); i++ ) {
                        if( sa->sa_any[i].bv_len >= index_substr_any_len ) {
                                /* don't bother accounting with stepping */
                                nkeys += sa->sa_any[i].bv_len -
@@ -554,7 +553,7 @@ octetStringSubstringsFilter (
        }
 
        if( flags & SLAP_INDEX_SUBSTR_FINAL &&
-               sa->sa_final.bv_val != NULL &&
+               !BER_BVISNULL( &sa->sa_final ) &&
                sa->sa_final.bv_len >= index_substr_if_minlen )
        {
                nkeys++;
@@ -580,7 +579,7 @@ octetStringSubstringsFilter (
        nkeys = 0;
 
        if( flags & SLAP_INDEX_SUBSTR_INITIAL &&
-               sa->sa_initial.bv_val != NULL &&
+               !BER_BVISNULL( &sa->sa_initial ) &&
                sa->sa_initial.bv_len >= index_substr_if_minlen )
        {
                pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
@@ -614,7 +613,7 @@ octetStringSubstringsFilter (
                pre = SLAP_INDEX_SUBSTR_PREFIX;
                klen = index_substr_any_len;
 
-               for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) {
+               for( i=0; !BER_BVISNULL( &sa->sa_any[i] ); i++ ) {
                        if( sa->sa_any[i].bv_len < index_substr_any_len ) {
                                continue;
                        }
@@ -633,7 +632,7 @@ octetStringSubstringsFilter (
        }
 
        if( flags & SLAP_INDEX_SUBSTR_FINAL &&
-               sa->sa_final.bv_val != NULL &&
+               !BER_BVISNULL( &sa->sa_final ) &&
                sa->sa_final.bv_len >= index_substr_if_minlen )
        {
                pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
@@ -663,7 +662,7 @@ octetStringSubstringsFilter (
        }
 
        if( nkeys > 0 ) {
-               keys[nkeys].bv_val = NULL;
+               BER_BVZERO( &keys[nkeys] );
                *keysp = keys;
        } else {
                ch_free( keys );
@@ -695,13 +694,13 @@ bitStringValidate(
         */
        
        if( in->bv_val[0] != '\'' ||
-               in->bv_val[in->bv_len-2] != '\'' ||
-               in->bv_val[in->bv_len-1] != 'B' )
+               in->bv_val[in->bv_len - 2] != '\'' ||
+               in->bv_val[in->bv_len - 1] != 'B' )
        {
                return LDAP_INVALID_SYNTAX;
        }
 
-       for( i=in->bv_len-3; i>0; i-- ) {
+       for( i = in->bv_len - 3; i > 0; i-- ) {
                if( in->bv_val[i] != '0' && in->bv_val[i] != '1' ) {
                        return LDAP_INVALID_SYNTAX;
                }
@@ -858,14 +857,14 @@ nameUIDValidate(
        int rc;
        struct berval dn, uid;
 
-       if( in->bv_len == 0 ) return LDAP_SUCCESS;
+       if( BER_BVISEMPTY( in ) ) return LDAP_SUCCESS;
 
        ber_dupbv( &dn, in );
        if( !dn.bv_val ) return LDAP_OTHER;
 
        /* if there's a "#", try bitStringValidate()... */
        uid.bv_val = strrchr( dn.bv_val, '#' );
-       if ( uid.bv_val ) {
+       if ( !BER_BVISNULL( &uid ) ) {
                uid.bv_val++;
                uid.bv_len = dn.bv_len - ( uid.bv_val - dn.bv_val );
 
@@ -897,7 +896,7 @@ nameUIDPretty(
 
        Debug( LDAP_DEBUG_TRACE, ">>> nameUIDPretty: <%s>\n", val->bv_val, 0, 0 );
 
-       if( val->bv_len == 0 ) {
+       if( BER_BVISEMPTY( val ) ) {
                ber_dupbv_x( out, val, ctx );
 
        } else if ( val->bv_len > SLAP_LDAPDN_MAXLEN ) {
@@ -909,7 +908,7 @@ nameUIDPretty(
                struct berval   uidval = BER_BVNULL;
 
                uidval.bv_val = strrchr( val->bv_val, '#' );
-               if ( uidval.bv_val ) {
+               if ( !BER_BVISNULL( &uidval ) ) {
                        uidval.bv_val++;
                        uidval.bv_len = val->bv_len - ( uidval.bv_val - val->bv_val );
 
@@ -921,7 +920,7 @@ nameUIDPretty(
                                dnval.bv_val[dnval.bv_len] = '\0';
 
                        } else {
-                               uidval.bv_val = NULL;
+                               BER_BVZERO( &uidval );
                        }
                }
 
@@ -933,7 +932,7 @@ nameUIDPretty(
                        return rc;
                }
 
-               if( uidval.bv_val ) {
+               if( !BER_BVISNULL( &uidval ) ) {
                        int     i, c, got1;
                        char    *tmp;
 
@@ -995,7 +994,7 @@ uniqueMemberNormalize(
                struct berval uid = BER_BVNULL;
 
                uid.bv_val = strrchr( out.bv_val, '#' );
-               if ( uid.bv_val ) {
+               if ( !BER_BVISNULL( &uid ) ) {
                        uid.bv_val++;
                        uid.bv_len = out.bv_len - ( uid.bv_val - out.bv_val );
 
@@ -1004,7 +1003,7 @@ uniqueMemberNormalize(
                                uid.bv_val[-1] = '\0';
                                out.bv_len -= uid.bv_len + 1;
                        } else {
-                               uid.bv_val = NULL;
+                               BER_BVZERO( &uid );
                        }
                }
 
@@ -1015,7 +1014,7 @@ uniqueMemberNormalize(
                        return LDAP_INVALID_SYNTAX;
                }
 
-               if( uid.bv_val ) {
+               if( !BER_BVISNULL( &uid ) ) {
                        char    *tmp;
 
                        tmp = ch_realloc( normalized->bv_val,
@@ -1237,12 +1236,12 @@ UTF8StringValidate(
        int len;
        unsigned char *u = (unsigned char *)in->bv_val;
 
-       if( in->bv_len == 0 && syntax == slap_schema.si_syn_directoryString ) {
+       if( BER_BVISEMPTY( in ) && syntax == slap_schema.si_syn_directoryString ) {
                /* directory strings cannot be empty */
                return LDAP_INVALID_SYNTAX;
        }
 
-       for( count = in->bv_len; count > 0; count-=len, u+=len ) {
+       for( count = in->bv_len; count > 0; count -= len, u += len ) {
                /* get the length indicated by the first byte */
                len = LDAP_UTF8_CHARLEN2( u, len );
 
@@ -1302,12 +1301,11 @@ UTF8StringNormalize(
 
        assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use ));
 
-       if( val->bv_val == NULL ) {
+       if( BER_BVISNULL( val ) ) {
                /* assume we're dealing with a syntax (e.g., UTF8String)
                 * which allows empty strings
                 */
-               normalized->bv_len = 0;
-               normalized->bv_val = NULL;
+               BER_BVZERO( normalized );
                return LDAP_SUCCESS;
        }
 
@@ -1325,8 +1323,8 @@ UTF8StringNormalize(
        nvalue.bv_len = 0;
        nvalue.bv_val = tmp.bv_val;
 
-       wasspace=1; /* trim leading spaces */
-       for( i=0; i<tmp.bv_len; i++) {
+       wasspace = 1; /* trim leading spaces */
+       for( i = 0; i < tmp.bv_len; i++) {
                if ( ASCII_SPACE( tmp.bv_val[i] )) {
                        if( wasspace++ == 0 ) {
                                /* trim repeated spaces */
@@ -1338,7 +1336,7 @@ UTF8StringNormalize(
                }
        }
 
-       if( nvalue.bv_len ) {
+       if( !BER_BVISEMPTY( &nvalue ) ) {
                if( wasspace ) {
                        /* last character was a space, trim it */
                        --nvalue.bv_len;
@@ -1489,11 +1487,11 @@ approxIndexer(
        struct berval *newkeys;
        BerVarray keys=NULL;
 
-       for( j=0; values[j].bv_val != NULL; j++ ) {
+       for( j = 0; !BER_BVISNULL( &values[j] ); j++ ) {
                struct berval val = BER_BVNULL;
                /* Yes, this is necessary */
                UTF8bvnormalize( &values[j], &val, LDAP_UTF8_APPROX, NULL );
-               assert( val.bv_val != NULL );
+               assert( !BER_BVISNULL( &val ) );
 
                /* Isolate how many words there are. There will be a key for each */
                for( wordcount = 0, c = val.bv_val; *c; c++) {
@@ -1522,7 +1520,7 @@ approxIndexer(
 
                ber_memfree( val.bv_val );
        }
-       keys[keycount].bv_val = NULL;
+       BER_BVZERO( &keys[keycount] );
        *keysp = keys;
 
        return LDAP_SUCCESS;
@@ -1547,9 +1545,9 @@ approxFilter(
        /* Yes, this is necessary */
        val = UTF8bvnormalize( ((struct berval *)assertedValue),
                NULL, LDAP_UTF8_APPROX, NULL );
-       if( val == NULL || val->bv_val == NULL ) {
+       if( val == NULL || BER_BVISNULL( val ) ) {
                keys = (struct berval *)ch_malloc( sizeof(struct berval) );
-               keys[0].bv_val = NULL;
+               BER_BVZERO( &keys[0] );
                *keysp = keys;
                ber_bvfree( val );
                return LDAP_SUCCESS;
@@ -1577,7 +1575,7 @@ approxFilter(
 
        ber_bvfree( val );
 
-       keys[count].bv_val = NULL;
+       BER_BVZERO( &keys[count] );
        *keysp = keys;
 
        return LDAP_SUCCESS;
@@ -1598,7 +1596,7 @@ telephoneNumberNormalize(
        assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ));
 
        /* validator should have refused an empty string */
-       assert( val->bv_len );
+       assert( !BER_BVISEMPTY( val ) );
 
        q = normalized->bv_val = slap_sl_malloc( val->bv_len + 1, ctx );
 
@@ -1611,9 +1609,9 @@ telephoneNumberNormalize(
 
        normalized->bv_len = q - normalized->bv_val;
 
-       if( normalized->bv_len == 0 ) {
+       if( BER_BVISEMPTY( normalized ) ) {
                slap_sl_free( normalized->bv_val, ctx );
-               normalized->bv_val = NULL;
+               BER_BVZERO( normalized );
                return LDAP_INVALID_SYNTAX;
        }
 
@@ -1627,7 +1625,7 @@ numericoidValidate(
 {
        struct berval val = *in;
 
-       if( val.bv_len == 0 ) {
+       if( BER_BVISEMPTY( &val ) ) {
                /* disallow empty strings */
                return LDAP_INVALID_SYNTAX;
        }
@@ -1672,13 +1670,13 @@ integerValidate(
        ber_len_t i;
        struct berval val = *in;
 
-       if( val.bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+       if ( BER_BVISEMPTY( &val ) ) return LDAP_INVALID_SYNTAX;
 
        if ( val.bv_val[0] == '-' ) {
                val.bv_len--;
                val.bv_val++;
 
-               if( val.bv_len == 0 ) { /* bare "-" */
+               if( BER_BVISEMPTY( &val ) ) { /* bare "-" */
                        return LDAP_INVALID_SYNTAX;
                }
 
@@ -1724,7 +1722,7 @@ integerMatch(
                v.bv_len--;
        }
 
-       if( v.bv_len == 0 ) vsign = 0;
+       if( BER_BVISEMPTY( &v ) ) vsign = 0;
 
        a = *asserted;
        if( a.bv_val[0] == '-' ) {
@@ -1733,7 +1731,7 @@ integerMatch(
                a.bv_len--;
        }
 
-       if( a.bv_len == 0 ) vsign = 0;
+       if( BER_BVISEMPTY( &a ) ) vsign = 0;
 
        match = vsign - asign;
        if( match == 0 ) {
@@ -1771,7 +1769,7 @@ printableStringValidate(
 {
        ber_len_t i;
 
-       if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;
 
        for(i=0; i < val->bv_len; i++) {
                if( !SLAP_PRINTABLE(val->bv_val[i]) ) {
@@ -1789,7 +1787,7 @@ printablesStringValidate(
 {
        ber_len_t i, len;
 
-       if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;
 
        for(i=0,len=0; i < val->bv_len; i++) {
                int c = val->bv_val[i];
@@ -1821,7 +1819,7 @@ IA5StringValidate(
 {
        ber_len_t i;
 
-       if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;
 
        for(i=0; i < val->bv_len; i++) {
                if( !LDAP_ASCII(val->bv_val[i]) ) {
@@ -1844,7 +1842,7 @@ IA5StringNormalize(
        char *p, *q;
        int casefold = !SLAP_MR_ASSOCIATED(mr, slap_schema.si_mr_caseExactIA5Match);
 
-       assert( val->bv_len );
+       assert( !BER_BVISEMPTY( val ) );
 
        assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use ));
 
@@ -1888,7 +1886,7 @@ IA5StringNormalize(
        *q = '\0';
 
        normalized->bv_len = q - normalized->bv_val;
-       if( normalized->bv_len == 0 ) {
+       if( BER_BVISEMPTY( normalized ) ) {
                normalized->bv_val = slap_sl_realloc( normalized->bv_val, 2, ctx );
                normalized->bv_val[0] = ' ';
                normalized->bv_val[1] = '\0';
@@ -1984,7 +1982,7 @@ numericStringValidate(
 {
        ber_len_t i;
 
-       if( in->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISEMPTY( in ) ) return LDAP_INVALID_SYNTAX;
 
        for(i=0; i < in->bv_len; i++) {
                if( !SLAP_NUMERIC(in->bv_val[i]) ) {
@@ -2007,7 +2005,7 @@ numericStringNormalize(
        /* removal all spaces */
        char *p, *q;
 
-       assert( val->bv_len );
+       assert( !BER_BVISEMPTY( val ) );
 
        normalized->bv_val = slap_sl_malloc( val->bv_len + 1, ctx );
 
@@ -2031,7 +2029,7 @@ numericStringNormalize(
 
        normalized->bv_len = q - normalized->bv_val;
 
-       if( normalized->bv_len == 0 ) {
+       if( BER_BVISEMPTY( normalized ) ) {
                normalized->bv_val = slap_sl_realloc( normalized->bv_val, 2, ctx );
                normalized->bv_val[0] = ' ';
                normalized->bv_val[1] = '\0';
@@ -2132,7 +2130,7 @@ serialNumberAndIssuerValidate(
        if( in->bv_len < 3 ) return LDAP_INVALID_SYNTAX;
 
        i.bv_val = strchr( in->bv_val, '$' );
-       if( i.bv_val == NULL ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISNULL( &i ) ) return LDAP_INVALID_SYNTAX;
 
        sn.bv_val = in->bv_val;
        sn.bv_len = i.bv_val - in->bv_val;
@@ -2173,7 +2171,7 @@ serialNumberAndIssuerPretty(
        if( val->bv_len < 3 ) return LDAP_INVALID_SYNTAX;
 
        i.bv_val = strchr( val->bv_val, '$' );
-       if( i.bv_val == NULL ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISNULL( &i ) ) return LDAP_INVALID_SYNTAX;
 
        sn.bv_val = val->bv_val;
        sn.bv_len = i.bv_val - val->bv_val;
@@ -2200,7 +2198,7 @@ serialNumberAndIssuerPretty(
        out->bv_len = sn.bv_len + newi.bv_len + 1;
        out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx );
 
-       if( out->bv_val == NULL ) {
+       if( BER_BVISNULL( out ) ) {
                slap_sl_free( newi.bv_val, ctx );
                return LDAP_OTHER;
        }
@@ -2248,7 +2246,7 @@ serialNumberAndIssuerNormalize(
        if( val->bv_len < 3 ) return LDAP_INVALID_SYNTAX;
 
        i.bv_val = strchr( val->bv_val, '$' );
-       if( i.bv_val == NULL ) return LDAP_INVALID_SYNTAX;
+       if( BER_BVISNULL( &i ) ) return LDAP_INVALID_SYNTAX;
 
        sn.bv_val = val->bv_val;
        sn.bv_len = i.bv_val - val->bv_val;
@@ -2277,7 +2275,7 @@ serialNumberAndIssuerNormalize(
        out->bv_len = sn.bv_len + newi.bv_len + 1;
        out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx );
 
-       if( out->bv_val == NULL ) {
+       if( BER_BVISNULL( out ) ) {
                slap_sl_free( newi.bv_val, ctx );
                return LDAP_OTHER;
        }
@@ -2315,7 +2313,7 @@ certificateExactNormalize(
        ASN1_INTEGER *sn = NULL;
        X509 *xcert = NULL;
 
-       if( val->bv_len == 0 ) goto done;
+       if( BER_BVISEMPTY( val ) ) goto done;
 
        if( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX(usage) ) {
                return serialNumberAndIssuerNormalize(0,NULL,NULL,val,normalized,ctx);
@@ -2612,14 +2610,14 @@ generalizedTimeNormalize(
 
        len = sizeof("YYYYmmddHHMMSSZ")-1 + fraction.bv_len;
        normalized->bv_val = slap_sl_malloc( len + 1, ctx );
-       if ( normalized->bv_val == NULL ) {
+       if ( BER_BVISNULL( normalized ) ) {
                return LBER_ERROR_MEMORY;
        }
 
        sprintf( normalized->bv_val, "%02d%02d%02d%02d%02d%02d%02d",
                parts[0], parts[1], parts[2] + 1, parts[3] + 1,
                parts[4], parts[5], parts[6] );
-       if ( fraction.bv_len ) {
+       if ( !BER_BVISEMPTY( &fraction ) ) {
                memcpy( normalized->bv_val + sizeof("YYYYmmddHHMMSSZ")-2,
                        fraction.bv_val, fraction.bv_len );
                normalized->bv_val[sizeof("YYYYmmddHHMMSSZ")-2] = '.';
@@ -2870,19 +2868,19 @@ again:
                return LDAP_INVALID_SYNTAX;
        }
 
-       if( tmp.bv_len == 0 ) return LDAP_SUCCESS;
+       if( BER_BVISEMPTY( &tmp ) ) return LDAP_SUCCESS;
 
-       while( tmp.bv_len && ( tmp.bv_val[0] == ' ' )) {
+       while( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == ' ' ) ) {
                tmp.bv_len++;
                tmp.bv_val--;
        }
-       if( tmp.bv_len && ( tmp.bv_val[0] == '$' )) {
+       if( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == '$' ) ) {
                tmp.bv_len++;
                tmp.bv_val--;
        } else {
                return LDAP_INVALID_SYNTAX;
        }
-       while( tmp.bv_len && ( tmp.bv_val[0] == ' ' )) {
+       while( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == ' ' ) ) {
                tmp.bv_len++;
                tmp.bv_val--;
        }
@@ -2898,7 +2896,7 @@ nisNetgroupTripleValidate(
        char *p, *e;
        int commas = 0;
 
-       if ( val->bv_len == 0 ) {
+       if ( BER_BVISEMPTY( val ) ) {
                return LDAP_INVALID_SYNTAX;
        }
 
@@ -2941,7 +2939,7 @@ bootParameterValidate(
 {
        char *p, *e;
 
-       if ( val->bv_len == 0 ) {
+       if ( BER_BVISEMPTY( val ) ) {
                return LDAP_INVALID_SYNTAX;
        }
 
@@ -3017,7 +3015,7 @@ firstComponentNormalize(
        /* grab next word */
        comp.bv_val = &val->bv_val[len];
        len = val->bv_len - len;
-       for( comp.bv_len=0;
+       for( comp.bv_len = 0;
                !ASCII_SPACE(comp.bv_val[comp.bv_len]) && comp.bv_len < len;
                comp.bv_len++ )
        {
index 948e8d1486f80a3324610226f2ec4abe50cad22f..fbf322efbb0513d48b0c15befeb24b7377d93e93 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -370,13 +370,17 @@ static struct slap_schema_oc_map {
                        "matchingRuleUse ) )",
                subentryObjectClass, SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_subschema) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentry", "( 2.5.17.2 "
                        "NAME 'collectiveAttributeSubentry' "
+                       "DESC 'RFC3671: collective attribute subentry' "
                        "AUXILIARY )",
                subentryObjectClass,
                SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
-               offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
+               offsetof( struct slap_internal_schema,
+                       si_oc_collectiveAttributeSubentry) },
+#endif
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
                        "NAME 'dynamicObject' "
                        "DESC 'RFC2589: Dynamic Object' "
@@ -506,9 +510,10 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentries", "( 2.5.18.12 "
                        "NAME 'collectiveAttributeSubentries' "
+                       "DESC 'RFC3671: collective attribute subentries' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "NO-USER-MODIFICATION USAGE directoryOperation )",
@@ -517,6 +522,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
        { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
+                       "DESC 'RFC3671: collective attribute exclusions' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "USAGE directoryOperation )",
@@ -566,7 +572,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_namingCSN) },
 
-#if 0
+#ifdef LDAP_SUPERIOR_UUID
        { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
                        "DESC 'UUID of the superior entry' "
                        "EQUALITY octetStringMatch "
@@ -602,7 +608,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_contextCSN) },
 
-#ifdef LDAP_DEVEL
+#ifdef LDAP_SYNC_TIMESTAMP
        { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
                        "DESC 'Time which object was replicated' "
                        "EQUALITY generalizedTimeMatch "
@@ -862,7 +868,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_aci) },
 #endif
 
-#ifdef LDAP_DEVEL
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
                        "DESC 'RFC2589: entry time-to-live' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
index 630d7c3289ff541de33d4082f1e919a83c392417..a1c6f34f12cf2caee2f5e89334f0fca096568cfd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index ce7cbef7cd4140eca7ec04bd7306b75e85b4f82e..283fb6dfcf4bd8e67eb30dff64d8468db4b639e6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -223,14 +223,6 @@ do_search(
        rs->sr_err = frontendDB->be_search( op, rs );
 
 return_results:;
-#if 0  /* DELETE ME */
-       if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) ) {
-               return rs->sr_err;
-       }
-       if ( ( op->o_sync_slog_size != -1 ) ) {
-               return rs->sr_err;
-       }
-#endif
        if ( !BER_BVISNULL( &op->o_req_dn ) ) {
                slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
        }
@@ -352,21 +344,7 @@ fe_op_search( Operation *op, SlapReply *rs )
         * if we don't hold it.
         */
 
-#if 0  /* DELETE ME */
-       /* Sync control overrides manageDSAit */
-
-       if ( manageDSAit != SLAP_CONTROL_NONE ) {
-               if ( op->o_sync_mode & SLAP_SYNC_REFRESH ) {
-                       be_manageDSAit = SLAP_CONTROL_NONE;
-               } else {
-                       be_manageDSAit = manageDSAit;
-               }
-       } else {
-               be_manageDSAit = manageDSAit;
-       }
-#else
-               be_manageDSAit = manageDSAit;
-#endif
+       be_manageDSAit = manageDSAit;
 
        op->o_bd = select_backend( &op->o_req_ndn, be_manageDSAit, 1 );
        if ( op->o_bd == NULL ) {
diff --git a/servers/slapd/sessionlog.c b/servers/slapd/sessionlog.c
deleted file mode 100644 (file)
index 3d21368..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* sessionlog.c -- Session History Management Routines */
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 2003-2004 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/socket.h>
-
-#include "lutil.h"
-#include "slap.h"
-#include "lutil_ldap.h"
-
-#if 0  /* DELETE ME -- needs to be reimplemented with syncprov overlay */
-int
-slap_send_session_log(
-       Operation *op,
-       Operation *sop,
-       SlapReply *rs
-)
-{
-       Entry e;
-       AttributeName   uuid_attr[2];
-       LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
-       int             num_ctrls = 0;
-       struct slog_entry *slog_e;
-       int             result;
-       int             match;
-       const   char    *text;
-
-       uuid_attr[0].an_desc = NULL;
-       uuid_attr[0].an_oc = NULL;
-       uuid_attr[0].an_oc_exclude = 0;
-       uuid_attr[0].an_name.bv_len = 0;
-       uuid_attr[0].an_name.bv_val = NULL;
-       e.e_attrs = NULL;
-       e.e_id = 0;
-       e.e_name.bv_val = NULL;
-       e.e_name.bv_len = 0;
-       e.e_nname.bv_val = NULL;
-       e.e_nname.bv_len = 0;
-
-       for( num_ctrls = 0;
-                num_ctrls < SLAP_MAX_RESPONSE_CONTROLS;
-                num_ctrls++ ) {
-               ctrls[num_ctrls] = NULL;
-       }
-       num_ctrls = 0;
-
-       LDAP_STAILQ_FOREACH( slog_e, &sop->o_sync_slog_list, sl_link ) {
-
-               if ( op->o_sync_state.ctxcsn->bv_val == NULL ) {
-                       match = 1;
-               } else {
-                       value_match( &match, slap_schema.si_ad_entryCSN,
-                                               slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
-                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                               op->o_sync_state.ctxcsn, &slog_e->sl_csn, &text );
-               }
-
-               if ( match < 0 ) {
-                       rs->sr_err = slap_build_sync_state_ctrl_from_slog( op, rs, slog_e,
-                                                       LDAP_SYNC_DELETE, ctrls, num_ctrls++, 0, NULL );
-
-                       if ( rs->sr_err != LDAP_SUCCESS )
-                               return rs->sr_err;
-
-                       if ( e.e_name.bv_val )
-                               ch_free( e.e_name.bv_val );
-                       ber_dupbv( &e.e_name, &slog_e->sl_name );
-
-                       rs->sr_entry = &e;
-                       rs->sr_attrs = uuid_attr;
-                       rs->sr_ctrls = ctrls;
-                       rs->sr_flags = 0;
-                       result = send_search_entry( op, rs );
-                       slap_sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, op->o_tmpmemctx );
-                       slap_sl_free( ctrls[--num_ctrls], op->o_tmpmemctx );
-                       ctrls[num_ctrls] = NULL;
-                       rs->sr_ctrls = NULL;
-               }
-       }
-       return LDAP_SUCCESS;
-}
-
-int
-slap_add_session_log(
-       Operation *op,
-       Operation *sop,
-       Entry *e
-)
-{
-       struct slog_entry* slog_e;
-       Attribute *a;
-
-       slog_e = (struct slog_entry *) ch_calloc (1, sizeof( struct slog_entry ));
-       a = attr_find( e->e_attrs, slap_schema.si_ad_entryUUID );
-       ber_dupbv( &slog_e->sl_uuid, &a->a_nvals[0] );
-       ber_dupbv( &slog_e->sl_name, &e->e_name );
-       ber_dupbv( &slog_e->sl_csn,  &op->o_sync_csn );
-       LDAP_STAILQ_INSERT_TAIL( &sop->o_sync_slog_list, slog_e, sl_link );
-       sop->o_sync_slog_len++;
-
-       while ( sop->o_sync_slog_len > sop->o_sync_slog_size ) {
-               slog_e = LDAP_STAILQ_FIRST( &sop->o_sync_slog_list );
-               if ( sop->o_sync_slog_omitcsn.bv_val ) {
-                       ch_free( sop->o_sync_slog_omitcsn.bv_val );
-               }
-               ber_dupbv( &sop->o_sync_slog_omitcsn, &slog_e->sl_csn );
-               LDAP_STAILQ_REMOVE_HEAD( &sop->o_sync_slog_list, sl_link );
-               ch_free( slog_e->sl_uuid.bv_val );
-               ch_free( slog_e->sl_name.bv_val );
-               ch_free( slog_e->sl_csn.bv_val );
-               ch_free( slog_e );
-               sop->o_sync_slog_len--;
-       }
-
-       return LDAP_SUCCESS;
-}
-#endif
index 4d55924bcd0c5798dc3b5b262630fb355d127084..9a626947b30d43f778f662217feca4c942af5371 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -116,13 +116,15 @@ slap_set_join(
 
        set = NULL;
        switch ( op ) {
-       case '|':
+       case '|':       /* union */
                if ( lset == NULL || BER_BVISNULL( lset ) ) {
                        if ( rset == NULL ) {
                                if ( lset == NULL ) {
-                                       return cp->op->o_tmpcalloc( 1,
+                                       set = cp->op->o_tmpcalloc( 1,
                                                        sizeof(struct berval),
                                                        cp->op->o_tmpmemctx );
+                                       BER_BVZERO( set );
+                                       return set;
                                }
                                return set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
                        }
@@ -151,10 +153,13 @@ slap_set_join(
                                }
                        }
 
+                       last = i;
+
                        for ( i = 0; !BER_BVISNULL( &rset[ i ] ); i++ ) {
                                int     exists = 0;
+
                                for ( j = 0; !BER_BVISNULL( &set[ j ] ); j++ ) {
-                                       if ( dn_match( &rset[ i ], &set[ j ] ) )
+                                       if ( bvmatch( &rset[ i ], &set[ j ] ) )
                                        {
                                                if ( !( op_flags & SLAP_SET_RREFVAL ) ) {
                                                        cp->op->o_tmpfree( rset[ i ].bv_val, cp->op->o_tmpmemctx );
@@ -167,22 +172,25 @@ slap_set_join(
 
                                if ( !exists ) {
                                        if ( op_flags & SLAP_SET_RREFVAL ) {
-                                               ber_dupbv_x( &set[ j ], &rset[ i ], cp->op->o_tmpmemctx );
+                                               ber_dupbv_x( &set[ last ], &rset[ i ], cp->op->o_tmpmemctx );
 
                                        } else {
-                                               set[ j ] = rset[ i ];
+                                               set[ last ] = rset[ i ];
                                        }
+                                       last++;
                                }
                        }
+                       BER_BVZERO( &set[ last ] );
                }
                break;
 
-       case '&':
+       case '&':       /* intersection */
                if ( lset == NULL || BER_BVISNULL( lset )
                                || rset == NULL || BER_BVISNULL( rset ) )
                {
                        set = cp->op->o_tmpcalloc( 1, sizeof(struct berval),
                                        cp->op->o_tmpmemctx );
+                       BER_BVZERO( set );
 
                } else {
                        set = set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
@@ -193,7 +201,7 @@ slap_set_join(
                        last = slap_set_size( set ) - 1;
                        for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ ) {
                                for ( j = 0; !BER_BVISNULL( &rset[ j ] ); j++ ) {
-                                       if ( dn_match( &set[ i ], &rset[ j ] ) ) {
+                                       if ( bvmatch( &set[ i ], &rset[ j ] ) ) {
                                                break;
                                        }
                                }
@@ -209,10 +217,53 @@ slap_set_join(
                }
                break;
 
+       case '+':       /* string concatenation */
+               i = slap_set_size( rset );
+               j = slap_set_size( lset );
+
+               set = cp->op->o_tmpcalloc( i * j + 1, sizeof(struct berval),
+                               cp->op->o_tmpmemctx );
+               if ( set == NULL ) {
+                       break;
+               }
+
+               for ( last = 0, i = 0; !BER_BVISNULL( &lset[ i ] ); i++ ) {
+                       for ( j = 0; !BER_BVISNULL( &rset[ j ] ); j++ ) {
+                               struct berval   bv;
+                               long            k;
+
+                               bv.bv_len = lset[ i ].bv_len + rset[ j ].bv_len;
+                               bv.bv_val = cp->op->o_tmpalloc( bv.bv_len + 1,
+                                               cp->op->o_tmpmemctx );
+                               if ( bv.bv_val == NULL ) {
+                                       slap_set_dispose( cp, set, 0 );
+                                       set = NULL;
+                                       goto done;
+                               }
+                               AC_MEMCPY( bv.bv_val, lset[ i ].bv_val, lset[ i ].bv_len );
+                               AC_MEMCPY( &bv.bv_val[ lset[ i ].bv_len ], rset[ j ].bv_val, rset[ j ].bv_len );
+                               bv.bv_val[ bv.bv_len ] = '\0';
+
+                               for ( k = 0; k < last; k++ ) {
+                                       if ( bvmatch( &set[ k ], &bv ) ) {
+                                               cp->op->o_tmpfree( bv.bv_val, cp->op->o_tmpmemctx );
+                                               break;
+                                       }
+                               }
+
+                               if ( k == last ) {
+                                       set[ last++ ] = bv;
+                               }
+                       }
+               }
+               BER_BVZERO( &set[ last ] );
+               break;
+
        default:
                break;
        }
 
+done:;
        if ( !( op_flags & SLAP_SET_LREFARR ) && lset != NULL ) {
                cp->op->o_tmpfree( lset, cp->op->o_tmpmemctx );
        }
@@ -231,12 +282,16 @@ set_chase( SLAP_SET_GATHER gatherer,
        BerVarray       vals, nset;
        int             i;
 
-       if ( set == NULL )
-               return cp->op->o_tmpcalloc( 1, sizeof(struct berval),
+       if ( set == NULL ) {
+               set = cp->op->o_tmpcalloc( 1, sizeof(struct berval),
                                cp->op->o_tmpmemctx );
+               BER_BVZERO( set );
+               return set;
+       }
 
-       if ( BER_BVISNULL( set ) )
+       if ( BER_BVISNULL( set ) ) {
                return set;
+       }
 
        nset = cp->op->o_tmpcalloc( 1, sizeof(struct berval), cp->op->o_tmpmemctx );
        if ( nset == NULL ) {
@@ -271,18 +326,19 @@ slap_set_filter( SLAP_SET_GATHER gatherer,
        SetCookie *cp, struct berval *fbv,
        struct berval *user, struct berval *target, BerVarray *results )
 {
+#define STACK_SIZE     64
 #define IS_SET(x)      ( (unsigned long)(x) >= 256 )
 #define IS_OP(x)       ( (unsigned long)(x) < 256 )
 #define SF_ERROR(x)    do { rc = -1; goto _error; } while (0)
 #define SF_TOP()       ( (BerVarray)( (stp < 0) ? 0 : stack[ stp ] ) )
 #define SF_POP()       ( (BerVarray)( (stp < 0) ? 0 : stack[ stp-- ] ) )
 #define SF_PUSH(x)     do { \
-               if (stp >= 63) SF_ERROR(overflow); \
+               if (stp >= (STACK_SIZE - 1)) SF_ERROR(overflow); \
                stack[ ++stp ] = (BerVarray)(long)(x); \
        } while (0)
 
        BerVarray       set, lset;
-       BerVarray       stack[64] = { 0 };
+       BerVarray       stack[ STACK_SIZE ] = { 0 };
        int             len, rc, stp;
        unsigned        op;
        char            c, *filter = fbv->bv_val;
@@ -334,8 +390,9 @@ slap_set_filter( SLAP_SET_GATHER gatherer,
                        }
                        break;
 
-               case '&':
-               case '|':
+               case '|':       /* union */
+               case '&':       /* intersection */
+               case '+':       /* string concatenation */
                        set = SF_POP();
                        if ( IS_OP( set ) ) {
                                SF_ERROR( syntax );
@@ -430,6 +487,7 @@ slap_set_filter( SLAP_SET_GATHER gatherer,
                                if ( BER_BVISNULL( set ) ) {
                                        SF_ERROR( memory );
                                }
+                               BER_BVZERO( &set[ 1 ] );
                                
                        } else if ( len == 4
                                && memcmp( "user", filter, len ) == 0 ) 
@@ -446,6 +504,7 @@ slap_set_filter( SLAP_SET_GATHER gatherer,
                                if ( BER_BVISNULL( set ) ) {
                                        SF_ERROR( memory );
                                }
+                               BER_BVZERO( &set[ 1 ] );
                                
                        } else if ( SF_TOP() != (void *)'/' ) {
                                SF_ERROR( syntax );
index bc5ea7155d6d15ecd0b1fff8685acf8ad9a3d126..af5d809dc7e7e925e775a32f51879b42fb6ec75e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 3ef7132d9c998c992c98c7e911bfb8fe481c511e..f8d2760ac4a7d3afa2f00bb11a11df3d91792ceb 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f3d68a7770fc53ed34d0d7f935db52da9915d057..3240efd2b93a4c3d01bcabf65567109238facadd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7926aacf67ce794651d7feb67e382797e446660e..2731b52b8676a3b55814d68e8b5c4de10c6ed99a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4f9da62640b1dc82e25fb150f4e60c0795d64fc4..754edf4c7d4dc17de73d8e09f30219db862d1281 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 9abc8653c12d904a451ad6c123b420d869838a51..79317158174d4e5ccdccc9c6049ad9d514564376 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -300,7 +300,7 @@ slap_sl_malloc(
                                }
                                so_right = LDAP_LIST_FIRST(&sh->sh_sopool);
                                LDAP_LIST_REMOVE(so_right, so_link);
-                               so_right->so_ptr = so_left->so_ptr + (1 << j);
+                               so_right->so_ptr = (void *)((char *)so_left->so_ptr + (1 << j));
                                if (j == order + 1) {
                                        ptr = so_left->so_ptr;
                                        diff = (unsigned long)((char*)ptr -
@@ -326,6 +326,9 @@ slap_sl_malloc(
                        return (void*)ch_malloc(size);
                }
        }
+
+       /* FIXME: missing return; guessing... */
+       return NULL;
 }
 
 void *
@@ -495,7 +498,7 @@ slap_sl_free(void *ptr, void *ctx)
                                        while (so) {
                                                if ((char*)so->so_ptr == (char*)tmpp) {
                                                        LDAP_LIST_REMOVE(so, so_link);
-                                               } else if ((char*)tmpp == so->so_ptr + order_size) {
+                                               } else if ((char*)tmpp == (char *)so->so_ptr + order_size) {
                                                        LDAP_LIST_REMOVE(so, so_link);
                                                        tmpp = so->so_ptr;
                                                        break;
@@ -549,6 +552,8 @@ slap_sl_context( void *ptr )
        struct slab_heap *sh = NULL;
        void *ctx;
 
+       if ( slapMode & SLAP_TOOL_MODE ) return NULL;
+
 #ifdef NO_THREADS
        sh = slheap;
 #else
index cefcf7e2fc49eb44ae24c77f3e1e5470c610a1a6..5cc6f3274ad3497936d451c5e6f22539d40e6b32 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 LDAP_BEGIN_DECL
 
+#ifdef LDAP_DEVEL
+#define SLAP_ACL_HONOR_DISCLOSE        /* partially implemented */
+#define SLAP_DYNACL
+#define LDAP_COMP_MATCH                        /* experimental */
+#define LDAP_DYNAMIC_OBJECTS
+#define LDAP_SYNC_TIMESTAMP
+#define LDAP_COLLECTIVE_ATTRIBUTES
+#define SLAP_CONTROL_X_TREE_DELETE LDAP_CONTROL_X_TREE_DELETE
+#endif
+
+#if defined(LDAP_DEVEL) && defined(ENABLE_REWRITE)
+/* use librewrite for sasl-regexp */
+#define SLAP_AUTH_REWRITE      1
+#endif /* LDAP_DEVEL && ENABLE_REWRITE */
+
 /*
  * SLAPD Memory allocation macros
  *
@@ -324,10 +339,6 @@ typedef int slap_syntax_transform_func LDAP_P((
        struct berval * out,
        void *memctx));
 
-#ifdef LDAP_DEVEL
-#define LDAP_COMP_MATCH
-#endif
-
 #ifdef LDAP_COMP_MATCH
 typedef void* slap_component_transform_func LDAP_P((
        struct berval * in ));
@@ -1123,11 +1134,13 @@ typedef struct slap_ldap_modlist {
 typedef enum slap_access_e {
        ACL_INVALID_ACCESS = -1,
        ACL_NONE = 0,
+       ACL_DISCLOSE,
        ACL_AUTH,
        ACL_COMPARE,
        ACL_SEARCH,
        ACL_READ,
-       ACL_WRITE
+       ACL_WRITE,
+       ACL_MANAGE
 } slap_access_t;
 
 typedef enum slap_control_e {
@@ -1166,10 +1179,6 @@ typedef struct slap_authz_info {
 } AuthorizationInformation;
 
 
-#ifdef LDAP_DEVEL
-#define SLAP_DYNACL
-#endif /* LDAP_DEVEL */
-
 #ifdef SLAP_DYNACL
 struct slap_op;
 
@@ -1209,11 +1218,13 @@ typedef struct slap_access {
 #define ACL_ACCESS2PRIV(access)        (0x01U << (access))
 
 #define ACL_PRIV_NONE                  ACL_ACCESS2PRIV( ACL_NONE )
+#define ACL_PRIV_DISCLOSE              ACL_ACCESS2PRIV( ACL_DISCLOSE )
 #define ACL_PRIV_AUTH                  ACL_ACCESS2PRIV( ACL_AUTH )
 #define ACL_PRIV_COMPARE               ACL_ACCESS2PRIV( ACL_COMPARE )
 #define ACL_PRIV_SEARCH                        ACL_ACCESS2PRIV( ACL_SEARCH )
 #define ACL_PRIV_READ                  ACL_ACCESS2PRIV( ACL_READ )
 #define ACL_PRIV_WRITE                 ACL_ACCESS2PRIV( ACL_WRITE )
+#define ACL_PRIV_MANAGE                        ACL_ACCESS2PRIV( ACL_MANAGE )
 
 #define ACL_PRIV_MASK                  0x00ffUL
 
@@ -1242,26 +1253,32 @@ typedef struct slap_access {
 #define ACL_IS_SUBTRACTIVE(m)  ACL_PRIV_ISSET((m),ACL_PRIV_SUBSTRACTIVE)
 
 #define ACL_LVL_NONE                   (ACL_PRIV_NONE|ACL_PRIV_LEVEL)
-#define ACL_LVL_AUTH                   (ACL_PRIV_AUTH|ACL_LVL_NONE)
+#define ACL_LVL_DISCLOSE               (ACL_PRIV_DISCLOSE|ACL_LVL_NONE)
+#define ACL_LVL_AUTH                   (ACL_PRIV_AUTH|ACL_LVL_DISCLOSE)
 #define ACL_LVL_COMPARE                        (ACL_PRIV_COMPARE|ACL_LVL_AUTH)
 #define ACL_LVL_SEARCH                 (ACL_PRIV_SEARCH|ACL_LVL_COMPARE)
 #define ACL_LVL_READ                   (ACL_PRIV_READ|ACL_LVL_SEARCH)
 #define ACL_LVL_WRITE                  (ACL_PRIV_WRITE|ACL_LVL_READ)
+#define ACL_LVL_MANAGE                 (ACL_PRIV_MANAGE|ACL_LVL_WRITE)
 
 #define ACL_LVL(m,l)                   (((m)&ACL_PRIV_MASK) == ((l)&ACL_PRIV_MASK))
 #define ACL_LVL_IS_NONE(m)             ACL_LVL((m),ACL_LVL_NONE)
+#define ACL_LVL_IS_DISCLOSE(m) ACL_LVL((m),ACL_LVL_DISCLOSE)
 #define ACL_LVL_IS_AUTH(m)             ACL_LVL((m),ACL_LVL_AUTH)
 #define ACL_LVL_IS_COMPARE(m)  ACL_LVL((m),ACL_LVL_COMPARE)
 #define ACL_LVL_IS_SEARCH(m)   ACL_LVL((m),ACL_LVL_SEARCH)
 #define ACL_LVL_IS_READ(m)             ACL_LVL((m),ACL_LVL_READ)
 #define ACL_LVL_IS_WRITE(m)            ACL_LVL((m),ACL_LVL_WRITE)
+#define ACL_LVL_IS_MANAGE(m)   ACL_LVL((m),ACL_LVL_MANAGE)
 
 #define ACL_LVL_ASSIGN_NONE(m)         ACL_PRIV_ASSIGN((m),ACL_LVL_NONE)
+#define ACL_LVL_ASSIGN_DISCLOSE(m)     ACL_PRIV_ASSIGN((m),ACL_LVL_DISCLOSE)
 #define ACL_LVL_ASSIGN_AUTH(m)         ACL_PRIV_ASSIGN((m),ACL_LVL_AUTH)
 #define ACL_LVL_ASSIGN_COMPARE(m)      ACL_PRIV_ASSIGN((m),ACL_LVL_COMPARE)
 #define ACL_LVL_ASSIGN_SEARCH(m)       ACL_PRIV_ASSIGN((m),ACL_LVL_SEARCH)
 #define ACL_LVL_ASSIGN_READ(m)         ACL_PRIV_ASSIGN((m),ACL_LVL_READ)
 #define ACL_LVL_ASSIGN_WRITE(m)                ACL_PRIV_ASSIGN((m),ACL_LVL_WRITE)
+#define ACL_LVL_ASSIGN_MANAGE(m)       ACL_PRIV_ASSIGN((m),ACL_LVL_MANAGE)
 
        slap_mask_t     a_access_mask;
 
@@ -1447,6 +1464,8 @@ typedef BackendDB Backend;
 #define SLAP_SYNC_RID_SIZE     3
 #define SLAP_SYNCUUID_SET_SIZE 256
 
+#define        SLAP_SYNC_UPDATE_MSGID  2
+
 struct nonpresent_entry {
        struct berval *npe_name;
        struct berval *npe_nname;
@@ -1454,9 +1473,8 @@ struct nonpresent_entry {
 };
 
 struct sync_cookie {
-       struct berval *ctxcsn;
-       long sid;
-       struct berval *octet_str;
+       struct berval ctxcsn;
+       struct berval octet_str;
        long rid;
        LDAP_STAILQ_ENTRY(sync_cookie) sc_next;
 };
@@ -1466,13 +1484,11 @@ LDAP_STAILQ_HEAD( slap_sync_cookie_s, sync_cookie );
 typedef struct syncinfo_s {
         struct slap_backend_db *si_be;
         long                           si_rid;
-        char                           *si_provideruri;
-        BerVarray                      si_provideruri_bv;
+        struct berval                  si_provideruri;
 #define SYNCINFO_TLS_OFF               0
 #define SYNCINFO_TLS_ON                        1
 #define SYNCINFO_TLS_CRITICAL  2
         int                                    si_tls;
-               struct berval           si_updatedn;    
         int                                    si_bindmethod;
         char                           *si_binddn;
         char                           *si_passwd;
@@ -1506,7 +1522,6 @@ typedef struct syncinfo_s {
         Avlnode                                *si_presentlist;
                LDAP                            *si_ld;
                LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
-               LDAP_STAILQ_ENTRY( syncinfo_s ) si_next;
 } syncinfo_t;
 
 LDAP_TAILQ_HEAD( be_pcl, slap_csn_entry );
@@ -1670,7 +1685,7 @@ struct slap_backend_db {
        struct          be_pcl  *be_pending_csn_list;
        ldap_pvt_thread_mutex_t                                 be_pcl_mutex;
        ldap_pvt_thread_mutex_t                                 *be_pcl_mutexp;
-       LDAP_STAILQ_HEAD( be_si, syncinfo_s )   be_syncinfo; /* For syncrepl */
+       syncinfo_t                                                              *be_syncinfo; /* For syncrepl */
 
        char    *be_realm;
        void    *be_pb;         /* Netscape plugin */
@@ -2059,35 +2074,6 @@ typedef struct slap_paged_state {
        int ps_count;
 } PagedResultsState;
 
-#define LDAP_PSEARCH_BY_ADD                    0x01
-#define LDAP_PSEARCH_BY_DELETE         0x02
-#define LDAP_PSEARCH_BY_PREMODIFY      0x03
-#define LDAP_PSEARCH_BY_MODIFY         0x04
-#define LDAP_PSEARCH_BY_SCOPEOUT       0x05
-#define LDAP_PSEARCH_BY_PREDELETE      0x06
-
-struct psid_entry {            /* DELETE ME */
-       struct slap_op *ps_op;
-       LDAP_LIST_ENTRY(psid_entry) ps_link;
-};
-
-#if 0  /* DELETE ME */
-struct slog_entry {
-       struct berval sl_uuid;
-       struct berval sl_name;
-       struct berval sl_csn;
-       LDAP_STAILQ_ENTRY(slog_entry) sl_link;
-};
-
-/* session lists */
-struct slap_session_entry {
-       int se_id;
-       int se_size;
-       struct berval se_spec;
-       LDAP_LIST_ENTRY( slap_session_entry ) se_link;
-};
-#endif
-
 struct slap_csn_entry {
        struct berval ce_csn;
        unsigned long ce_opid;
@@ -2098,16 +2084,6 @@ struct slap_csn_entry {
        LDAP_TAILQ_ENTRY (slap_csn_entry) ce_csn_link;
 };
 
-struct pc_entry {
-       ID pc_id;
-       int pc_sent;
-       struct berval pc_csn;
-       struct berval pc_entryUUID;
-       struct berval pc_ename;
-       struct berval pc_enname;
-       LDAP_TAILQ_ENTRY( pc_entry ) pc_link;
-};
-
 /*
  * Caches the result of a backend_group check for ACL evaluation
  */
@@ -2344,29 +2320,6 @@ typedef struct slap_op {
 
 #define get_pagedresults(op)                   ((int)(op)->o_pagedresults)
 
-#ifdef BDB_PSEARCH
-       struct sync_cookie      o_sync_state;
-       int                                     o_sync_rhint;
-       struct berval           o_sync_cid;
-       int                                     o_sync_slog_size;
-       struct berval           o_sync_csn;
-       struct berval           o_sync_slog_omitcsn;
-       int                                     o_sync_slog_len;
-       LDAP_STAILQ_HEAD(sl, slog_entry) o_sync_slog_list;
-
-       int o_ps_entries;
-       int     o_no_psearch;
-       LDAP_LIST_ENTRY(slap_op) o_ps_link;
-       LDAP_LIST_HEAD(pe, psid_entry) o_pm_list;
-
-       int o_refresh_in_progress;
-       LDAP_TAILQ_HEAD(pc_pre, pc_entry) o_ps_pre_candidates;
-       LDAP_TAILQ_HEAD(pc_post, pc_entry) o_ps_post_candidates;
-       Avlnode *o_psearch_finished;
-       struct pc_entry *o_ps_send_wait;
-       ldap_pvt_thread_mutex_t o_pcmutex;
-#endif
-
        AuthorizationInformation o_authz;
 
        BerElement      *o_ber;         /* ber of the request */
@@ -2635,11 +2588,6 @@ typedef int (SLAP_CTRL_PARSE_FN) LDAP_P((
 #define SLAP_ZONE_ALLOC 1
 #undef SLAP_ZONE_ALLOC
 
-#if defined(LDAP_DEVEL) && defined(ENABLE_REWRITE)
-/* use librewrite for sasl-regexp */
-#define SLAP_AUTH_REWRITE      1
-#endif /* LDAP_DEVEL && ENABLE_REWRITE */
-
 #ifdef LDAP_COMP_MATCH
 /*
  * Extensible Filter Definition
index 6e8e5e3653dfb3f1c8f7682d996cda911aab7067..b890826b58b38bb5eaa36838d6328235ec0a8366 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -109,7 +109,8 @@ slapacl( int argc, char **argv )
                slap_mask_t             mask;
                AttributeDescription    *desc = NULL;
                int                     rc;
-               struct berval           val;
+               struct berval           val = BER_BVNULL,
+                                       *valp = NULL;
                const char              *text;
                char                    accessmaskbuf[ACCESSMASK_MAXLEN];
                char                    *accessstr;
@@ -124,6 +125,7 @@ slapacl( int argc, char **argv )
                        val.bv_val[0] = '\0';
                        val.bv_val++;
                        val.bv_len = strlen( val.bv_val );
+                       valp = &val;
                }
 
                accessstr = strchr( attr, '/' );
@@ -151,7 +153,7 @@ slapacl( int argc, char **argv )
                        break;
                }
 
-               rc = access_allowed_mask( op, &e, desc, &val, access,
+               rc = access_allowed_mask( op, &e, desc, valp, access,
                                NULL, &mask );
 
                if ( accessstr ) {
index 2d648278161dd4b3fb3950d685b9ee61366a8347..788100e615605c8b0d9a4f94986762ede874844a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
 #include "slapcommon.h"
 
 static char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
-static const struct berval slap_syncrepl_bvc = BER_BVC("syncreplxxx");
-static const struct berval slap_syncrepl_cn_bvc = BER_BVC("cn=syncreplxxx");
-static struct berval slap_syncrepl_bv = BER_BVNULL;
-static struct berval slap_syncrepl_cn_bv = BER_BVNULL;
-
-struct subentryinfo {
-       struct berval cn;
-       struct berval ndn;
-       struct berval rdn;
-       struct berval cookie;
-       LDAP_SLIST_ENTRY( subentryinfo ) sei_next;
-};
+static char maxcsnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
 
 int
 slapadd( int argc, char **argv )
@@ -66,25 +55,17 @@ slapadd( int argc, char **argv )
        const char *progname = "slapadd";
 
        struct berval csn;
-       struct berval maxcsn = BER_BVNULL;
-       struct berval ldifcsn = BER_BVNULL;
+       struct berval maxcsn;
        int match;
-       int     provider_subentry = 0;
-       struct subentryinfo *sei;
-       LDAP_SLIST_HEAD( consumer_subentry_slist, subentryinfo ) consumer_subentry;
        Attribute *attr;
        Entry *ctxcsn_e;
-       ID      ctxcsn_id;
-       struct berval   ctxcsn_ndn = BER_BVNULL;
+       ID      ctxcsn_id, id;
        int ret;
        struct berval bvtext;
        int i;
        struct berval mc;
-       struct sync_cookie sc;
        slap_tool_init( progname, SLAPADD, argc, argv );
 
-       LDAP_SLIST_INIT( &consumer_subentry );
-
        if( !be->be_entry_open ||
                !be->be_entry_close ||
                !be->be_entry_put )
@@ -108,6 +89,11 @@ slapadd( int argc, char **argv )
                exit( EXIT_FAILURE );
        }
 
+       if ( update_ctxcsn ) {
+               maxcsn.bv_val = maxcsnbuf;
+               maxcsn.bv_len = 0;
+       }
+
        while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
                Entry *e = str2entry( buf );
 
@@ -288,11 +274,10 @@ slapadd( int argc, char **argv )
                                attr_merge( e, slap_schema.si_ad_entryCSN, vals, NULL );
                        }
 
-                       if ( !is_entry_syncProviderSubentry( e ) &&
-                                !is_entry_syncConsumerSubentry( e ) &&
-                                update_ctxcsn != SLAP_TOOL_CTXCSN_KEEP ) {
+                       if ( update_ctxcsn ) {
                                attr = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
                                if ( maxcsn.bv_len != 0 ) {
+                                       match = 0;
                                        value_match( &match, slap_schema.si_ad_entryCSN,
                                                slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
                                                SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
@@ -301,142 +286,32 @@ slapadd( int argc, char **argv )
                                        match = -1;
                                }
                                if ( match < 0 ) {
-                                       if ( maxcsn.bv_val )
-                                               ch_free( maxcsn.bv_val );
-                                       ber_dupbv( &maxcsn, &attr->a_nvals[0] );
+                                       strcpy( maxcsn.bv_val, attr->a_nvals[0].bv_val );
+                                       maxcsn.bv_len = attr->a_nvals[0].bv_len;
                                }
                        }
                }
 
-               if ( dryrun ) {
-                       if ( verbose ) {
-                               fprintf( stderr, "(dry) added: \"%s\"\n", e->e_dn );
-                       }
-                       goto done;
-               }
-
-               if ( update_ctxcsn == SLAP_TOOL_CTXCSN_KEEP &&
-                       ( replica_promotion || replica_demotion )) {
-                       if ( is_entry_syncProviderSubentry( e )) { 
-                               if ( !LDAP_SLIST_EMPTY( &consumer_subentry )) {
-                                       fprintf( stderr, "%s: consumer and provider subentries "
-                                                                        "are both present\n", progname );
-                                       rc = EXIT_FAILURE;
-                                       entry_free( e );
-                                       sei = LDAP_SLIST_FIRST( &consumer_subentry );
-                                       while ( sei ) {
-                                               ch_free( sei->cn.bv_val );
-                                               ch_free( sei->ndn.bv_val );
-                                               ch_free( sei->rdn.bv_val );
-                                               ch_free( sei->cookie.bv_val );
-                                               LDAP_SLIST_REMOVE_HEAD( &consumer_subentry, sei_next );
-                                               ch_free( sei );
-                                               sei = LDAP_SLIST_FIRST( &consumer_subentry );
-                                       }
-                                       break;
-                               }
-                               if ( provider_subentry ) {
-                                       fprintf( stderr, "%s: multiple provider subentries are "
-                                                       "present : add -w flag to refresh\n", progname );
-                                       rc = EXIT_FAILURE;
-                                       entry_free( e );
-                                       break;
-                               }
-                               attr = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
-                               if ( attr == NULL ) {
-                                       entry_free( e );
-                                       continue;
-                               }
-                               provider_subentry = 1;
-                               ber_dupbv( &maxcsn, &attr->a_nvals[0] );
-                       } else if ( is_entry_syncConsumerSubentry( e )) {
-                               if ( provider_subentry ) {
-                                       fprintf( stderr, "%s: consumer and provider subentries "
-                                                                        "are both present\n", progname );
-                                       rc = EXIT_FAILURE;
-                                       entry_free( e );
-                                       break;
-                               }
-
-                               attr = attr_find( e->e_attrs, slap_schema.si_ad_cn );
-
-                               if ( attr == NULL ) {
-                                       entry_free( e );
-                                       continue;
-                               }
-
-                               if ( !LDAP_SLIST_EMPTY( &consumer_subentry )) {
-                                       LDAP_SLIST_FOREACH( sei, &consumer_subentry, sei_next ) {
-                                               value_match( &match, slap_schema.si_ad_cn,
-                                                       slap_schema.si_ad_cn->ad_type->sat_equality,
-                                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                                       &sei->cn, &attr->a_nvals[0], &text );
-                                       }
-                                       if ( !match ) {
-                                               fprintf( stderr, "%s: multiple consumer subentries "
-                                                               "have the same id : add -w flag to refresh\n",
-                                                               progname );
-                                               rc = EXIT_FAILURE;
-                                               entry_free( e );
-                                               sei = LDAP_SLIST_FIRST( &consumer_subentry );
-                                               while ( sei ) {
-                                                       ch_free( sei->cn.bv_val );
-                                                       ch_free( sei->ndn.bv_val );
-                                                       ch_free( sei->rdn.bv_val );
-                                                       ch_free( sei->cookie.bv_val );
-                                                       LDAP_SLIST_REMOVE_HEAD( &consumer_subentry, sei_next );
-                                                       ch_free( sei );
-                                                       sei = LDAP_SLIST_FIRST( &consumer_subentry );
-                                               }
-                                               break;
-                                       }
-                               }
-                               sei = ch_calloc( 1, sizeof( struct subentryinfo ));
-                               ber_dupbv( &sei->cn, &attr->a_nvals[0] );
-                               ber_dupbv( &sei->ndn, &e->e_nname );
-                               dnExtractRdn( &sei->ndn, &sei->rdn, NULL );
-                               attr = attr_find( e->e_attrs, slap_schema.si_ad_syncreplCookie );
-                               if ( attr == NULL ) {
-                                       ch_free( sei->cn.bv_val );
-                                       ch_free( sei->ndn.bv_val );
-                                       ch_free( sei->rdn.bv_val );
-                                       ch_free( sei->cookie.bv_val );
-                                       ch_free( sei );
-                                       entry_free( e );
-                                       continue;
-                               }
-                               ber_dupbv( &sei->cookie, &attr->a_nvals[0] );
-                               LDAP_SLIST_INSERT_HEAD( &consumer_subentry, sei, sei_next );
+               if ( !dryrun ) {
+                       id = be->be_entry_put( be, e, &bvtext );
+                       if( id == NOID ) {
+                               fprintf( stderr, "%s: could not add entry dn=\"%s\" "
+                                                                "(line=%d): %s\n", progname, e->e_dn,
+                                                                lineno, bvtext.bv_val );
+                               rc = EXIT_FAILURE;
+                               entry_free( e );
+                               if( continuemode ) continue;
+                               break;
                        }
                }
 
-               if (( !is_entry_syncProviderSubentry( e ) &&
-                                !is_entry_syncConsumerSubentry( e )) ||
-                                ( !replica_promotion && !replica_demotion ))
-               {
-                       /* dryrun moved earlier */
-                       assert( !dryrun );
-
-                       if (!dryrun) {
-                               ID id = be->be_entry_put( be, e, &bvtext );
-                               if( id == NOID ) {
-                                       fprintf( stderr, "%s: could not add entry dn=\"%s\" "
-                                                                        "(line=%d): %s\n", progname, e->e_dn,
-                                                                        lineno, bvtext.bv_val );
-                                       rc = EXIT_FAILURE;
-                                       entry_free( e );
-                                       if( continuemode ) continue;
-                                       break;
-                               }
-       
-                               if ( verbose ) {
-                                       fprintf( stderr, "added: \"%s\" (%08lx)\n",
-                                               e->e_dn, (long) id );
-                               }
+               if ( verbose ) {
+                       if ( dryrun ) {
+                               fprintf( stderr, "added: \"%s\"\n",
+                                       e->e_dn );
                        } else {
-                               if ( verbose ) {
-                                       fprintf( stderr, "(dry) added: \"%s\"\n", e->e_dn );
-                               }
+                               fprintf( stderr, "added: \"%s\" (%08lx)\n",
+                                       e->e_dn, (long) id );
                        }
                }
 
@@ -448,279 +323,37 @@ done:;
        bvtext.bv_val = textbuf;
        bvtext.bv_val[0] = '\0';
 
-       if ( !LDAP_SLIST_EMPTY( &consumer_subentry )) {
-               maxcsn.bv_len = 0;
-               maxcsn.bv_val = NULL;
-               LDAP_SLIST_FOREACH( sei, &consumer_subentry, sei_next ) {
-                       sc.octet_str = &sei->cookie;
-                       slap_parse_sync_cookie( &sc );
-                       if ( maxcsn.bv_len != 0 ) {
-                               value_match( &match, slap_schema.si_ad_syncreplCookie,
-                                       slap_schema.si_ad_syncreplCookie->ad_type->sat_ordering,
+       if ( update_ctxcsn && !dryrun && maxcsn.bv_len ) {
+               ctxcsn_id = be->be_dn2id_get( be, be->be_nsuffix );
+               if ( ctxcsn_id == NOID ) {
+                       fprintf( stderr, "%s: context entry is missing\n", progname );
+                       rc = EXIT_FAILURE;
+               } else {
+                       ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
+                       if ( ret == LDAP_SUCCESS ) {
+                               attr = attr_find( ctxcsn_e->e_attrs,
+                                                                       slap_schema.si_ad_contextCSN );
+                               value_match( &match, slap_schema.si_ad_entryCSN,
+                                       slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
                                        SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                       &maxcsn, &sc.ctxcsn[0], &text );
-                       } else {
-                               match = -1;
-                       }
-                       if ( match < 0 ) {
-                               if ( maxcsn.bv_val )
-                                       ch_free( maxcsn.bv_val );
-                               ber_dupbv( &maxcsn, &sc.ctxcsn[0] );
-                       }
-                       sc.octet_str = NULL;
-                       slap_sync_cookie_free( &sc, 0 );
-               }
-       }
-
-       slap_compose_sync_cookie( NULL, &mc, &maxcsn, -1, -1 );
-
-       if ( SLAP_LASTMOD(be) && replica_promotion ) {
-               if ( provider_subentry || update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH ||
-                        !LDAP_SLIST_EMPTY( &consumer_subentry )) {
-                       build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0],
-                                                 (struct berval *)&slap_ldapsync_cn_bv, NULL );
-                       ctxcsn_id = be->be_dn2id_get( be, &ctxcsn_ndn );
-               
-                       if ( ctxcsn_id == NOID ) {
-                               ctxcsn_e = slap_create_context_csn_entry( be, &maxcsn );
-                               
-                               /* dryrun moved earlier */
-                               assert( !dryrun );
-
-                               if ( !dryrun ) {
-                                       ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
-                                       if( ctxcsn_id == NOID ) {
-                                               fprintf( stderr, "%s: could not add ctxcsn subentry\n",
-                                                                                progname);
-                                               rc = EXIT_FAILURE;
-                                       }
-                                       if ( verbose ) {
-                                               fprintf( stderr, "added: \"%s\" (%08lx)\n",
-                                                                                ctxcsn_e->e_dn, (long) ctxcsn_id );
-                                       }
-                               } else {
-                                       if ( verbose ) {
-                                               fprintf( stderr, "(dry) added: \"%s\"\n", ctxcsn_e->e_dn );
-                                       }
-                               }
-                               entry_free( ctxcsn_e );
-                       } else {
-                               ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
-                               if ( ret == LDAP_SUCCESS ) {
-                                       attr = attr_find( ctxcsn_e->e_attrs,
-                                                                               slap_schema.si_ad_contextCSN );
+                                       &maxcsn, &attr->a_nvals[0], &text );
+                               if ( match > 0 ) {
                                        AC_MEMCPY( attr->a_vals[0].bv_val, maxcsn.bv_val, maxcsn.bv_len );
                                        attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
                                        attr->a_vals[0].bv_len = maxcsn.bv_len;
                                
-                                       /* dryrun moved earlier */
-                                       assert( !dryrun );
-
-                                       if ( !dryrun ) {
-                                               ctxcsn_id = be->be_entry_modify( be, ctxcsn_e, &bvtext );
-                                               if( ctxcsn_id == NOID ) {
-                                                       fprintf( stderr, "%s: could not modify ctxcsn "
-                                                                                        "subentry\n", progname);
-                                                       rc = EXIT_FAILURE;
-                                               }
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "modified: \"%s\" (%08lx)\n",
-                                                                                        ctxcsn_e->e_dn, (long) ctxcsn_id );
-                                               }
-                                       } else {
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "(dry) modified: \"%s\"\n",
-                                                                                        ctxcsn_e->e_dn );
-                                               }
-                                       }
-                               } else {
-                                       fprintf( stderr, "%s: could not modify ctxcsn subentry\n",
-                                                                        progname);
-                                       rc = EXIT_FAILURE;
-                               }
-                       }
-               } 
-       } else if ( SLAP_LASTMOD(be) && replica_demotion &&
-                               ( update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH ||
-                               provider_subentry )) {
-
-               ber_dupbv( &slap_syncrepl_bv, (struct berval *) &slap_syncrepl_bvc );
-               ber_dupbv( &slap_syncrepl_cn_bv,
-                                       (struct berval *) &slap_syncrepl_cn_bvc );
-
-               if ( replica_id_list == NULL ) {
-                       replica_id_list = ch_calloc( 2, sizeof( int ));
-                       replica_id_list[0] = 0;
-                       replica_id_list[1] = -1;
-               }
-
-               for ( i = 0; replica_id_list[i] > -1 ; i++ ) {
-                       slap_syncrepl_bv.bv_len = snprintf( slap_syncrepl_bv.bv_val,
-                                                                       slap_syncrepl_bvc.bv_len+1,
-                                                                       "syncrepl%d", replica_id_list[i] );
-                       slap_syncrepl_cn_bv.bv_len = snprintf( slap_syncrepl_cn_bv.bv_val,
-                                                                               slap_syncrepl_cn_bvc.bv_len+1,
-                                                                               "cn=syncrepl%d", replica_id_list[i] );
-                       build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0],
-                                                 (struct berval *)&slap_syncrepl_cn_bv, NULL );
-                       ctxcsn_id = be->be_dn2id_get( be, &ctxcsn_ndn );
-
-                       if ( ctxcsn_id == NOID ) {
-                               ctxcsn_e = slap_create_syncrepl_entry( be, &mc,
-                                               &slap_syncrepl_cn_bv,
-                                               &slap_syncrepl_bv );
-
-                               /* dryrun moved earlier */
-                               assert( !dryrun );
-
-                               if ( !dryrun ) {
-                                       ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
-                                       if( ctxcsn_id == NOID ) {
-                                               fprintf( stderr, "%s: could not add ctxcsn subentry\n",
-                                                                                progname);
-                                               rc = EXIT_FAILURE;
-                                       }
-                                       if ( verbose ) {
-                                               fprintf( stderr, "added: \"%s\" (%08lx)\n",
-                                                                                ctxcsn_e->e_dn, (long) ctxcsn_id );
-                                       }
-                               } else {
-                                       if ( verbose ) {
-                                               fprintf( stderr, "(dry) added: \"%s\"\n",
-                                                                                       ctxcsn_e->e_dn );
-                                       }
-                               }
-                               entry_free( ctxcsn_e );
-                       } else {
-                               ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
-                               if ( ret == LDAP_SUCCESS ) {
-                                       attr = attr_find( ctxcsn_e->e_attrs,
-                                                                         slap_schema.si_ad_syncreplCookie );
-                                       AC_MEMCPY( attr->a_vals[0].bv_val, mc.bv_val, mc.bv_len );
-                                       attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
-                                       attr->a_vals[0].bv_len = maxcsn.bv_len;
-                               
-                                       /* dryrun moved earlier */
-                                       assert( !dryrun );
-
-                                       if ( !dryrun ) {
-                                               ctxcsn_id = be->be_entry_modify( be,
-                                                                                       ctxcsn_e, &bvtext );
-                                               if( ctxcsn_id == NOID ) {
-                                                       fprintf( stderr, "%s: could not modify ctxcsn "
-                                                                                        "subentry\n", progname);
-                                                       rc = EXIT_FAILURE;
-                                               }
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "modified: \"%s\" (%08lx)\n",
-                                                                                        ctxcsn_e->e_dn, (long) ctxcsn_id );
-                                               }
-                                       } else {
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "(dry) modified: \"%s\"\n",
-                                                                                        ctxcsn_e->e_dn );
-                                               }
-                                       }
-                               } else {
-                                       fprintf( stderr, "%s: could not modify ctxcsn subentry\n",
-                                                                        progname);
-                                       rc = EXIT_FAILURE;
-                               }
-                       }
-               }
-               
-               if ( slap_syncrepl_bv.bv_val ) {
-                       ch_free( slap_syncrepl_bv.bv_val );
-               }
-               if ( slap_syncrepl_cn_bv.bv_val ) {
-                       ch_free( slap_syncrepl_cn_bv.bv_val );
-               }
-       } else if ( SLAP_LASTMOD(be) && replica_demotion &&
-                               !LDAP_SLIST_EMPTY( &consumer_subentry )) {
-
-               LDAP_SLIST_FOREACH( sei, &consumer_subentry, sei_next ) {
-                       ctxcsn_id = be->be_dn2id_get( be, &sei->ndn );
-
-                       if ( ctxcsn_id == NOID ) {
-                               ctxcsn_e = slap_create_syncrepl_entry( be, &sei->cookie,
-                                               &sei->rdn, &sei->cn );
-
-                               /* dryrun moved earlier */
-                               assert( !dryrun );
-
-                               if ( !dryrun ) {
-                                       ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
+                                       ctxcsn_id = be->be_entry_modify( be, ctxcsn_e, &bvtext );
                                        if( ctxcsn_id == NOID ) {
-                                               fprintf( stderr, "%s: could not add ctxcsn subentry\n",
-                                                                                progname);
+                                               fprintf( stderr, "%s: could not modify ctxcsn\n",
+                                                                               progname);
                                                rc = EXIT_FAILURE;
-                                       }
-                                       if ( verbose ) {
-                                               fprintf( stderr, "added: \"%s\" (%08lx)\n",
+                                       } else if ( verbose ) {
+                                               fprintf( stderr, "modified: \"%s\" (%08lx)\n",
                                                                                 ctxcsn_e->e_dn, (long) ctxcsn_id );
                                        }
-                               } else {
-                                       if ( verbose ) {
-                                               fprintf( stderr, "(dry) added: \"%s\"\n",
-                                                                                       ctxcsn_e->e_dn );
-                                       }
-                               }
-                               entry_free( ctxcsn_e );
-                       } else {
-                               ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
-                               if ( ret == LDAP_SUCCESS ) {
-                                       attr = attr_find( ctxcsn_e->e_attrs,
-                                                                         slap_schema.si_ad_syncreplCookie );
-                                       AC_MEMCPY( attr->a_vals[0].bv_val, sei->cookie.bv_val, sei->cookie.bv_len );
-                                       attr->a_vals[0].bv_val[sei->cookie.bv_len] = '\0';
-                                       attr->a_vals[0].bv_len = sei->cookie.bv_len;
-                                       
-                                       /* dryrun moved earlier */
-                                       assert( !dryrun );
-
-                                       if ( !dryrun ) {
-                                               ctxcsn_id = be->be_entry_modify( be,
-                                                                                       ctxcsn_e, &bvtext );
-                                               if( ctxcsn_id == NOID ) {
-                                                       fprintf( stderr, "%s: could not modify ctxcsn "
-                                                                                        "subentry\n", progname);
-                                                       rc = EXIT_FAILURE;
-                                               }
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "modified: \"%s\" (%08lx)\n",
-                                                                                        ctxcsn_e->e_dn, (long) ctxcsn_id );
-                                               }
-                                       } else {
-                                               if ( verbose ) {
-                                                       fprintf( stderr, "(dry) modified: \"%s\"\n",
-                                                                                        ctxcsn_e->e_dn );
-                                               }
-                                       }
-                               } else {
-                                       fprintf( stderr, "%s: could not modify ctxcsn subentry\n",
-                                                                        progname);
-                                       rc = EXIT_FAILURE;
                                }
                        }
-               }
-               
-               if ( slap_syncrepl_bv.bv_val ) {
-                       ch_free( slap_syncrepl_bv.bv_val );
-               }
-               if ( slap_syncrepl_cn_bv.bv_val ) {
-                       ch_free( slap_syncrepl_cn_bv.bv_val );
-               }
-       }
-
-       sei = LDAP_SLIST_FIRST( &consumer_subentry );
-       while ( sei ) {
-               ch_free( sei->cn.bv_val );
-               ch_free( sei->ndn.bv_val );
-               ch_free( sei->rdn.bv_val );
-               ch_free( sei->cookie.bv_val );
-               LDAP_SLIST_REMOVE_HEAD( &consumer_subentry, sei_next );
-               ch_free( sei );
-               sei = LDAP_SLIST_FIRST( &consumer_subentry );
+               } 
        }
 
        ch_free( buf );
index ec19742bd60930b1c8e23d66dc6b7299015b4c06..6e61ff163e68dc6d3a960ef3e413e6a4e0f0c716 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 7daeaa645a185f0c25be1699e3cbad8cc2c07793..e8a4beda5aab7166306059eb2108c1c0a5ad0925 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
@@ -87,20 +87,6 @@ slapcat( int argc, char **argv )
                        }
                }
 
-               if ( retrieve_ctxcsn == 0 ) {
-                       if ( is_entry_syncProviderSubentry( e ) ) {
-                               be_entry_release_r( &op, e );
-                               continue;
-                       }
-               }
-
-               if ( retrieve_synccookie == 0 ) {
-                       if ( is_entry_syncConsumerSubentry( e ) ) {
-                               be_entry_release_r( &op, e );
-                               continue;
-                       }
-               }
-
                if( verbose ) {
                        printf( "# id=%08lx\n", (long) id );
                }
index fbae61c2abbdd0267db5dc5839e08a31dcfaffef..bafe34dafe204ef6e457df07a676b956d9ef4087 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
@@ -49,35 +49,39 @@ usage( int tool, const char *progname )
 {
        char *options = NULL;
        fprintf( stderr,
-               "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n",
+               "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]",
                progname );
 
        switch( tool ) {
+       case SLAPACL:
+               options = "\n\t[-U authcID | -D authcDN]"
+                       " -b DN [attr[/access][:value]] [...]\n";
+               break;
+
        case SLAPADD:
-               options = "\t[-n databasenumber | -b suffix]\n"
-                       "\t[-l ldiffile] [-u] [-p [-w] | -r [-i syncreplidlist] [-w]]\n";
+               options = "\n\t[-n databasenumber | -b suffix]\n"
+                       "\t[-l ldiffile] [-u] [-w]\n";
+               break;
+
+       case SLAPAUTH:
+               options = "\n\t[-U authcID] [-X authzID] [-R realm] [-M mech] ID [...]\n";
                break;
 
        case SLAPCAT:
-               options = "\t[-n databasenumber | -b suffix]"
-                       " [-l ldiffile] [-a filter] [-m] [-k]\n";
+               options = "\n\t[-n databasenumber | -b suffix]"
+                       " [-l ldiffile] [-a filter]\n";
                break;
 
        case SLAPDN:
-               options = "\tDN [...]\n";
+               options = " DN [...]\n";
                break;
 
        case SLAPINDEX:
-               options = "\t[-n databasenumber | -b suffix]\n";
+               options = "\n\t[-n databasenumber | -b suffix]\n";
                break;
 
-       case SLAPAUTH:
-               options = "\t[-U authcID] [-X authzID] [-R realm] [-M mech] ID [...]\n";
-               break;
-
-       case SLAPACL:
-               options = "\t[-U authcID | -D authcDN]"
-                       " -b DN [attr[/access][:value]] [...]\n";
+       case SLAPTEST:
+               options = " [-u]\n";
                break;
        }
 
@@ -113,7 +117,7 @@ slap_tool_init(
        int truncatemode = 0;
 
 #ifdef CSRIMALLOC
-       leakfilename = malloc( strlen( progname ) + STRLEOF( ".leak" ) - 1 );
+       leakfilename = malloc( strlen( progname ) + STRLENOF( ".leak" ) + 1 );
        sprintf( leakfilename, "%s.leak", progname );
        if( ( leakfile = fopen( leakfilename, "w" )) == NULL ) {
                leakfile = stderr;
@@ -123,20 +127,24 @@ slap_tool_init(
 
        switch( tool ) {
        case SLAPADD:
-               options = "b:cd:f:i:l:n:prtuvWw";
+               options = "b:cd:f:l:n:tuvw";
                break;
 
        case SLAPCAT:
-               options = "a:b:cd:f:kl:mn:s:v";
+               options = "a:b:cd:f:l:n:s:v";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
        case SLAPDN:
-       case SLAPTEST:
                options = "d:f:v";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
+       case SLAPTEST:
+               options = "d:f:uv";
+               mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
+               break;
+
        case SLAPAUTH:
                options = "d:f:M:R:U:vX:";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
@@ -184,39 +192,10 @@ slap_tool_init(
                        conffile = strdup( optarg );
                        break;
 
-               case 'i': /* specify syncrepl id list */
-                       replica_id_string = strdup( optarg );
-                       if ( !isdigit( (unsigned char) *replica_id_string )) {
-                               usage( tool, progname );
-                               exit( EXIT_FAILURE );
-                       }
-                       slap_str2clist( &replica_id_strlist, replica_id_string, "," );
-                       for ( i = 0; replica_id_strlist && replica_id_strlist[i]; i++ ) ;
-                       replica_id_list = ch_calloc( i + 1, sizeof( int ) );
-                       for ( i = 0; replica_id_strlist && replica_id_strlist[i]; i++ ) {
-                               replica_id_list[i] = atoi( replica_id_strlist[i] );
-                               if ( replica_id_list[i] >= 1000 ) {
-                                       fprintf(stderr,
-                                               "%s: syncrepl id %d is out of range [0..999]\n",
-                                               progname, replica_id_list[i] );
-                                       exit( EXIT_FAILURE );
-                               }
-                       }
-                       replica_id_list[i] = -1;
-                       break;
-
-               case 'k':       /* Retrieve sync cookie entry */
-                       retrieve_synccookie = 1;
-                       break;
-
                case 'l':       /* LDIF file */
                        ldiffile = strdup( optarg );
                        break;
 
-               case 'm':       /* Retrieve ldapsync entry */
-                       retrieve_ctxcsn = 1;
-                       break;
-
                case 'M':
                        ber_str2bv( optarg, 0, 0, &mech );
                        break;
@@ -225,14 +204,6 @@ slap_tool_init(
                        dbnum = atoi( optarg ) - 1;
                        break;
 
-               case 'p':       /* replica promotion */
-                       replica_promotion = 1;          
-                       break;
-
-               case 'r':       /* replica demotion */
-                       replica_demotion = 1;           
-                       break;
-
                case 'R':
                        realm = optarg;
                        break;
@@ -258,13 +229,8 @@ slap_tool_init(
                        verbose++;
                        break;
 
-               case 'W':       /* write context csn on every entry add */
-                       update_ctxcsn = SLAP_TOOL_CTXCSN_BATCH;
-                       /* FIXME : update_ctxcsn = SLAP_TOOL_CTXCSN_ENTRY; */
-                       break;
-
-               case 'w':       /* write context csn on at the end */
-                       update_ctxcsn = SLAP_TOOL_CTXCSN_BATCH;
+               case 'w':       /* write context csn at the end */
+                       update_ctxcsn++;
                        break;
 
                case 'X':
@@ -285,14 +251,6 @@ slap_tool_init(
                        usage( tool, progname );
                }
 
-               if ( replica_promotion && replica_demotion ) {
-                       usage( tool, progname );
-
-               } else if ( !replica_promotion && !replica_demotion ) {
-                       if ( update_ctxcsn != SLAP_TOOL_CTXCSN_KEEP ) {
-                               usage( tool, progname );
-                       }
-               }
                break;
 
        case SLAPDN:
@@ -523,7 +481,19 @@ startup:;
 #endif
 
        if ( !dryrun && slap_startup( be ) ) {
-               fprintf( stderr, "slap_startup failed\n" );
+
+               switch ( tool ) {
+               case SLAPTEST:
+                       fprintf( stderr, "slap_startup failed "
+                                       "(test would succeed using "
+                                       "the -u switch)\n" );
+                       break;
+
+               default:
+                       fprintf( stderr, "slap_startup failed\n" );
+                       break;
+               }
+               
                exit( EXIT_FAILURE );
        }
 }
index ab3d0aa0c3c14f0d9c31a610a6b19510ed8d41e8..8d6c94113f754deade7c5e746a0a1d351735f17c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,21 +32,10 @@ enum slaptool {
        SLAPLAST
 };
 
-#define SLAP_TOOL_CTXCSN_KEEP  0
-#define SLAP_TOOL_CTXCSN_ENTRY 1
-#define SLAP_TOOL_CTXCSN_BATCH 2
-
 typedef struct tool_vars {
        Backend *tv_be;
        int tv_verbose;
        int tv_update_ctxcsn;
-       int tv_retrieve_ctxcsn;
-       int tv_retrieve_synccookie;
-       int tv_replica_promotion;
-       int tv_replica_demotion;
-       char    *tv_replica_id_string;
-       char    **tv_replica_id_strlist;
-       int     *tv_replica_id_list;
        int tv_continuemode;
        int tv_nosubordinates;
        int tv_dryrun;
@@ -66,13 +55,6 @@ extern tool_vars tool_globals;
 #define        be tool_globals.tv_be
 #define verbose tool_globals.tv_verbose
 #define update_ctxcsn tool_globals.tv_update_ctxcsn
-#define retrieve_ctxcsn tool_globals.tv_retrieve_ctxcsn
-#define retrieve_synccookie tool_globals.tv_retrieve_synccookie
-#define replica_promotion tool_globals.tv_replica_promotion
-#define replica_demotion tool_globals.tv_replica_demotion
-#define replica_id_string tool_globals.tv_replica_id_string
-#define replica_id_strlist tool_globals.tv_replica_id_strlist
-#define replica_id_list tool_globals.tv_replica_id_list
 #define continuemode tool_globals.tv_continuemode
 #define nosubordinates tool_globals.tv_nosubordinates
 #define dryrun tool_globals.tv_dryrun
index 57c796845c53f326f938ca406c842507cc533196..400d5071db5b2bfb6fe81c441654cf749ac4c26d 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index 06178835119a3987dfd5aad8d67c6ee445e1b9db..c2b9a594d2805ae9ac8c75ebb1f89d72d87c6869 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## Portions Copyright IBM Corp. 1997,2002,2003
 ## All rights reserved.
 ##
index a3bef163641b85dede0f7ab0b865c1ccbb080907..460e03cea45f19b2bfe7e160ebeab4dbe912f7ef 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index 224c77e187d0a1cc2ed95936e0dd234ba15baaa3..428d1cf2fa79954adcd3681eb469b8bd4dd29d0e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index 658eca5c270c325621f7533c6a1312ca33bca186..046658249649fea1a3b5551fe17cd34d975961b1 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index cb3c87bb75e155b33e5706be8e90501e15744166..1470e345188c4b23eea944eeb41122b222433181 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index 08f0ce932cf362a0da64be519a344de7e18a4567..fea688d1eac6990916c384ee1568175b0e13291b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index d83b77a2a8e52e565014a47d971030d4840d9543..cb1d66e0ec9c69a065edae4da5ad0de5e59c0744 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 6a0f9ec04f88f3294dca9efc1144efd0fbf278f0..fb0fd3605205bedc1517cd3ac8f8570af2bbde90 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index 9df6d213a126432727dd689cb8d042dea08faa3b..79efa4124e461f1aee5663fb9fde92c31e462152 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
@@ -228,6 +228,10 @@ isOkNetscapeParam( int param )
 static int
 isValidParam( Slapi_PBlock *pb, int param ) 
 {
+       if ( !pb ) {
+               return INVALID_PARAM;
+       }
+       
        if ( pb->ckParams == TRUE ) {
                if ( IBM_RESERVED( param ) ) return LDAP_SUCCESS;
                if (param == SLAPI_PLUGIN_AUDIT_FN ||
index f1e2b4e73a6dc506c671ef35c326e5f18850d6c2..3a69cc4a55960ffc49e2d9588c37bb51646d2f73 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
index e9466c04276c824504a87e2f358a39a38d804ea2..da889dadc724ff11e7007495f6adba7c89fa4de6 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 50575217fdd22f76e20cff20b331319b572d3981..f02008fad00b68cafc1bda867d671067b63019df 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
index 12680414c76e977b82c00c4536b5660b79bef557..2bd5d1b0f383b2b3aadcbbca57d4da7df2dfa487 100644 (file)
@@ -1,6 +1,6 @@
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
index b953e3e3e59fe20c058dae833126a2dfa11d3702..e8170ad69056d1115a21482d181073aa318b6566 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 52e5d791698a4f2d925d503ee8ce43b9af290236..b6aa778c6b85fd71bd1567eeb4d47b7555d596bd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 8e15a439347316ecfebef520f00cbeaa193d1bbc..ec9f08280b3b63ba499cf7095d43e23ea80d16e1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 by IBM Corporation.
  * Portions Copyright 2003 by Howard Chu, Symas Corporation.
  * All rights reserved.
 #undef ldap_debug
 #include "../../libraries/libldap/ldap-int.h"
 
-#define SYNCREPL_STR   "syncreplxxx"
-#define CN_STR "cn="
-
-static const struct berval slap_syncrepl_bvc = BER_BVC(SYNCREPL_STR);
-static const struct berval slap_syncrepl_cn_bvc = BER_BVC(CN_STR SYNCREPL_STR);
-
 static int syncuuid_cmp( const void *, const void * );
 static void avl_ber_bvfree( void * );
 static void syncrepl_del_nonpresent( Operation *, syncinfo_t *, BerVarray );
@@ -231,12 +225,11 @@ ldap_sync_search(
        ber_init2( ber, NULL, LBER_USE_DER );
        ber_set_option( ber, LBER_OPT_BER_MEMCTX, &ctx );
 
-       if ( si->si_syncCookie.octet_str &&
-               !BER_BVISNULL( &si->si_syncCookie.octet_str[0] ) )
+       if ( !BER_BVISNULL( &si->si_syncCookie.octet_str ) )
        {
                ber_printf( ber, "{eO}",
                        abs(si->si_type),
-                       &si->si_syncCookie.octet_str[0] );
+                       &si->si_syncCookie.octet_str );
        } else {
                ber_printf( ber, "{e}",
                        abs(si->si_type) );
@@ -280,8 +273,6 @@ do_syncrep1(
        int     rc;
        int cmdline_cookie_found = 0;
 
-       char syncrepl_cbuf[sizeof(CN_STR SYNCREPL_STR)];
-       struct berval syncrepl_cn_bv;
        struct sync_cookie      *sc = NULL;
        struct berval   *psub;
 #ifdef HAVE_TLS
@@ -291,11 +282,11 @@ do_syncrep1(
        psub = &si->si_be->be_nsuffix[0];
 
        /* Init connection to master */
-       rc = ldap_initialize( &si->si_ld, si->si_provideruri );
+       rc = ldap_initialize( &si->si_ld, si->si_provideruri.bv_val );
        if ( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_ANY,
                        "do_syncrep1: ldap_initialize failed (%s)\n",
-                       si->si_provideruri, 0, 0 );
+                       si->si_provideruri.bv_val, 0, 0 );
                return rc;
        }
 
@@ -326,7 +317,7 @@ do_syncrep1(
                        if( rc != LDAP_OPT_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
                                        "(%s,SECPROPS,\"%s\") failed!\n",
-                                       si->si_provideruri, si->si_secprops, 0 );
+                                       si->si_provideruri.bv_val, si->si_secprops, 0 );
                                goto done;
                        }
                }
@@ -396,94 +387,51 @@ do_syncrep1(
        op->o_ssf = ( op->o_sasl_ssf > op->o_tls_ssf )
                ?  op->o_sasl_ssf : op->o_tls_ssf;
 
-       /* get syncrepl cookie of shadow replica from subentry */
-       assert( si->si_rid < 1000 );
-       syncrepl_cn_bv.bv_val = syncrepl_cbuf;
-       syncrepl_cn_bv.bv_len = snprintf( syncrepl_cbuf, sizeof(syncrepl_cbuf),
-               CN_STR "syncrepl%ld", si->si_rid );
-       build_new_dn( &op->o_req_ndn, psub, &syncrepl_cn_bv, op->o_tmpmemctx );
-       op->o_req_dn = op->o_req_ndn;
-
-       LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) {
-               if ( si->si_rid == sc->rid ) {
-                       cmdline_cookie_found = 1;
-                       break;
-               }
-       }
 
-       if ( cmdline_cookie_found ) {
-               /* cookie is supplied in the command line */
-               BerVarray cookie = NULL;
-               struct berval cookie_bv;
+       if ( BER_BVISNULL( &si->si_syncCookie.octet_str )) {
+               /* get contextCSN shadow replica from database */
+               BerVarray csn = NULL;
+               struct berval newcookie;
 
-               LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
-               slap_sync_cookie_free( &si->si_syncCookie, 0 );
+               assert( si->si_rid < 1000 );
+               op->o_req_ndn = op->o_bd->be_nsuffix[0];
+               op->o_req_dn = op->o_req_ndn;
 
-               /* read stored cookie if it exists */
+               /* try to read stored contextCSN */
                backend_attribute( op, NULL, &op->o_req_ndn,
-                       slap_schema.si_ad_syncreplCookie, &cookie, ACL_READ );
+                       slap_schema.si_ad_contextCSN, &csn, ACL_READ );
+               if ( csn ) {
+                       ch_free( si->si_syncCookie.ctxcsn.bv_val );
+                       ber_dupbv( &si->si_syncCookie.ctxcsn, csn );
+                       ber_bvarray_free_x( csn, op->o_tmpmemctx );
+               }
 
-               if ( !cookie ) {
-                       /* no stored cookie */
-                       if ( sc->ctxcsn == NULL ||
-                                BER_BVISNULL( sc->ctxcsn ) ) {
+               si->si_syncCookie.rid = si->si_rid;
+
+               LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) {
+                       if ( si->si_rid == sc->rid ) {
+                               cmdline_cookie_found = 1;
+                               break;
+                       }
+               }
+
+               if ( cmdline_cookie_found ) {
+                       /* cookie is supplied in the command line */
+
+                       LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
+
+                       if ( BER_BVISNULL( &sc->ctxcsn ) ) {
                                /* if cmdline cookie does not have ctxcsn */
                                /* component, set it to an initial value */
                                slap_init_sync_cookie_ctxcsn( sc );
                        }
+                       slap_sync_cookie_free( &si->si_syncCookie, 0 );
                        slap_dup_sync_cookie( &si->si_syncCookie, sc );
                        slap_sync_cookie_free( sc, 1 );
-                       sc = NULL;
-
-               } else {
-                       /* stored cookie */
-                       struct berval newcookie = BER_BVNULL;
-                       ber_dupbv( &cookie_bv, &cookie[0] );
-                       ber_bvarray_add( &si->si_syncCookie.octet_str, &cookie_bv );
-                       slap_parse_sync_cookie( &si->si_syncCookie );
-                       ber_bvarray_free( si->si_syncCookie.octet_str );
-                       si->si_syncCookie.octet_str = NULL;
-                       ber_bvarray_free_x( cookie, op->o_tmpmemctx );
-                       if ( sc->sid != -1 ) {
-                               /* command line cookie wins */
-                               si->si_syncCookie.sid = sc->sid;
-                       }
-                       if ( sc->ctxcsn != NULL ) {
-                               /* command line cookie wins */
-                               if ( si->si_syncCookie.ctxcsn ) {
-                                       ber_bvarray_free( si->si_syncCookie.ctxcsn );
-                                       si->si_syncCookie.ctxcsn = NULL;
-                               }
-                               ber_dupbv( &cookie_bv, &sc->ctxcsn[0] );
-                               ber_bvarray_add( &si->si_syncCookie.ctxcsn, &cookie_bv );
-                       }
-                       if ( sc->rid != -1 ) {
-                               /* command line cookie wins */
-                               si->si_syncCookie.rid = sc->rid;
-                       }
-                       slap_sync_cookie_free( sc, 1 );
-                       sc = NULL;
-                       slap_compose_sync_cookie( NULL, &newcookie,
-                                       &si->si_syncCookie.ctxcsn[0],
-                                       si->si_syncCookie.sid, si->si_syncCookie.rid );
-                       ber_bvarray_add( &si->si_syncCookie.octet_str, &newcookie );
                }
 
-       } else {
-               /* no command line cookie is specified */
-               if ( si->si_syncCookie.octet_str == NULL ) {
-                       BerVarray cookie = NULL;
-                       struct berval cookie_bv;
-                       /* try to read stored cookie */
-                       backend_attribute( op, NULL, &op->o_req_ndn,
-                               slap_schema.si_ad_syncreplCookie, &cookie, ACL_READ );
-                       if ( cookie ) {
-                               ber_dupbv( &cookie_bv, &cookie[0] );
-                               ber_bvarray_add( &si->si_syncCookie.octet_str, &cookie_bv );
-                               slap_parse_sync_cookie( &si->si_syncCookie );
-                               ber_bvarray_free_x( cookie, op->o_tmpmemctx );
-                       }
-               }
+               slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
+                       &si->si_syncCookie.ctxcsn, si->si_syncCookie.rid );
        }
 
        rc = ldap_sync_search( si, op->o_tmpmemctx );
@@ -501,8 +449,6 @@ done:
                }
        }
 
-       slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-
        return rc;
 }
 
@@ -527,8 +473,8 @@ do_syncrep2(
 
        int             syncstate;
        struct berval   syncUUID = BER_BVNULL;
-       struct sync_cookie      syncCookie = { NULL, -1, NULL };
-       struct sync_cookie      syncCookie_req = { NULL, -1, NULL };
+       struct sync_cookie      syncCookie = { 0 };
+       struct sync_cookie      syncCookie_req = { 0 };
        struct berval           cookie = BER_BVNULL;
 
        int     rc, err, i;
@@ -598,12 +544,10 @@ do_syncrep2(
                                if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE ) {
                                        ber_scanf( ber, /*"{"*/ "m}", &cookie );
                                        if ( !BER_BVISNULL( &cookie ) ) {
-                                               struct berval tmp_bv;
-                                               ber_dupbv( &tmp_bv, &cookie );
-                                               ber_bvarray_add( &syncCookie.octet_str, &tmp_bv );
+                                               ch_free( syncCookie.octet_str.bv_val );
+                                               ber_dupbv( &syncCookie.octet_str, &cookie );
                                        }
-                                       if ( syncCookie.octet_str &&
-                                                       !BER_BVISNULL( &syncCookie.octet_str[0] ) )
+                                       if ( !BER_BVISNULL( &syncCookie.octet_str ) )
                                        {
                                                slap_parse_sync_cookie( &syncCookie );
                                        }
@@ -611,9 +555,8 @@ do_syncrep2(
                                if ( syncrepl_message_to_entry( si, op, msg,
                                        &modlist, &entry, syncstate ) == LDAP_SUCCESS ) {
                                        rc_efree = syncrepl_entry( si, op, entry, &modlist,
-                                               syncstate, &syncUUID, &syncCookie_req, syncCookie.ctxcsn );
-                                       if ( syncCookie.octet_str &&
-                                               !BER_BVISNULL( &syncCookie.octet_str[0] ) )
+                                               syncstate, &syncUUID, &syncCookie_req, &syncCookie.ctxcsn );
+                                       if ( !BER_BVISNULL( &syncCookie.octet_str ) )
                                        {
                                                syncrepl_updateCookie( si, op, psub, &syncCookie );
                                        }
@@ -646,12 +589,10 @@ do_syncrep2(
                                        if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE ) {
                                                ber_scanf( ber, "m", &cookie );
                                                if ( !BER_BVISNULL( &cookie ) ) {
-                                                       struct berval tmp_bv;
-                                                       ber_dupbv( &tmp_bv, &cookie );
-                                                       ber_bvarray_add( &syncCookie.octet_str, &tmp_bv);
+                                                       ch_free( syncCookie.octet_str.bv_val );
+                                                       ber_dupbv( &syncCookie.octet_str, &cookie);
                                                }
-                                               if ( syncCookie.octet_str &&
-                                                       !BER_BVISNULL( &syncCookie.octet_str[0] ) )
+                                               if ( !BER_BVISNULL( &syncCookie.octet_str ) )
                                                {
                                                        slap_parse_sync_cookie( &syncCookie );
                                                }
@@ -662,18 +603,18 @@ do_syncrep2(
                                        }
                                        ber_scanf( ber, /*"{"*/ "}" );
                                }
-                               if ( syncCookie_req.ctxcsn == NULL ) {
+                               if ( BER_BVISNULL( &syncCookie_req.ctxcsn )) {
                                        match = -1;
-                               } else if ( syncCookie.ctxcsn == NULL ) {
+                               } else if ( BER_BVISNULL( &syncCookie.ctxcsn )) {
                                        match = 1;
                                } else {
                                        value_match( &match, slap_schema.si_ad_entryCSN,
                                                slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
                                                SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                               &syncCookie_req.ctxcsn[0], &syncCookie.ctxcsn[0],
+                                               &syncCookie_req.ctxcsn, &syncCookie.ctxcsn,
                                                &text );
                                }
-                               if ( syncCookie.octet_str && !BER_BVISNULL( syncCookie.octet_str ) &&
+                               if ( !BER_BVISNULL( &syncCookie.octet_str ) &&
                                        match < 0 && err == LDAP_SUCCESS )
                                {
                                        syncrepl_updateCookie( si, op, psub, &syncCookie );
@@ -732,13 +673,10 @@ do_syncrep2(
                                                {
                                                        ber_scanf( ber, "m", &cookie );
                                                        if ( !BER_BVISNULL( &cookie ) ) {
-                                                               struct berval tmp_bv;
-                                                               ber_dupbv( &tmp_bv, &cookie );
-                                                               ber_bvarray_add( &syncCookie.octet_str,
-                                                                       &tmp_bv);
+                                                               ch_free( syncCookie.octet_str.bv_val );
+                                                               ber_dupbv( &syncCookie.octet_str, &cookie );
                                                        }
-                                                       if ( syncCookie.octet_str &&
-                                                               !BER_BVISNULL( &syncCookie.octet_str[0] ) )
+                                                       if ( !BER_BVISNULL( &syncCookie.octet_str ) )
                                                        {
                                                                slap_parse_sync_cookie( &syncCookie );
                                                        }
@@ -762,13 +700,10 @@ do_syncrep2(
                                                {
                                                        ber_scanf( ber, "m", &cookie );
                                                        if ( !BER_BVISNULL( &cookie ) ) {
-                                                               struct berval tmp_bv;
-                                                               ber_dupbv( &tmp_bv, &cookie );
-                                                               ber_bvarray_add( &syncCookie.octet_str,
-                                                                       &tmp_bv );
+                                                               ch_free( syncCookie.octet_str.bv_val );
+                                                               ber_dupbv( &syncCookie.octet_str, &cookie );
                                                        }
-                                                       if ( syncCookie.octet_str &&
-                                                                       !BER_BVISNULL( &syncCookie.octet_str[0] ) )
+                                                       if ( !BER_BVISNULL( &syncCookie.octet_str ) )
                                                        {
                                                                slap_parse_sync_cookie( &syncCookie );
                                                        }
@@ -804,19 +739,19 @@ do_syncrep2(
                                                continue;
                                        }
 
-                                       if ( syncCookie_req.ctxcsn == NULL ) {
+                                       if ( BER_BVISNULL( &syncCookie_req.ctxcsn )) {
                                                match = -1;
-                                       } else if ( syncCookie.ctxcsn == NULL ) {
+                                       } else if ( BER_BVISNULL( &syncCookie.ctxcsn )) {
                                                match = 1;
                                        } else {
                                                value_match( &match, slap_schema.si_ad_entryCSN,
                                                        slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
                                                        SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                                       &syncCookie_req.ctxcsn[0],
-                                                       &syncCookie.ctxcsn[0], &text );
+                                                       &syncCookie_req.ctxcsn,
+                                                       &syncCookie.ctxcsn, &text );
                                        }
 
-                                       if ( syncCookie.ctxcsn && !BER_BVISNULL( &syncCookie.ctxcsn[0] ) &&
+                                       if ( !BER_BVISNULL( &syncCookie.ctxcsn ) &&
                                                match < 0 )
                                        {
                                                syncrepl_updateCookie( si, op, psub, &syncCookie);
@@ -848,7 +783,7 @@ do_syncrep2(
                                break;
 
                        }
-                       if ( syncCookie.octet_str ) {
+                       if ( !BER_BVISNULL( &syncCookie.octet_str )) {
                                slap_sync_cookie_free( &syncCookie_req, 0 );
                                slap_dup_sync_cookie( &syncCookie_req, &syncCookie );
                                slap_sync_cookie_free( &syncCookie, 0 );
@@ -929,10 +864,10 @@ do_syncrepl(
        op->o_tmpmemctx = NULL;
        op->o_tmpmfuncs = &ch_mfuncs;
 
-       op->o_dn = si->si_updatedn;
-       op->o_ndn = si->si_updatedn;
        op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
        op->o_bd = be = si->si_be;
+       op->o_dn = op->o_bd->be_rootdn;
+       op->o_ndn = op->o_bd->be_rootndn;
 
        /* Establish session, do search */
        if ( !si->si_ld ) {
@@ -1002,8 +937,6 @@ do_syncrepl(
 
                if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) {
                        ldap_pvt_runqueue_remove( &slapd_rq, rtask );
-                       LDAP_STAILQ_REMOVE( &be->be_syncinfo, si, syncinfo_s, si_next );
-                       syncinfo_free( si );
                } else if ( si->si_retrynum[i] >= -1 ) {
                        if ( si->si_retrynum[i] > 0 )
                                si->si_retrynum[i]--;
@@ -1215,11 +1148,6 @@ syncrepl_entry(
        int ret = LDAP_SUCCESS;
 
        struct berval pdn = BER_BVNULL;
-       struct berval org_req_dn = BER_BVNULL;
-       struct berval org_req_ndn = BER_BVNULL;
-       struct berval org_dn = BER_BVNULL;
-       struct berval org_ndn = BER_BVNULL;
-       int     org_managedsait;
        dninfo dni = {0};
        int     retry = 1;
 
@@ -1273,12 +1201,13 @@ syncrepl_entry(
        ava.aa_value = *syncUUID;
        op->ors_filter = &f;
 
-       op->ors_filterstr.bv_len = STRLENOF( "entryUUID=" ) + syncUUID->bv_len;
+       op->ors_filterstr.bv_len = STRLENOF( "(entryUUID=)" ) + syncUUID->bv_len;
        op->ors_filterstr.bv_val = (char *) slap_sl_malloc(
                op->ors_filterstr.bv_len + 1, op->o_tmpmemctx ); 
-       AC_MEMCPY( op->ors_filterstr.bv_val, "entryUUID=", STRLENOF( "entryUUID=" ) );
-       AC_MEMCPY( &op->ors_filterstr.bv_val[STRLENOF( "entryUUID=" )],
+       AC_MEMCPY( op->ors_filterstr.bv_val, "(entryUUID=", STRLENOF( "(entryUUID=" ) );
+       AC_MEMCPY( &op->ors_filterstr.bv_val[STRLENOF( "(entryUUID=" )],
                syncUUID->bv_val, syncUUID->bv_len );
+       op->ors_filterstr.bv_val[op->ors_filterstr.bv_len - 1] = ')';
        op->ors_filterstr.bv_val[op->ors_filterstr.bv_len] = '\0';
 
        op->o_tag = LDAP_REQ_SEARCH;
@@ -1315,7 +1244,7 @@ syncrepl_entry(
        cb.sc_response = null_callback;
        cb.sc_private = si;
 
-       if ( entry && entry->e_name.bv_val ) {
+       if ( entry && !BER_BVISNULL( &entry->e_name ) ) {
                Debug( LDAP_DEBUG_SYNC,
                                "syncrepl_entry: %s\n",
                                entry->e_name.bv_val, 0, 0 );
@@ -1325,19 +1254,23 @@ syncrepl_entry(
                                dni.dn.bv_val ? dni.dn.bv_val : "(null)", 0, 0 );
        }
 
-       org_req_dn = op->o_req_dn;
-       org_req_ndn = op->o_req_ndn;
-       org_dn = op->o_dn;
-       org_ndn = op->o_ndn;
-       org_managedsait = get_manageDSAit( op );
-       op->o_dn = op->o_bd->be_rootdn;
-       op->o_ndn = op->o_bd->be_rootndn;
-       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
-
        if ( syncstate != LDAP_SYNC_DELETE ) {
-               attr_delete( &entry->e_attrs, slap_schema.si_ad_entryUUID );
-               attr_merge_one( entry, slap_schema.si_ad_entryUUID,
-                       &syncUUID_strrep, syncUUID );
+               Attribute       *a = attr_find( entry->e_attrs, slap_schema.si_ad_entryUUID );
+
+               if ( a == NULL ) {
+                       /* add if missing */
+                       attr_merge_one( entry, slap_schema.si_ad_entryUUID,
+                               &syncUUID_strrep, syncUUID );
+
+               } else if ( !bvmatch( &a->a_nvals[0], syncUUID ) ) {
+                       /* replace only if necessary */
+                       if ( a->a_nvals != a->a_vals ) {
+                               ber_memfree( a->a_nvals[0].bv_val );
+                               ber_dupbv( &a->a_nvals[0], syncUUID );
+                       }
+                       ber_memfree( a->a_vals[0].bv_val );
+                       ber_dupbv( &a->a_vals[0], &syncUUID_strrep );
+               }
        }
 
        switch ( syncstate ) {
@@ -1457,11 +1390,11 @@ retry_add:;
                        assert( *modlist );
 
                        /* Delete all the old attrs */
-                       for ( i=0; i<dni.attrs; i++) {
-                               mod = ch_malloc( sizeof(Modifications));
+                       for ( i = 0; i < dni.attrs; i++ ) {
+                               mod = ch_malloc( sizeof( Modifications ) );
                                mod->sml_op = LDAP_MOD_DELETE;
                                mod->sml_desc = dni.ads[i];
-                               mod->sml_type =mod->sml_desc->ad_cname;
+                               mod->sml_type = mod->sml_desc->ad_cname;
                                mod->sml_values = NULL;
                                mod->sml_nvalues = NULL;
                                if ( !modhead ) modhead = mod;
@@ -1583,19 +1516,11 @@ syncrepl_del_nonpresent(
        SlapReply       rs_modify = {REP_RESULT};
        struct nonpresent_entry *np_list, *np_prev;
        int rc;
-       Modifications *ml;
-       Modifications *mlnext;
-       Modifications *mod;
-       Modifications *modlist = NULL;
-       Modifications **modtail;
        AttributeName   an[2];
 
        struct berval pdn = BER_BVNULL;
        struct berval org_req_dn = BER_BVNULL;
        struct berval org_req_ndn = BER_BVNULL;
-       struct berval org_dn = BER_BVNULL;
-       struct berval org_ndn = BER_BVNULL;
-       int     org_managedsait;
 
        op->o_req_dn = si->si_base;
        op->o_req_ndn = si->si_base;
@@ -1620,7 +1545,6 @@ syncrepl_del_nonpresent(
                op->ors_attrs = slap_anlist_no_attrs;
                op->ors_limit = NULL;
                op->ors_filter = &uf;
-               op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 
                uf.f_ava = &eq;
                uf.f_av_desc = slap_schema.si_ad_entryUUID;
@@ -1644,7 +1568,6 @@ syncrepl_del_nonpresent(
                op->ors_filter = str2filter_x( op, si->si_filterstr.bv_val );
                op->ors_filterstr = si->si_filterstr;
                op->o_nocaching = 1;
-               op->o_managedsait = SLAP_CONTROL_NONE;
 
                if ( limits_check( op, &rs_search ) == 0 ) {
                        rc = be->be_search( op, &rs_search );
@@ -1652,10 +1575,12 @@ syncrepl_del_nonpresent(
                if ( op->ors_filter ) filter_free_x( op, op->ors_filter );
        }
 
-       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
        op->o_nocaching = 0;
 
        if ( !LDAP_LIST_EMPTY( &si->si_nonpresentlist ) ) {
+
+               slap_queue_csn( op, &si->si_syncCookie.ctxcsn );
+
                np_list = LDAP_LIST_FIRST( &si->si_nonpresentlist );
                while ( np_list != NULL ) {
                        LDAP_LIST_REMOVE( np_list, npe_link );
@@ -1670,43 +1595,27 @@ syncrepl_del_nonpresent(
                        rc = op->o_bd->be_delete( op, &rs_delete );
 
                        if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
-                               modtail = &modlist;
-                               mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-                               mod->sml_op = LDAP_MOD_REPLACE;
-                               mod->sml_desc = slap_schema.si_ad_objectClass;
-                               mod->sml_type = mod->sml_desc->ad_cname;
-                               mod->sml_values = &gcbva[0];
-                               *modtail = mod;
-                               modtail = &mod->sml_next;
-
-                               mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-                               mod->sml_op = LDAP_MOD_REPLACE;
-                               mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
-                               mod->sml_type = mod->sml_desc->ad_cname;
-                               mod->sml_values = &gcbva[1];
-                               *modtail = mod;
-                               modtail = &mod->sml_next;
+                               Modifications mod1, mod2;
+                               mod1.sml_op = LDAP_MOD_REPLACE;
+                               mod1.sml_desc = slap_schema.si_ad_objectClass;
+                               mod1.sml_type = mod1.sml_desc->ad_cname;
+                               mod1.sml_values = &gcbva[0];
+                               mod1.sml_nvalues = NULL;
+                               mod1.sml_next = &mod2;
+
+                               mod2.sml_op = LDAP_MOD_REPLACE;
+                               mod2.sml_desc = slap_schema.si_ad_structuralObjectClass;
+                               mod2.sml_type = mod2.sml_desc->ad_cname;
+                               mod2.sml_values = &gcbva[1];
+                               mod2.sml_nvalues = NULL;
+                               mod2.sml_next = NULL;
 
                                op->o_tag = LDAP_REQ_MODIFY;
-                               op->orm_modlist = modlist;
+                               op->orm_modlist = &mod1;
 
                                rc = be->be_modify( op, &rs_modify );
-
-                               for ( ml = modlist; ml != NULL; ml = mlnext ) {
-                                       mlnext = ml->sml_next;
-                                       free( ml );
-                               }
                        }
 
-                       org_req_dn = op->o_req_dn;
-                       org_req_ndn = op->o_req_ndn;
-                       org_dn = op->o_dn;
-                       org_ndn = op->o_ndn;
-                       org_managedsait = get_manageDSAit( op );
-                       op->o_dn = op->o_bd->be_rootdn;
-                       op->o_ndn = op->o_bd->be_rootndn;
-                       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
-
                        while ( rs_delete.sr_err == LDAP_SUCCESS &&
                                        op->o_delete_glue_parent ) {
                                op->o_delete_glue_parent = 0;
@@ -1724,19 +1633,14 @@ syncrepl_del_nonpresent(
                            }
                        }
 
-                       op->o_managedsait = org_managedsait;
-                       op->o_dn = org_dn;
-                       op->o_ndn = org_ndn;
-                       op->o_req_dn = org_req_dn;
-                       op->o_req_ndn = org_req_ndn;
                        op->o_delete_glue_parent = 0;
 
                        ber_bvfree( np_prev->npe_name );
                        ber_bvfree( np_prev->npe_nname );
-                       BER_BVZERO( &op->o_req_dn );
-                       BER_BVZERO( &op->o_req_ndn );
                        ch_free( np_prev );
                }
+
+               slap_graduate_commit_csn( op );
        }
 
        return;
@@ -1870,28 +1774,6 @@ syncrepl_add_glue(
        return;
 }
 
-static struct berval ocbva[] = {
-       BER_BVC("top"),
-       BER_BVC("subentry"),
-       BER_BVC("syncConsumerSubentry"),
-       BER_BVNULL
-};
-
-static struct berval cnbva[] = {
-       BER_BVNULL,
-       BER_BVNULL
-};
-
-static struct berval ssbva[] = {
-       BER_BVC("{}"),
-       BER_BVNULL
-};
-
-static struct berval scbva[] = {
-       BER_BVNULL,
-       BER_BVNULL
-};
-
 void
 syncrepl_updateCookie(
        syncinfo_t *si,
@@ -1900,210 +1782,59 @@ syncrepl_updateCookie(
        struct sync_cookie *syncCookie )
 {
        Backend *be = op->o_bd;
-       Modifications *ml;
-       Modifications *mlnext;
-       Modifications *mod;
-       Modifications *modlist = NULL;
-       Modifications **modtail = &modlist;
+       Modifications mod = {0};
+       struct berval vals[2];
 
        const char      *text;
        char txtbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof txtbuf;
 
-       Entry* e = NULL;
        int rc;
 
-       char syncrepl_cbuf[sizeof(CN_STR SYNCREPL_STR)];
-       struct berval slap_syncrepl_dn_bv = BER_BVNULL;
-       struct berval slap_syncrepl_cn_bv = BER_BVNULL;
-       
        slap_callback cb = { NULL };
-       SlapReply       rs_add = {REP_RESULT};
        SlapReply       rs_modify = {REP_RESULT};
 
        slap_sync_cookie_free( &si->si_syncCookie, 0 );
        slap_dup_sync_cookie( &si->si_syncCookie, syncCookie );
 
-       mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-       mod->sml_op = LDAP_MOD_REPLACE;
-       mod->sml_desc = slap_schema.si_ad_objectClass;
-       mod->sml_type = mod->sml_desc->ad_cname;
-       mod->sml_values = ocbva;
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       ber_dupbv( &cnbva[0], (struct berval *) &slap_syncrepl_bvc );
-       assert( si->si_rid < 1000 );
-       cnbva[0].bv_len = snprintf( cnbva[0].bv_val,
-               slap_syncrepl_bvc.bv_len + 1,
-               "syncrepl%ld", si->si_rid );
-       mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-       mod->sml_op = LDAP_MOD_REPLACE;
-       mod->sml_desc = slap_schema.si_ad_cn;
-       mod->sml_type = mod->sml_desc->ad_cname;
-       mod->sml_values = cnbva;
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-       mod->sml_op = LDAP_MOD_REPLACE;
-       mod->sml_desc = slap_schema.si_ad_subtreeSpecification;
-       mod->sml_type = mod->sml_desc->ad_cname;
-       mod->sml_values = ssbva;
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       /* Keep this last, so we can avoid touching the previous
-        * attributes unnecessarily.
-        */
-       if ( scbva[0].bv_val ) ch_free( scbva[0].bv_val );
-       ber_dupbv( &scbva[0], &si->si_syncCookie.octet_str[0] );
-       mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
-       mod->sml_op = LDAP_MOD_REPLACE;
-       mod->sml_desc = slap_schema.si_ad_syncreplCookie;
-       mod->sml_type = mod->sml_desc->ad_cname;
-       mod->sml_values = scbva;
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       slap_queue_csn( op, si->si_syncCookie.ctxcsn );
-
-       mlnext = mod;
+       mod.sml_op = LDAP_MOD_REPLACE;
+       mod.sml_desc = slap_schema.si_ad_contextCSN;
+       mod.sml_type = mod.sml_desc->ad_cname;
+       mod.sml_values = vals;
+       vals[0] = si->si_syncCookie.ctxcsn;
+       vals[1].bv_val = NULL;
+       vals[1].bv_len = 0;
 
-       op->o_tag = LDAP_REQ_ADD;
-       rc = slap_mods_opattrs( op, modlist, modtail,
-                &text, txtbuf, textlen, 0 );
-
-       for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
-               ml->sml_op = LDAP_MOD_REPLACE;
-       }
+       slap_queue_csn( op, &si->si_syncCookie.ctxcsn );
 
-       if( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods opattrs (%s)\n",
-                        text, 0, 0 );
-       }
-
-       e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
+       op->o_tag = LDAP_REQ_MODIFY;
 
-       slap_syncrepl_cn_bv.bv_val = syncrepl_cbuf;
        assert( si->si_rid < 1000 );
-       slap_syncrepl_cn_bv.bv_len = snprintf( slap_syncrepl_cn_bv.bv_val,
-               slap_syncrepl_cn_bvc.bv_len + 1,
-               "cn=syncrepl%ld", si->si_rid );
-
-       build_new_dn( &slap_syncrepl_dn_bv, pdn, &slap_syncrepl_cn_bv,
-               op->o_tmpmemctx );
-       ber_dupbv( &e->e_name, &slap_syncrepl_dn_bv );
-       ber_dupbv( &e->e_nname, &slap_syncrepl_dn_bv );
-
-       if ( !BER_BVISNULL( &slap_syncrepl_dn_bv ) ) {
-               slap_sl_free( slap_syncrepl_dn_bv.bv_val, op->o_tmpmemctx );
-       }
-
-       e->e_attrs = NULL;
-
-       rc = slap_mods2entry( modlist, &e, 1, 1, &text, txtbuf, textlen );
-
-       if( rc != LDAP_SUCCESS ) {
-               Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods2entry (%s)\n",
-                        text, 0, 0 );
-       }
 
        cb.sc_response = null_callback;
        cb.sc_private = si;
 
        op->o_callback = &cb;
-       op->o_req_dn = e->e_name;
-       op->o_req_ndn = e->e_nname;
+       op->o_req_dn = op->o_bd->be_suffix[0];
+       op->o_req_ndn = op->o_bd->be_nsuffix[0];
 
-       /* update persistent cookie */
-update_cookie_retry:
-       op->o_tag = LDAP_REQ_MODIFY;
-       /* Just modify the cookie value, not the entire entry */
-       op->orm_modlist = mod;
+       /* update contextCSN */
+       op->o_msgid = SLAP_SYNC_UPDATE_MSGID;
+       op->orm_modlist = &mod;
        rc = be->be_modify( op, &rs_modify );
+       op->o_msgid = 0;
 
        if ( rs_modify.sr_err != LDAP_SUCCESS ) {
-               if ( rs_modify.sr_err == LDAP_REFERRAL ||
-                        rs_modify.sr_err == LDAP_NO_SUCH_OBJECT ) {
-                       op->o_tag = LDAP_REQ_ADD;
-                       op->ora_e = e;
-                       rc = be->be_add( op, &rs_add );
-                       if ( rs_add.sr_err != LDAP_SUCCESS ) {
-                               if ( rs_add.sr_err == LDAP_ALREADY_EXISTS ) {
-                                       goto update_cookie_retry;
-                               } else if ( rs_add.sr_err == LDAP_REFERRAL ||
-                                                       rs_add.sr_err == LDAP_NO_SUCH_OBJECT ) {
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "cookie will be non-persistent\n",
-                                               0, 0, 0 );
-                               } else {
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "be_add failed (%d)\n", rs_add.sr_err, 0, 0 );
-                               }
-                       } else {
-                               be_entry_release_w( op, e );
-                               goto done;
-                       }
-               } else {
-                       Debug( LDAP_DEBUG_ANY,
-                               "be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
-               }
-       }
-       if ( e != NULL ) {
-               entry_free( e );
+               Debug( LDAP_DEBUG_ANY,
+                       "be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
        }
 
 done :
        slap_graduate_commit_csn( op );
 
-
-       if ( !BER_BVISNULL( &cnbva[0] ) ) {
-               ch_free( cnbva[0].bv_val );
-               BER_BVZERO( &cnbva[0] );
-       }
-       if ( !BER_BVISNULL( &scbva[0] ) ) {
-               ch_free( scbva[0].bv_val );
-               BER_BVZERO( &scbva[0] );
-       }
-
-       if ( mlnext->sml_next ) {
-               slap_mods_free( mlnext->sml_next );
-               mlnext->sml_next = NULL;
-       }
-
-       for (ml = modlist ; ml != NULL; ml = mlnext ) {
-               mlnext = ml->sml_next;
-               free( ml );
-       }
-
        return;
 }
 
-int
-syncrepl_isupdate( Operation *op )
-{
-       return ( syncrepl_isupdate_dn( op->o_bd, &op->o_ndn ));
-}
-
-int
-syncrepl_isupdate_dn(
-       Backend*                be,
-       struct berval*  ndn )
-{
-       syncinfo_t*     si;
-       int                     ret = 0;
-
-       if ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
-               LDAP_STAILQ_FOREACH( si, &be->be_syncinfo, si_next ) {
-                       if ( ( ret = dn_match( &si->si_updatedn, ndn ) ) ) {
-                               return ret;
-                       }
-               }
-       }
-       return 0;
-}
-
 static int
 dn_callback(
        Operation*      op,
@@ -2262,40 +1993,6 @@ null_callback(
        return LDAP_SUCCESS;
 }
 
-Entry *
-slap_create_syncrepl_entry(
-       Backend *be,
-       struct berval *context_csn,
-       struct berval *rdn,
-       struct berval *cn )
-{
-       Entry* e;
-
-       struct berval bv;
-
-       e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
-
-       attr_merge( e, slap_schema.si_ad_objectClass, ocbva, NULL );
-
-       attr_merge_one( e, slap_schema.si_ad_structuralObjectClass,
-               &ocbva[1], NULL );
-
-       attr_merge_one( e, slap_schema.si_ad_cn, cn, NULL );
-
-       if ( context_csn ) {
-               attr_merge_one( e, slap_schema.si_ad_syncreplCookie,
-                       context_csn, NULL );
-       }
-
-       BER_BVSTR( &bv, "{}" );
-       attr_merge_one( e, slap_schema.si_ad_subtreeSpecification, &bv, NULL );
-
-       build_new_dn( &e->e_name, &be->be_nsuffix[0], rdn, NULL );
-       ber_dupbv( &e->e_nname, &e->e_name );
-
-       return e;
-}
-
 struct berval *
 slap_uuidstr_from_normalized(
        struct berval* uuidstr,
@@ -2377,14 +2074,8 @@ avl_ber_bvfree( void *v_bv )
 void
 syncinfo_free( syncinfo_t *sie )
 {
-       if ( sie->si_provideruri ) {
-               ch_free( sie->si_provideruri );
-       }
-       if ( sie->si_provideruri_bv ) {
-               ber_bvarray_free( sie->si_provideruri_bv );
-       }
-       if ( sie->si_updatedn.bv_val ) {
-               ch_free( sie->si_updatedn.bv_val );
+       if ( !BER_BVISNULL( &sie->si_provideruri ) ) {
+               ch_free( sie->si_provideruri.bv_val );
        }
        if ( sie->si_binddn ) {
                ch_free( sie->si_binddn );
index 92c1e0681f34be5d7ef5898d12d4a43103930750..0469e308cb9b2a64de156106d7b837252021e6ca 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 774253ef42083d5fa7b47f67c27ebd1600ba8b8a..4dec901ce9a2c4a0974a5c71f8ddfd84ed4c09a1 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 2de0ffd17c7e224d877c3f28b13d83b52e52e652..29aa25b4298e9f2f5fd05610e4f390c3f00da87c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 PM Lashley.
  * All rights reserved.
  *
index 7612dddd34d4e2b88f84f3ff5b55ec5f71a6f8e1..ebec9e348174b90c23b9ce1af187296a4c6e2fbd 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 14d2113f9a59762e0e76bc1df701545cb0726238..ff9a25bf5a971972aadb6a9ad8cf60bcc20bd3fe 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$*/
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index cb12a907daa48076eaf26f19a2f7cbab892437d7..b9fe96367b730e1cb2e16c1e395cd9444c428aa2 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index fef41a1dc68bf1c9661fe067ae4ea595946d3cc4..72c4c12d571784b6cfb9ce66f148f2803b208bf8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index f6a348a9c363000c18e883bfceda630e0a9c3baa..4faaadab552c0869a9dcb73c6ee852fc6d49274e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 033388bdf73382ac8b44da63b703332bce738962..18514dd0d93b3a50f0347b8a93c50c64b7322793 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index e767ee5ff59aba2c4d7d4a812df9a0f81c74b233..71934ce59efc95a1555eb6720e3063d7254a51c9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Mark Benson.
  * Portions Copyright 2002 John Morrissey.
  * All rights reserved.
index 16526493fe3af2488d9c71ec400214acfca3d59f..37a0954619695cf9cb08293ae205114774738ffe 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 222292affdfc3bb6aa1bfe8cd15ae1ff541c21cf..bf6ede6c779ae8363d2d801627b49b713caf7cfa 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 4296c44a9d8d2b2b4781f9c9010033b9579839c1..ea30a229216299ac44eab74c1828cbba462c9b09 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 7312056a661cdf8c50dbda56a606870b8bd56224..16d719867a43d5f4c739219789b719b842ea224b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 Mark Benson.
  * All rights reserved.
  *
@@ -103,9 +103,9 @@ do_ldap(
                        lderr = op_ldap_add( ri, re, errmsg, errfree );
                        if ( lderr != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY,
-                                       "Error: ldap_add_s failed adding \"%s\": %s\n",
-                                       *errmsg ? *errmsg : ldap_err2string( lderr ),
-                                       re->re_dn, 0 );
+                                       "Error: ldap_add_s failed adding DN \"%s\": %s\n",
+                                       re->re_dn, *errmsg && (*errmsg)[0] ?
+                                       *errmsg : ldap_err2string( lderr ), 0 );
                        }
                        break;
 
@@ -113,9 +113,9 @@ do_ldap(
                        lderr = op_ldap_modify( ri, re, errmsg, errfree );
                        if ( lderr != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY,
-                                       "Error: ldap_modify_s failed modifying \"%s\": %s\n",
-                                       *errmsg ? *errmsg : ldap_err2string( lderr ),
-                                       re->re_dn, 0 );
+                                       "Error: ldap_modify_s failed modifying DN \"%s\": %s\n",
+                                       re->re_dn, *errmsg && (*errmsg)[0] ?
+                                       *errmsg : ldap_err2string( lderr ), 0 );
                        }
                        break;
 
@@ -123,9 +123,9 @@ do_ldap(
                        lderr = op_ldap_delete( ri, re, errmsg, errfree );
                        if ( lderr != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY,
-                                       "Error: ldap_delete_s failed deleting \"%s\": %s\n",
-                                       *errmsg ? *errmsg : ldap_err2string( lderr ),
-                                       re->re_dn, 0 );
+                                       "Error: ldap_delete_s failed deleting DN \"%s\": %s\n",
+                                       re->re_dn, *errmsg && (*errmsg)[0] ?
+                                       *errmsg : ldap_err2string( lderr ), 0 );
                        }
                        break;
 
@@ -133,15 +133,15 @@ do_ldap(
                        lderr = op_ldap_modrdn( ri, re, errmsg, errfree );
                        if ( lderr != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY,
-                                       "Error: ldap_modrdn_s failed modifying %s: %s\n",
-                                       *errmsg ? *errmsg : ldap_err2string( lderr ),
-                                       re->re_dn, 0 );
+                                       "Error: ldap_modrdn_s failed modifying DN \"%s\": %s\n",
+                                       re->re_dn, *errmsg && (*errmsg)[0] ?
+                                       *errmsg : ldap_err2string( lderr ), 0 );
                        }
                        break;
 
                default:
                        Debug( LDAP_DEBUG_ANY,
-                               "Error: do_ldap: bad op \"%d\", dn = \"%s\"\n",
+                               "Error: do_ldap: bad op \"%d\", DN \"%s\"\n",
                                re->re_changetype, re->re_dn, 0 );
                        return DO_LDAP_ERR_FATAL;
                }
index 24feb7b73ac2c8a87c30a713dde7119550dff8a3..3ce58367d7ff9d4f201567875c1be80b7e32b272 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -91,11 +91,13 @@ lock_fclose(
     FILE       *lfp
 )
 {
+       int rc = fclose( fp );
+
        /* unlock */
        ldap_unlockf( fileno(lfp) );
        fclose( lfp );
 
-       return( fclose( fp ) );
+       return( rc );
 }
 
 
index d3522355b3617267ee536acf2f7dbc44cb6e3701..4984a6a50f8da9e4a9f34019a61fd959eb2c52d7 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 511eb379aef537f54b92ee91eed4d9cc21b539c5..c95a4b7b8a48cb55b1557e8ff435d4fd61527e9c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 845d179e82bc718861f2b14e1291070ea06a4bef..461afd96493ad7b46eb0166d98aff845d81f052d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 955b67b6177ce51ca864525567313b81cb79d61c..05fd60743c9479b217e8ae098ed159d6cc74b666 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 09fa86975553b4f8b910d15b64b97fc928d7a66d..9b872925a0f9100045dc560442200a069cd6866e 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 68429c3829bdcdabd1a542dc1655d80b49a21f73..8a1605e6169d7ae89098d03a556db3cfba84e8cc 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 460c4a124b69614aaba724dbddc4034e17d2482b..53a82f64e4ec6bf15809b16b370ccf727820d59a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index b4384e29289bcff5114034a387829c928725860a..32cdd184487ce5388d0da19a9705e03e463ca2af 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 810a6b78eca6a2e2eb292c70833f2a1dc465cea6..4649118000a0075b299be3757eb82c8537cbf223 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fd376c7ba56ab09f100ca244080426ba43d068eb..d6cdb090738a4a720da906c808e3d39e05869e2b 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index c796cc3c53a7a6b843503ff7c166a5e1ec611556..7be6016233ad73b1f045c150f21c1d1d1521f030 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index fa8d9029ee52aaed9518ba66e58020c844f21ce1..cb78c2d9c90b4a7d3cce6d8d687c242995befab7 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 0b664785ebf1103b2d8acd8267bf98be696bf46c..05f99d66d7c43fac17a93508bef4bd026ca767b6 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -63,5 +63,5 @@ clean-local:  FORCE
        -$(RM) -r testrun *leak *gmon *core
 
 veryclean-local: FORCE
-       @-$(RM) data schema ucdata
+       @-$(RM) run data schema ucdata
 
index b44d98cb136048cfd0a0b01ba33f99f10cc6b79f..ea2abb2317113e4ad36801ddde2759bbd72ae49b 100644 (file)
@@ -1,3 +1,7 @@
+# Try to read an entry inside the Alumni Association container.
+# It should give us noSuchObject if we're not bound...
+# ... and should return all attributes if we're bound as anyone
+# under Example.
 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
 objectClass: OpenLDAPperson
 cn: James A Jones 1
@@ -16,6 +20,7 @@ mail: jaj@mail.alumni.example.com
 facsimileTelephoneNumber: +1 313 555 4332
 telephoneNumber: +1 313 555 0895
 
+# Using ldapsearch to retrieve all the entries...
 dn: cn=All Staff,ou=Groups,dc=example,dc=com
 member: cn=Manager,dc=example,dc=com
 member: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=exam
diff --git a/tests/data/chain.out b/tests/data/chain.out
new file mode 100644 (file)
index 0000000..3d53473
--- /dev/null
@@ -0,0 +1,410 @@
+dn: cn=All Staff,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+member: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=exam
+ ple,dc=com
+member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc
+ =com
+member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=exa
+ mple,dc=com
+member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=exampl
+ e,dc=com
+owner: cn=Manager,dc=example,dc=com
+cn: All Staff
+description: Everyone in the sample data
+objectClass: groupOfNames
+
+dn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All Alumni Assoc Staff
+cn: Alumni Assoc Staff
+objectClass: groupOfNames
+
+dn: ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Alumni Association
+
+dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
+ dc=com
+objectClass: OpenLDAPperson
+cn: Barbara Jensen
+cn: Babs Jensen
+sn:: IEplbnNlbiA=
+uid: bjensen
+title: Mythical Manager, Research Systems
+postalAddress: ITD Prod Dev & Deployment $ 535 W. William St. Room 4212 $ Anyt
+ own, MI 48103-4943
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: YmplbnNlbg==
+mail: bjensen@mailgw.example.com
+homePostalAddress: 123 Wesley $ Anytown, MI 48103
+description: Mythical manager of the rsdd unix project
+drink: water
+homePhone: +1 313 555 2333
+pager: +1 313 555 3233
+facsimileTelephoneNumber: +1 313 555 2274
+telephoneNumber: +1 313 555 9022
+
+dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
+ =com
+objectClass: OpenLDAPperson
+cn: Bjorn Jensen
+cn: Biiff Jensen
+sn: Jensen
+uid: bjorn
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: Ympvcm4=
+homePostalAddress: 19923 Seven Mile Rd. $ South Lyon, MI 49999
+drink: Iced Tea
+description: Hiker, biker
+title: Director, Embedded Systems
+postalAddress: Info Tech Division $ 535 W. William St. $ Anytown, MI 48103
+mail: bjorn@mailgw.example.com
+homePhone: +1 313 555 5444
+pager: +1 313 555 4474
+facsimileTelephoneNumber: +1 313 555 2177
+telephoneNumber: +1 313 555 0355
+
+dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Dorothy Stevens
+cn: Dot Stevens
+sn: Stevens
+uid: dots
+title: Secretary, UM Alumni Association
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Lemonade
+homePostalAddress: 377 White St. Apt. 3 $ Anytown, MI 48104
+description: Very tall
+facsimileTelephoneNumber: +1 313 555 3223
+telephoneNumber: +1 313 555 3664
+mail: dots@mail.alumni.example.com
+homePhone: +1 313 555 0454
+
+dn: dc=example,dc=com
+objectClass: top
+objectClass: organization
+objectClass: domainRelatedObject
+objectClass: dcObject
+dc: example
+l: Anytown, Michigan
+st: Michigan
+o: Example, Inc.
+o: EX
+o: Ex.
+description: The Example, Inc. at Anytown
+postalAddress: Example, Inc. $ 535 W. William St. $ Anytown, MI 48109 $ US
+telephoneNumber: +1 313 555 1817
+associatedDomain: example.com
+
+dn: ou=Groups,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Groups
+
+dn: ou=Information Technology Division,ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Information Technology Division
+description:: aMODwoPDgsKCw4PCgsOCwotFVlZQw4PCg8OCwoPDg8KCw4LCv0zDg8KDw4LCgsOD
+ woLDgsKKT8ODwoPDgsKDw4PCgsOCwqs6w4PCg8OCwoLDg8KCw4LCjUQkw4PCg8OCwoLDg8KCw4LCi
+ 01QUcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4
+ LCgsODwoLDgsKLRCQoZitEJMODwoPDgsKCw4PCgsOCwrfDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoP
+ Dg8KCw4LCgcODwoPDgsKDw4PCgsOCwqHDg8KDw4LCgsODwoLDgsKLRCQkZitEJMODwoPDgsKCw4PC
+ gsOCwrfDg8KDw4LCg8ODwoLDgsKQw4PCg8OCwoPDg8KCw4LCisODwoPDgsKCw4PCgsOCwotFUVZqU
+ MODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKAw4PCg8OCwoLDg8KCw4LCik85dCTDg8KDw4
+ LCgsODwoLDgsKFQ8ODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4L
+ Cvzl0JMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPD
+ gsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKLRCTDg8KDw4LCgsODwoLDgsKDw4PCg8OCwoLDg8KCw
+ 4LCuMODwoPDgsKDw4PCgsOCwoR0Q8ODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LChMODwo
+ PDgsKDw4PCgsOCwoFOdTrDg8KDw4LCg8ODwoLDgsKHw4PCg8OCwoPDg8KCw4LChMODwoPDgsKDw4P
+ CgsOCwoFOw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwrtHw4PCg8OCwoLDg8KCw4LChcOD
+ woPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsK4dMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODw
+ oLDgsKtR8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwo
+ PDgsKDw4PCgsOCwr9SfGrDg8KDw4LCgsODwoLDgsKLQGgxw4PCg8OCwoPDg8KCw4LCoWhQw4PCg8O
+ CwoPDg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKT8ODwoPDgsKCw4PCgsOC
+ wotEJDDDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHTDg8KDw4LCgsODwoLDgsKDw4PCg
+ 8OCwoPDg8KCw4LCuHXDg8KDw4LCgsODwoLDgsKLRCRqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4
+ PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpPDg8K
+ Dw4LCg8ODwoLDgsKQXV9eW8ODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoPD
+ g8KCw4LCgsODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODw
+ oPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgs
+ OCwoxWV8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKxw4PCg8OCwoLDg8KCw4LCi3wkw4P
+ Cg8OCwoLDg8KCw4LCjcODwoPDgsKCw4PCgsOCwofDg8KDw4LCg8ODwoLDgsKof8ODwoPDgsKDw4PC
+ gsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCg8ODwoPDgsKDw4PCgsOCwrh5w4PCg
+ 8OCwoLDg8KCw4LChzQzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PCgsOCworDg8KDw4LCgsODwo
+ LDgsKIw4PCg8OCwoLDg8KCw4LCuDFBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNdDF
+ Bw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPD
+ gsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw
+ 4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgs
+ KCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKAdcODwoPDgsKDw4PCgsOCwqhtw4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCsMODwoPDgsKC
+ w4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCt
+ sODwoPDgsKDw4PCgsOCwq7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4
+ PCgsOCwoPDg8KDw4LCg8ODwoLDgsKoZsODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4w4P
+ Cg8OCwoLDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwpUzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PC
+ gsOCworDg8KDw4LCgsODwoLDgsKISDJBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNN
+ DJBw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwo
+ PDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8O
+ DwoPDgsKDw4PCgsOCwojDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCnEzDg8KDw4LCgsOD
+ woLDgsKLSEBmw4PCg8OCwoLDg8KCw4LCg3lwdSTDg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw
+ 4LCv8ODwoPDgsKCw4PCgsOCwobDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwp/Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwoj
+ Dg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCwpPDg8KDw4LCgsOD
+ woLDgsKBw4PCg8OCwoPDg8KCw4LCv1rDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODw
+ oPDgsKCw4PCgsOCwodqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwoBqaMODwoPDgsKCw4
+ PCgsOCwpBQw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDIMODwoPDgsKCw4PCgsOCwopPw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKOacODwoPDgsKCw4PCgsOCwrhf
+ XsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCw
+ oLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKGw4PCg8OCwoLDg8KCw4LCgM
+ ODwoPDgsKCw4PCgsOCwoRJw4PCg8OCwoLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsO
+ DwoLDgsKIw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQ9w4PCg8OCwoLDg8KCw4LCgcOD
+ woPDgsKDw4PCgsOCwr9aw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQxw4PCg8OCwoLDg
+ 8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LCm0
+ 7Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsK
+ Cw4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODw
+ oPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgs
+ OCwo7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCkMODwoPDgsKDw4PCgsOCwojDg8KDw4L
+ CgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsK+
+ S8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKww4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDw
+ 4PCgsOCwoTDg8KDw4LCgsODwoLDgsKKT1DDg8KDw4LCg8ODwoLDgsKoRsODwoPDgsKCw4PCgsOCwo
+ vDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwrZ0Y8ODwoPDgsK
+ Cw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/dF/Dg8KDw4LCgsODwoLDgsKhdHpPw4PCg8OCwoLDg8KC
+ w4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PCg8OCwoPDg8KCw4LCqC1Jw4PCg8OCwoLDg8KCw4LChcODw
+ oPDgsKDw4PCgsOCwoB1RMODwoPDgsKCw4PCgsOCwqFwek/Dg8KDw4LCgsODwoLDgsKLw4PCg8OCwo
+ PDg8KCw4LCj1DDg8KDw4LCg8ODwoLDgsKoScODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK
+ AdTPDg8KDw4LCgsODwoLDgsKhbHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PC
+ g8OCwoPDg8KCw4LCqEnDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHXDg8KDw4LCgsODw
+ oLDgsKhaHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo9Qw4PCg8OCwoPDg8KCw4LCqM
+ ODwoPDgsKDw4PCgsOCwrpIw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoB1M8ODwoPDgsK
+ Dw4PCgsOCwoBfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgjPDg8KDw4LCg8ODwoLDgsKAX17Dg
+ 8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCg8ODwo
+ LDgsKoJ8ODwoPDgsKDw4PCgsOCwq3Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoP
+ DgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4aHU5w4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PC
+ gsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw
+ 4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgs
+ KIw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpLDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoB0IcODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKA
+ w4PCg8OCwoPDg8KCw4LCtMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKAdGbDg8KDw4LCg
+ sODwoLDgsKLQGY9dGY9dTPDg8KDw4LCg8ODwoLDgsKAX17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwo
+ LDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPDgsKDw4PCgsO
+ CwoIzw4PCg8OCwoPDg8KCw4LCgF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwovDg8KD
+ w4LCg8ODwoLDgsK/Ri9BUC9BRi9BWi9BZC9BWzBBZC9BZTBBZC9BZC9BbzBBZC9BeTBBw4PCg8OCw
+ oLDg8KCw4LCgzBBMUFhMUFrMUE=
+description:: UF7Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOC
+ wozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg
+ 8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCqFDDg8KDw4LCg8ODwoLDgsKpRsODwoPDgsKDw4PCgsOCwo
+ zDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8O
+ DwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKCw4PCgsOCwotEJCDDg8KDw4LCgsODwoLDgsKD
+ w4PCg8OCwoPDg8KCw4LCrMODwoPDgsKCw4PCgsOCwotUJCRTw4PCg8OCwoLDg8KCw4LCi1wkJFbDg
+ 8KDw4LCgsODwoLDgsKJTCRXVVBSU8ODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsKdT8ODwo
+ PDgsKCw4PCgsOCwoN8JDB1w4PCg8OCwoPDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8O
+ DwoLDgsKBTsODwoPDgsKDw4PCgsOCwqktw4PCg8OCwoLDg8KCw4LCg3wkMHTDg8KDw4LCgsODwoLD
+ gsKDfCQww4PCg8OCwoLDg8KCw4LChTPDg8KDw4LCg8ODwoLDgsK2OTXDg8KDw4LCg8ODwoLDgsKAw
+ 4PCg8OCwoPDg8KCw4LCgU7Dg8KDw4LCgsODwoLDgsKEIMODwoPDgsKCw4PCgsOCwqFIw4PCg8OCwo
+ PDg8KCw4LChU7Dg8KDw4LCgsODwoLDgsKJNcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8ODwoLDgsK
+ BTsODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKD
+ w4PCgsOCwr9TXMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw
+ 4LChMODwoPDgsKCw4PCgsOCwpHDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLIEjDg8
+ KDw4LCg8ODwoLDgsKFTlDDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ngw4PCg8OCwoL
+ Dg8KCw4LCi8ODwoPDgsKDw4PCgsOCwpjDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCm3Rx
+ w4PCg8OCwoLDg8KCw4LCizvDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi8ODwoPDgsKDw
+ 4PCgsOCwr9XaMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGdGLDg8KDw4LCgsODwo
+ LDgsKLf2zDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi1D
+ Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8OD
+ woLDgsKow4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwq10SmgoT03Dg8KDw4LCgsODwoLDg
+ sKLw4PCg8OCwoPDg8KCw4LCjcODwoPDgsKDw4PCgsOCwqggTMODwoPDgsKCw4PCgsOCwoXDg8KDw4
+ LCg8ODwoLDgsKAdDrDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLTSBQUcODwoPDgsK
+ Dw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKL
+ RCQoZitEJCDDg8KDw4LCgsODwoLDgsK3w4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwoHDg
+ 8KDw4LCg8ODwoLDgsKhw4PCg8OCwoLDg8KCw4LCi0QkJGYrRCTDg8KDw4LCgsODwoLDgsK3w4PCg8
+ OCwoPDg8KCw4LCkMODwoPDgsKDw4PCgsOCworDg8KDw4LCgsODwoLDgsKLRSBRVmpQw4PCg8OCwoP
+ Dg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKTzl0JHXDg8KDw4LCgsODwoLD
+ gsKhOXQkw4PCg8OCwoLDg8KCw4LChW/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODw
+ oPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKhRMODwoPDgsKDw4PCgsOCwoVOw4PCg8OCwoLDg8
+ KCw4LCi8ODwoPDgsKDw4PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ncw4P
+ Cg8OCwoLDg8KCw4LCiUQkw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsOD
+ woLDgsKEw4PCg8OCwoPDg8KCw4LCtjPDg8KDw4LCg8ODwoLDgsK2w4PCg8OCwoLDg8KCw4LCjUQkw
+ 4PCg8OCwoLDg8KCw4LCiyBEw4PCg8OCwoPDg8KCw4LChU5Qw4PCg8OCwoLDg8KCw4LCi8ODwoPDgs
+ KDw4PCgsOCwr9TYMODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCkMODwoPDgsKC
+ w4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCj8ODwoPDgsKDw4PCgsOCwr9Ta
+ MODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwr3Dg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4L
+ Cj1DDg8KDw4LCg8ODwoLDgsK/U2zDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCqMODwoPD
+ gsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKtw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCw
+ p9oMMODwoPDgsKDw4PCgsOCwolMw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4
+ LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCq0vDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4L
+ CgMODwoPDgsKCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi0QkOcODwoPD
+ gsKCw4PCgsOCwrDDg8KDw4LCg8ODwoLDgsKEdEU5w4PCg8OCwoLDg8KCw4LCtTR0PcODwoPDgsKCw
+ 4PCgsOCwovDg8KDw4LCg8ODwoLDgsKNw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwo5Lw4
+ PCg8OCwoLDg8KCw4LCi0AgUMODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKsw4PCg8OCwoL
+ Dg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHUow4PCg8OCwoLDg8KCw4LC
+ i8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCgsODwoLDgsKJw4PCg8OCwoLDg8KCw4LCtTTDg8KDw4LCg
+ 8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKDw4PCgsOCwrtWw4PCg8OCwoLDg8KCw4LCi8
+ ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCnw==
+
+dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All ITD Staff
+cn: ITD Staff
+objectClass: groupOfUniqueNames
+uniqueMember: cn=Manager,dc=example,dc=com
+uniqueMember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=
+ example,dc=com
+uniqueMember: cn=James A Jones 2,ou=Information Technology Division,ou=People,
+ dc=example,dc=com
+uniqueMember: cn=John Doe,ou=Information Technology Division,ou=People,dc=exam
+ ple,dc=com
+
+dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: James A Jones 1
+cn: James Jones
+cn: Jim Jones
+sn: Jones
+uid: jaj
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: amFq
+homePostalAddress: 3882 Beverly Rd. $ Anytown, MI 48105
+homePhone: +1 313 555 4772
+description: Outstanding
+title: Mad Cow Researcher, UM Alumni Association
+pager: +1 313 555 3923
+mail: jaj@mail.alumni.example.com
+facsimileTelephoneNumber: +1 313 555 4332
+telephoneNumber: +1 313 555 0895
+
+dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example
+ ,dc=com
+objectClass: OpenLDAPperson
+cn: James A Jones 2
+cn: James Jones
+cn: Jim Jones
+sn: Doe
+uid: jjones
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 933 Brooks $ Anytown, MI 48104
+homePhone: +1 313 555 8838
+title: Senior Manager, Information Technology Division
+description: Not around very much
+mail: jjones@mailgw.example.com
+postalAddress: Info Tech Division $ 535 W William $ Anytown, MI 48103
+pager: +1 313 555 2833
+facsimileTelephoneNumber: +1 313 555 8688
+telephoneNumber: +1 313 555 7334
+
+dn: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Jane Doe
+cn: Jane Alverson
+sn: Doe
+uid: jdoe
+title: Programmer Analyst, UM Alumni Association
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 123 Anystreet $ Anytown, MI 48104
+drink: diet coke
+description: Enthusiastic
+mail: jdoe@woof.net
+homePhone: +1 313 555 5445
+pager: +1 313 555 1220
+facsimileTelephoneNumber: +1 313 555 2311
+telephoneNumber: +1 313 555 4774
+
+dn: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Jennifer Smith
+cn: Jen Smith
+sn: Smith
+uid: jen
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Sam Adams
+homePostalAddress: 1000 Maple #44 $ Anytown, MI 48103
+title: Telemarketer, UM Alumni Association
+mail: jen@mail.alumni.example.com
+homePhone: +1 313 555 2333
+pager: +1 313 555 6442
+facsimileTelephoneNumber: +1 313 555 2756
+telephoneNumber: +1 313 555 8232
+
+dn: cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: John Doe
+cn: Jonathon Doe
+sn: Doe
+uid: johnd
+postalAddress: ITD $ 535 W. William $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 912 East Bllvd $ Anytown, MI 48104
+title: System Administrator, Information Technology Division
+description: overworked!
+mail: johnd@mailgw.example.com
+homePhone: +1 313 555 3774
+pager: +1 313 555 6573
+facsimileTelephoneNumber: +1 313 555 4544
+telephoneNumber: +1 313 555 9394
+
+dn: cn=Manager,dc=example,dc=com
+objectClass: person
+cn: Manager
+cn: Directory Manager
+cn: Dir Man
+sn: Manager
+description: Manager of the directory
+userPassword:: c2VjcmV0
+
+dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Mark Elliot
+cn: Mark A Elliot
+sn: Elliot
+uid: melliot
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 199 Outer Drive $ Ypsilanti, MI 48198
+homePhone: +1 313 555 0388
+drink: Gasoline
+title: Director, UM Alumni Association
+mail: melliot@mail.alumni.example.com
+pager: +1 313 555 7671
+facsimileTelephoneNumber: +1 313 555 7762
+telephoneNumber: +1 313 555 4177
+
+dn: ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+objectClass: extensibleObject
+ou: People
+uidNumber: 0
+gidNumber: 0
+
+dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Ursula Hampster
+sn: Hampster
+uid: uham
+title: Secretary, UM Alumni Association
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 123 Anystreet $ Anytown, MI 48104
+mail: uham@mail.alumni.example.com
+homePhone: +1 313 555 8421
+pager: +1 313 555 2844
+facsimileTelephoneNumber: +1 313 555 9700
+telephoneNumber: +1 313 555 5331
+
diff --git a/tests/data/chainmod.out b/tests/data/chainmod.out
new file mode 100644 (file)
index 0000000..a15e26f
--- /dev/null
@@ -0,0 +1,389 @@
+dn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All Alumni Assoc Staff
+cn: Alumni Assoc Staff
+objectClass: groupOfNames
+
+dn: ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Alumni Association
+
+dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
+ dc=com
+objectClass: OpenLDAPperson
+cn: Barbara Jensen
+cn: Babs Jensen
+sn:: IEplbnNlbiA=
+uid: bjensen
+title: Mythical Manager, Research Systems
+postalAddress: ITD Prod Dev & Deployment $ 535 W. William St. Room 4212 $ Anyt
+ own, MI 48103-4943
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: YmplbnNlbg==
+mail: bjensen@mailgw.example.com
+homePostalAddress: 123 Wesley $ Anytown, MI 48103
+description: Mythical manager of the rsdd unix project
+drink: water
+homePhone: +1 313 555 2333
+pager: +1 313 555 3233
+facsimileTelephoneNumber: +1 313 555 2274
+telephoneNumber: +1 313 555 9022
+
+dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
+ =com
+objectClass: OpenLDAPperson
+cn: Bjorn Jensen
+cn: Biiff Jensen
+sn: Jensen
+uid: bjorn
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: Ympvcm4=
+homePostalAddress: 19923 Seven Mile Rd. $ South Lyon, MI 49999
+drink: Iced Tea
+description: Hiker, biker
+title: Director, Embedded Systems
+postalAddress: Info Tech Division $ 535 W. William St. $ Anytown, MI 48103
+mail: bjorn@mailgw.example.com
+homePhone: +1 313 555 5444
+pager: +1 313 555 4474
+facsimileTelephoneNumber: +1 313 555 2177
+telephoneNumber: +1 313 555 0355
+
+dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Dorothy Stevens
+cn: Dot Stevens
+sn: Stevens
+uid: dots
+title: Secretary, UM Alumni Association
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Lemonade
+homePostalAddress: 377 White St. Apt. 3 $ Anytown, MI 48104
+description: Very tall
+facsimileTelephoneNumber: +1 313 555 3223
+telephoneNumber: +1 313 555 3664
+mail: dots@mail.alumni.example.com
+homePhone: +1 313 555 0454
+
+dn: dc=example,dc=com
+objectClass: top
+objectClass: organization
+objectClass: domainRelatedObject
+objectClass: dcObject
+dc: example
+l: Anytown, Michigan
+st: Michigan
+o: Example, Inc.
+o: EX
+o: Ex.
+description: The Example, Inc. at Anytown
+postalAddress: Example, Inc. $ 535 W. William St. $ Anytown, MI 48109 $ US
+telephoneNumber: +1 313 555 1817
+associatedDomain: example.com
+
+dn: ou=Groups,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Groups
+
+dn: ou=Information Technology Division,ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Information Technology Division
+description:: aMODwoPDgsKCw4PCgsOCwotFVlZQw4PCg8OCwoPDg8KCw4LCv0zDg8KDw4LCgsOD
+ woLDgsKKT8ODwoPDgsKDw4PCgsOCwqs6w4PCg8OCwoLDg8KCw4LCjUQkw4PCg8OCwoLDg8KCw4LCi
+ 01QUcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4
+ LCgsODwoLDgsKLRCQoZitEJMODwoPDgsKCw4PCgsOCwrfDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoP
+ Dg8KCw4LCgcODwoPDgsKDw4PCgsOCwqHDg8KDw4LCgsODwoLDgsKLRCQkZitEJMODwoPDgsKCw4PC
+ gsOCwrfDg8KDw4LCg8ODwoLDgsKQw4PCg8OCwoPDg8KCw4LCisODwoPDgsKCw4PCgsOCwotFUVZqU
+ MODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKAw4PCg8OCwoLDg8KCw4LCik85dCTDg8KDw4
+ LCgsODwoLDgsKFQ8ODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4L
+ Cvzl0JMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPD
+ gsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKLRCTDg8KDw4LCgsODwoLDgsKDw4PCg8OCwoLDg8KCw
+ 4LCuMODwoPDgsKDw4PCgsOCwoR0Q8ODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LChMODwo
+ PDgsKDw4PCgsOCwoFOdTrDg8KDw4LCg8ODwoLDgsKHw4PCg8OCwoPDg8KCw4LChMODwoPDgsKDw4P
+ CgsOCwoFOw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwrtHw4PCg8OCwoLDg8KCw4LChcOD
+ woPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsK4dMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODw
+ oLDgsKtR8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwo
+ PDgsKDw4PCgsOCwr9SfGrDg8KDw4LCgsODwoLDgsKLQGgxw4PCg8OCwoPDg8KCw4LCoWhQw4PCg8O
+ CwoPDg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKT8ODwoPDgsKCw4PCgsOC
+ wotEJDDDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHTDg8KDw4LCgsODwoLDgsKDw4PCg
+ 8OCwoPDg8KCw4LCuHXDg8KDw4LCgsODwoLDgsKLRCRqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4
+ PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpPDg8K
+ Dw4LCg8ODwoLDgsKQXV9eW8ODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoPD
+ g8KCw4LCgsODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODw
+ oPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgs
+ OCwoxWV8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKxw4PCg8OCwoLDg8KCw4LCi3wkw4P
+ Cg8OCwoLDg8KCw4LCjcODwoPDgsKCw4PCgsOCwofDg8KDw4LCg8ODwoLDgsKof8ODwoPDgsKDw4PC
+ gsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCg8ODwoPDgsKDw4PCgsOCwrh5w4PCg
+ 8OCwoLDg8KCw4LChzQzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PCgsOCworDg8KDw4LCgsODwo
+ LDgsKIw4PCg8OCwoLDg8KCw4LCuDFBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNdDF
+ Bw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPD
+ gsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw
+ 4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgs
+ KCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKAdcODwoPDgsKDw4PCgsOCwqhtw4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCsMODwoPDgsKC
+ w4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCt
+ sODwoPDgsKDw4PCgsOCwq7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4
+ PCgsOCwoPDg8KDw4LCg8ODwoLDgsKoZsODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4w4P
+ Cg8OCwoLDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwpUzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PC
+ gsOCworDg8KDw4LCgsODwoLDgsKISDJBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNN
+ DJBw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwo
+ PDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8O
+ DwoPDgsKDw4PCgsOCwojDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCnEzDg8KDw4LCgsOD
+ woLDgsKLSEBmw4PCg8OCwoLDg8KCw4LCg3lwdSTDg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw
+ 4LCv8ODwoPDgsKCw4PCgsOCwobDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwp/Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwoj
+ Dg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCwpPDg8KDw4LCgsOD
+ woLDgsKBw4PCg8OCwoPDg8KCw4LCv1rDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODw
+ oPDgsKCw4PCgsOCwodqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwoBqaMODwoPDgsKCw4
+ PCgsOCwpBQw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDIMODwoPDgsKCw4PCgsOCwopPw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKOacODwoPDgsKCw4PCgsOCwrhf
+ XsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCw
+ oLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKGw4PCg8OCwoLDg8KCw4LCgM
+ ODwoPDgsKCw4PCgsOCwoRJw4PCg8OCwoLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsO
+ DwoLDgsKIw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQ9w4PCg8OCwoLDg8KCw4LCgcOD
+ woPDgsKDw4PCgsOCwr9aw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQxw4PCg8OCwoLDg
+ 8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LCm0
+ 7Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsK
+ Cw4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODw
+ oPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgs
+ OCwo7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCkMODwoPDgsKDw4PCgsOCwojDg8KDw4L
+ CgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsK+
+ S8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKww4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDw
+ 4PCgsOCwoTDg8KDw4LCgsODwoLDgsKKT1DDg8KDw4LCg8ODwoLDgsKoRsODwoPDgsKCw4PCgsOCwo
+ vDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwrZ0Y8ODwoPDgsK
+ Cw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/dF/Dg8KDw4LCgsODwoLDgsKhdHpPw4PCg8OCwoLDg8KC
+ w4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PCg8OCwoPDg8KCw4LCqC1Jw4PCg8OCwoLDg8KCw4LChcODw
+ oPDgsKDw4PCgsOCwoB1RMODwoPDgsKCw4PCgsOCwqFwek/Dg8KDw4LCgsODwoLDgsKLw4PCg8OCwo
+ PDg8KCw4LCj1DDg8KDw4LCg8ODwoLDgsKoScODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK
+ AdTPDg8KDw4LCgsODwoLDgsKhbHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PC
+ g8OCwoPDg8KCw4LCqEnDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHXDg8KDw4LCgsODw
+ oLDgsKhaHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo9Qw4PCg8OCwoPDg8KCw4LCqM
+ ODwoPDgsKDw4PCgsOCwrpIw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoB1M8ODwoPDgsK
+ Dw4PCgsOCwoBfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgjPDg8KDw4LCg8ODwoLDgsKAX17Dg
+ 8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCg8ODwo
+ LDgsKoJ8ODwoPDgsKDw4PCgsOCwq3Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoP
+ DgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4aHU5w4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PC
+ gsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw
+ 4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgs
+ KIw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpLDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoB0IcODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKA
+ w4PCg8OCwoPDg8KCw4LCtMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKAdGbDg8KDw4LCg
+ sODwoLDgsKLQGY9dGY9dTPDg8KDw4LCg8ODwoLDgsKAX17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwo
+ LDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPDgsKDw4PCgsO
+ CwoIzw4PCg8OCwoPDg8KCw4LCgF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwovDg8KD
+ w4LCg8ODwoLDgsK/Ri9BUC9BRi9BWi9BZC9BWzBBZC9BZTBBZC9BZC9BbzBBZC9BeTBBw4PCg8OCw
+ oLDg8KCw4LCgzBBMUFhMUFrMUE=
+description:: UF7Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOC
+ wozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg
+ 8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCqFDDg8KDw4LCg8ODwoLDgsKpRsODwoPDgsKDw4PCgsOCwo
+ zDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8O
+ DwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKCw4PCgsOCwotEJCDDg8KDw4LCgsODwoLDgsKD
+ w4PCg8OCwoPDg8KCw4LCrMODwoPDgsKCw4PCgsOCwotUJCRTw4PCg8OCwoLDg8KCw4LCi1wkJFbDg
+ 8KDw4LCgsODwoLDgsKJTCRXVVBSU8ODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsKdT8ODwo
+ PDgsKCw4PCgsOCwoN8JDB1w4PCg8OCwoPDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8O
+ DwoLDgsKBTsODwoPDgsKDw4PCgsOCwqktw4PCg8OCwoLDg8KCw4LCg3wkMHTDg8KDw4LCgsODwoLD
+ gsKDfCQww4PCg8OCwoLDg8KCw4LChTPDg8KDw4LCg8ODwoLDgsK2OTXDg8KDw4LCg8ODwoLDgsKAw
+ 4PCg8OCwoPDg8KCw4LCgU7Dg8KDw4LCgsODwoLDgsKEIMODwoPDgsKCw4PCgsOCwqFIw4PCg8OCwo
+ PDg8KCw4LChU7Dg8KDw4LCgsODwoLDgsKJNcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8ODwoLDgsK
+ BTsODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKD
+ w4PCgsOCwr9TXMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw
+ 4LChMODwoPDgsKCw4PCgsOCwpHDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLIEjDg8
+ KDw4LCg8ODwoLDgsKFTlDDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ngw4PCg8OCwoL
+ Dg8KCw4LCi8ODwoPDgsKDw4PCgsOCwpjDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCm3Rx
+ w4PCg8OCwoLDg8KCw4LCizvDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi8ODwoPDgsKDw
+ 4PCgsOCwr9XaMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGdGLDg8KDw4LCgsODwo
+ LDgsKLf2zDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi1D
+ Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8OD
+ woLDgsKow4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwq10SmgoT03Dg8KDw4LCgsODwoLDg
+ sKLw4PCg8OCwoPDg8KCw4LCjcODwoPDgsKDw4PCgsOCwqggTMODwoPDgsKCw4PCgsOCwoXDg8KDw4
+ LCg8ODwoLDgsKAdDrDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLTSBQUcODwoPDgsK
+ Dw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKL
+ RCQoZitEJCDDg8KDw4LCgsODwoLDgsK3w4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwoHDg
+ 8KDw4LCg8ODwoLDgsKhw4PCg8OCwoLDg8KCw4LCi0QkJGYrRCTDg8KDw4LCgsODwoLDgsK3w4PCg8
+ OCwoPDg8KCw4LCkMODwoPDgsKDw4PCgsOCworDg8KDw4LCgsODwoLDgsKLRSBRVmpQw4PCg8OCwoP
+ Dg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKTzl0JHXDg8KDw4LCgsODwoLD
+ gsKhOXQkw4PCg8OCwoLDg8KCw4LChW/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODw
+ oPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKhRMODwoPDgsKDw4PCgsOCwoVOw4PCg8OCwoLDg8
+ KCw4LCi8ODwoPDgsKDw4PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ncw4P
+ Cg8OCwoLDg8KCw4LCiUQkw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsOD
+ woLDgsKEw4PCg8OCwoPDg8KCw4LCtjPDg8KDw4LCg8ODwoLDgsK2w4PCg8OCwoLDg8KCw4LCjUQkw
+ 4PCg8OCwoLDg8KCw4LCiyBEw4PCg8OCwoPDg8KCw4LChU5Qw4PCg8OCwoLDg8KCw4LCi8ODwoPDgs
+ KDw4PCgsOCwr9TYMODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCkMODwoPDgsKC
+ w4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCj8ODwoPDgsKDw4PCgsOCwr9Ta
+ MODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwr3Dg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4L
+ Cj1DDg8KDw4LCg8ODwoLDgsK/U2zDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCqMODwoPD
+ gsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKtw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCw
+ p9oMMODwoPDgsKDw4PCgsOCwolMw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4
+ LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCq0vDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4L
+ CgMODwoPDgsKCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi0QkOcODwoPD
+ gsKCw4PCgsOCwrDDg8KDw4LCg8ODwoLDgsKEdEU5w4PCg8OCwoLDg8KCw4LCtTR0PcODwoPDgsKCw
+ 4PCgsOCwovDg8KDw4LCg8ODwoLDgsKNw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwo5Lw4
+ PCg8OCwoLDg8KCw4LCi0AgUMODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKsw4PCg8OCwoL
+ Dg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHUow4PCg8OCwoLDg8KCw4LC
+ i8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCgsODwoLDgsKJw4PCg8OCwoLDg8KCw4LCtTTDg8KDw4LCg
+ 8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKDw4PCgsOCwrtWw4PCg8OCwoLDg8KCw4LCi8
+ ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCnw==
+
+dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All ITD Staff
+cn: ITD Staff
+objectClass: groupOfUniqueNames
+uniqueMember: cn=Manager,dc=example,dc=com
+uniqueMember: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=
+ example,dc=com
+uniqueMember: cn=James A Jones 2,ou=Information Technology Division,ou=People,
+ dc=example,dc=com
+uniqueMember: cn=John Doe,ou=Information Technology Division,ou=People,dc=exam
+ ple,dc=com
+
+dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: James A Jones 1
+cn: James Jones
+cn: Jim Jones
+sn: Jones
+uid: jaj
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+userPassword:: amFq
+homePostalAddress: 3882 Beverly Rd. $ Anytown, MI 48105
+homePhone: +1 313 555 4772
+description: Outstanding
+title: Mad Cow Researcher, UM Alumni Association
+pager: +1 313 555 3923
+mail: jaj@mail.alumni.example.com
+facsimileTelephoneNumber: +1 313 555 4332
+telephoneNumber: +1 313 555 0895
+
+dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example
+ ,dc=com
+objectClass: OpenLDAPperson
+cn: James A Jones 2
+cn: James Jones
+cn: Jim Jones
+sn: Doe
+uid: jjones
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 933 Brooks $ Anytown, MI 48104
+homePhone: +1 313 555 8838
+title: Senior Manager, Information Technology Division
+description: Not around very much
+mail: jjones@mailgw.example.com
+postalAddress: Info Tech Division $ 535 W William $ Anytown, MI 48103
+pager: +1 313 555 2833
+facsimileTelephoneNumber: +1 313 555 8688
+telephoneNumber: +1 313 555 7334
+
+dn: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Jane Doe
+cn: Jane Alverson
+sn: Doe
+uid: jdoe
+title: Programmer Analyst, UM Alumni Association
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 123 Anystreet $ Anytown, MI 48104
+drink: diet coke
+description: Enthusiastic
+mail: jdoe@woof.net
+homePhone: +1 313 555 5445
+pager: +1 313 555 1220
+facsimileTelephoneNumber: +1 313 555 2311
+telephoneNumber: +1 313 555 4774
+
+dn: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Jennifer Smith
+cn: Jen Smith
+sn: Smith
+uid: jen
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Sam Adams
+homePostalAddress: 1000 Maple #44 $ Anytown, MI 48103
+title: Telemarketer, UM Alumni Association
+mail: jen@mail.alumni.example.com
+homePhone: +1 313 555 2333
+pager: +1 313 555 6442
+facsimileTelephoneNumber: +1 313 555 2756
+telephoneNumber: +1 313 555 8232
+
+dn: cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: John Doe
+cn: Jonathon Doe
+sn: Doe
+uid: johnd
+postalAddress: ITD $ 535 W. William $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 912 East Bllvd $ Anytown, MI 48104
+title: System Administrator, Information Technology Division
+description: overworked!
+mail: johnd@mailgw.example.com
+homePhone: +1 313 555 3774
+pager: +1 313 555 6573
+facsimileTelephoneNumber: +1 313 555 4544
+telephoneNumber: +1 313 555 9394
+
+dn: cn=Manager,dc=example,dc=com
+objectClass: person
+cn: Manager
+cn: Directory Manager
+cn: Dir Man
+sn: Manager
+description: Manager of the directory
+userPassword:: c2VjcmV0
+
+dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+objectClass: OpenLDAPperson
+cn: Mark Elliot
+cn: Mark A Elliot
+sn: Elliot
+uid: melliot
+postalAddress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seeAlso: cn=All Staff,ou=Groups,dc=example,dc=com
+homePostalAddress: 199 Outer Drive $ Ypsilanti, MI 48198
+homePhone: +1 313 555 0388
+drink: Gasoline
+title: Director, UM Alumni Association
+mail: melliot@mail.alumni.example.com
+pager: +1 313 555 7671
+facsimileTelephoneNumber: +1 313 555 7762
+telephoneNumber: +1 313 555 4177
+
+dn: ou=People,dc=example,dc=com
+objectClass: organizationalUnit
+objectClass: extensibleObject
+ou: People
+uidNumber: 0
+gidNumber: 0
+
+dn: cn=Renamed Group,ou=Groups,dc=example,dc=com
+objectClass: groupOfNames
+description: testing chain overlay writes...
+member: cn=New Group,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+cn: Renamed Group
+
+dn: cn=Renamed User,ou=People,dc=example,dc=com
+objectClass: person
+sn: User
+description: testing chain overlay writes...
+seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
+cn: Renamed User
+
index 8e40f1c94862815309f72b94609c7525d9154ae2..dccea354d743a9807ffdce9e4a3ff95cc303e1d2 100644 (file)
@@ -1,7 +1,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 1380fcbea71b20cad7b85ce7e74795d88131980e..b3ef32295cdf4e2db5dc8b97da644a1ed1624ac0 100644 (file)
@@ -2054,7 +2054,7 @@ mail: auser@mail.alumni.example.com
 telephoneNumber: +49 1234-567-890
 description: Just added in o=Beispiel,c=DE naming context
 
-# refldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE??sub
+# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub
 
 # searching base="o=Esempio,c=IT"...
 dn: o=Esempio,c=IT
@@ -2466,7 +2466,7 @@ mail: auser@mail.alumni.example.com
 telephoneNumber: +49 1234-567-890
 description: Just added in o=Beispiel,c=DE naming context
 
-# refldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE??sub
+# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub
 
 # searching filter="(objectClass=referral)"
 #      attrs="'*' ref"
@@ -2477,9 +2477,9 @@ objectClass: extensibleObject
 ou: Referrals
 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei
  spiel,c=DE
-description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,o=Bei
spiel,c=DE
-ref: ldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE
+description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel,
+ c=DE
+ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE
 
 #      base="o=Example,c=US"...
 dn: ou=Referrals,o=Example,c=US
@@ -2488,9 +2488,9 @@ objectClass: extensibleObject
 ou: Referrals
 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei
  spiel,c=DE
-description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,o=Bei
spiel,c=DE
-ref: ldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE??base
+description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel,
+ c=DE
+ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE
 
 #      base="o=Esempio,c=IT"...
 dn: ou=Referrals,o=Esempio,c=IT
@@ -2499,9 +2499,9 @@ objectClass: extensibleObject
 ou: Referrals
 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei
  spiel,c=DE
-description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,o=Bei
spiel,c=DE
-ref: ldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE??base
+description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel,
+ c=DE
+ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE
 
 # searching filter="(seeAlso=cn=all staff,ou=Groups,o=Example,c=US)"
 #      attrs="seeAlso"
@@ -2540,5 +2540,5 @@ seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,o=Example,c=US
 dn: cn=Added User,ou=Alumni Association,ou=People,o=Example,c=US
 seeAlso: cn=All Staff,ou=Groups,o=Example,c=US
 
-# refldap://ldap.example.com:389/ou=Referrals,o=Beispiel,c=DE??sub
+# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub
 
index 3307b6bd945f23a2d696104ae966d25fc2afb1b7..f01b747f8f2422609cd2c45e1fea80034f3112bb 100644 (file)
@@ -3,7 +3,7 @@
   kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -64,6 +64,7 @@ access                to filter="(objectclass=person)" attr=userpassword
 access         to dn.children="ou=Alumni Association,ou=People,dc=example,dc=com"
                by dn.regex=".+,dc=example,dc=com" +c continue
                by dn.subtree="dc=example,dc=com" +rs continue
+               by dn.children="dc=example,dc=com" +d continue
                by * stop
 
 #access                to attr=member,uniquemember dn.subtree="dc=example,dc=com"
index 746d75931f1b94fcf52fcd4192a86ada126da0f2..f4b8073aaaf6e3311053a5712eaa787bf938d34e 100644 (file)
@@ -3,7 +3,7 @@
  22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
diff --git a/tests/data/slapd-chain1.conf b/tests/data/slapd-chain1.conf
new file mode 100644 (file)
index 0000000..786a87c
--- /dev/null
@@ -0,0 +1,57 @@
+# master slapd config -- for testing
+# $OpenLDAP: pkg/ldap/tests/data/slapd-pw.conf,v 1.19.2.4 2003/12/15 22:05:29 
+ kurt Exp $
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
+##
+## Copyright 1998-2005 The OpenLDAP Foundation.
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted only as authorized by the OpenLDAP
+## Public License.
+##
+## A copy of this license is available in the file LICENSE in the
+## top-level directory of the distribution or, alternatively, at
+## <http://www.OpenLDAP.org/license.html>.
+
+include ./schema/core.schema
+include ./schema/cosine.schema
+include ./schema/inetorgperson.schema
+include ./schema/openldap.schema
+include ./schema/nis.schema
+pidfile     ./testrun/slapd.1.pid
+argsfile    ./testrun/slapd.1.args
+
+#mod#modulepath        ../servers/slapd/back-@BACKEND@/
+#mod#moduleload        back_@BACKEND@.la
+#ldapmod#modulepath ../servers/slapd/back-ldap/
+#ldapmod#moduleload back_ldap.la
+#monitormod#modulepath ../servers/slapd/back-monitor/
+#monitormod#moduleload back_monitor.la
+
+#
+# uses the chain overlay as global;
+# no chain-URI is configured, so the URI is parsed out of the referral
+overlay                chain
+chain-acl-authcDN      "cn=Manager,dc=example,dc=com"
+chain-acl-passwd       secret
+
+#######################################################################
+# database definitions
+#######################################################################
+
+#
+# normal installations should protect root dse,
+# cn=monitor, cn=schema, and cn=config
+#
+
+database       @BACKEND@
+#ldbm#cachesize        0
+suffix         "dc=example,dc=com"
+directory      ./testrun/db.1.a
+rootdn         "cn=Manager,dc=example,dc=com"
+rootpw         secret
+index          objectClass     eq
+index          cn,sn,uid       pres,eq,sub
+
+#monitor#database monitor
diff --git a/tests/data/slapd-chain2.conf b/tests/data/slapd-chain2.conf
new file mode 100644 (file)
index 0000000..79d3411
--- /dev/null
@@ -0,0 +1,58 @@
+# master slapd config -- for testing
+# $OpenLDAP: pkg/ldap/tests/data/slapd-pw.conf,v 1.19.2.4 2003/12/15 22:05:29 
+ kurt Exp $
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
+##
+## Copyright 1998-2005 The OpenLDAP Foundation.
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted only as authorized by the OpenLDAP
+## Public License.
+##
+## A copy of this license is available in the file LICENSE in the
+## top-level directory of the distribution or, alternatively, at
+## <http://www.OpenLDAP.org/license.html>.
+
+include ./schema/core.schema
+include ./schema/cosine.schema
+include ./schema/inetorgperson.schema
+include ./schema/openldap.schema
+include ./schema/nis.schema
+pidfile     ./testrun/slapd.2.pid
+argsfile    ./testrun/slapd.2.args
+
+#mod#modulepath        ../servers/slapd/back-@BACKEND@/
+#mod#moduleload        back_@BACKEND@.la
+#ldapmod#modulepath ../servers/slapd/back-ldap/
+#ldapmod#moduleload back_ldap.la
+#monitormod#modulepath ../servers/slapd/back-monitor/
+#monitormod#moduleload back_monitor.la
+
+#######################################################################
+# database definitions
+#######################################################################
+
+#
+# normal installations should protect root dse,
+# cn=monitor, cn=schema, and cn=config
+#
+
+database       @BACKEND@
+#ldbm#cachesize        0
+suffix         "dc=example,dc=com"
+directory      ./testrun/db.2.a
+rootdn         "cn=Manager,dc=example,dc=com"
+rootpw         secret
+index          objectClass     eq
+index          cn,sn,uid       pres,eq,sub
+
+#
+# uses the chain overlay as database specific;
+# the chain-URI is configured, so only that URI is chained
+overlay                chain
+chain-uri      @URI1@
+chain-acl-authcDN      "cn=Manager,dc=example,dc=com"
+chain-acl-passwd       secret
+
+#monitor#database monitor
index 5c1739d1782b9542cf1fd789a76ffa9cc440cabf..ce988c81576494d85e9c0fc4af33a5cc8df5e430 100644 (file)
@@ -3,7 +3,7 @@
  :29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f67ab8d75b20f06385b647ff56a6627013f74c06..c7e414c0898c2cc2ce6d6dbef66cfe78342189d4 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index a7b2bd0af0ba7dfb2652f8d14c13b971bd387b5b..4ea647ee995c5d4958c97d22a57cb0e382c994c5 100644 (file)
@@ -3,7 +3,7 @@
  :29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 5db18ba6040a924e5a6f68c677e9d1cf3f496609..3ae2f34df12286185c72db28083a8308c1290ce2 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index bdf1099edfe0bb37f0a187dc31b32e25047c848a..fe529c6d5e213cb416ee3fcbd5b53a8a03439926 100644 (file)
@@ -3,7 +3,7 @@
   kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index aab967311047f627c6f880e8bfdb33002e4787ed..648ac31320dd738c330998724b9fbdd54ff8f9aa 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -39,7 +39,7 @@ argsfile    ./testrun/slapd.1.args
 authz-policy   both
 authz-regexp   "^uid=admin/([^,]+),.+" "ldap:///ou=Admin,dc=example,dc=com??sub?(cn=$1)"
 authz-regexp   "^uid=it/([^,]+),.+" "ldap:///ou=People,dc=example,dc=it??sub?(uid=$1)"
-authz-regexp   "^uid=(us/)*([^,]+),.+" "ldap:///ou=People,dc=example,dc=com??sub?(uid=$2)"
+authz-regexp   "^uid=(us/)?([^,]+),.+" "ldap:///ou=People,dc=example,dc=com??sub?(uid=$2)"
 
 #
 # normal installations should protect root dse,
index 3bfdb3127c2a3ad2ed3ea1a2aed39957d7050b25..95e9e286048ace4bd9b6938a647e0aef10cc7ddf 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 19c515ec09b4c38a493d64cf1979c8f8f01f55f9..51513efb29e2645fe65b942adbb11922138c4bd8 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index ab87ed10e725f266a14c4c6f73c1ba472359de97..5c9155e1c9d9ed4c5289a7a1903bd66e89c3da56 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index dc4a6b92a5b0b6832a1421df805a995bd0e274c8..6b51b12693bc91e444ed9f56cdc29c3574f6b17b 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 5c4badc0fe65935615116385a724b94dd6bced7c..2f5828ef660b035156bcc962a5e5bb94b3b6dfe4 100644 (file)
@@ -3,7 +3,7 @@
  :29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 71b985259823dcd9f56587a5fa1ea9db6a9d82ae..ac6e94400a08ad7f9b8737770f66ca599dc64b30 100644 (file)
@@ -3,7 +3,7 @@
  2:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e51dc28f4275a23687e75b74ba4f1facc6e857c2..fd3589f430c7bc4e9ba87d024fdbf1d712042b67 100644 (file)
@@ -3,7 +3,7 @@
  :29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 18b86458a91e6de08168762d6d2fd8a16c486875..debfa68fa24fe79e1b824e04a598328c85cad51d 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 045071cd19c5ba4e6fbb122b5228e3c5f3f2ae89..bfcb01a756c895a02ac156f7157612dbe32df552 100644 (file)
@@ -3,7 +3,7 @@
  :05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 10dbdb224f1c58558e74c5dac9b9ce233fada590..cd3b42ded8e36ab324023bae77117b0b1f5a5449 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 27bac169b2057a1969c858b3a50c06e17c07e25b..131d2cadb788f74e8543525f7d37b5b09d4bc8b2 100644 (file)
@@ -3,7 +3,7 @@
  :05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index b014b9b29698a59b986fabecc68387cd1984ac1a..3de976ff02c8afac3058013ad8e6f16718577073 100644 (file)
@@ -3,7 +3,7 @@
  05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index bd6b8f9b5c3cd505e11537aa6b89e6ebaff02d47..3d80502799b302081e97834d3cf167e41bd4c56a 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 7030ae5e4c44186e3ffd7b35bc18ddd2cfbd350f..e13e66f1c686a0441b03cb03866d69e84815ae3c 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 1bb6734f1709e0cc6c1aa870adc7495ffb82d5c3..af4580d1f6b367a3f02a091c191f94a3e67df481 100644 (file)
@@ -3,7 +3,7 @@
  22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index aa4ee66973a8cb145d38b4c9491871109b674626..a03323286772125a370c0c0545120254f378df9b 100644 (file)
@@ -3,7 +3,7 @@
  2:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -27,6 +27,21 @@ argsfile    ./testrun/slapd.2.args
 #mod#moduleload        back_@BACKEND@.la
 #monitormod#modulepath ../servers/slapd/back-monitor/
 #monitormod#moduleload back_monitor.la
+#ldapmod#modulepath ../servers/slapd/back-ldap/
+#ldapmod#moduleload back_ldap.la
+
+#ldapyes#overlay               chain
+#ldapyes#chain-uri             @URI1@
+#ldapyes#chain-idassert-method "simple"
+#ldapyes#chain-idassert-authcDN        "cn=Manager,dc=example,dc=com"
+#ldapyes#chain-idassert-passwd secret
+#ldapyes#chain-idassert-mode   self
+#ldapmod#overlay               chain
+#ldapmod#chain-uri             @URI1@
+#ldapmod#chain-idassert-method "simple"
+#ldapmod#chain-idassert-authcDN        "cn=Manager,dc=example,dc=com"
+#ldapmod#chain-idassert-passwd secret
+#ldapmod#chain-idassert-mode   self
 
 #######################################################################
 # database definitions
@@ -39,10 +54,10 @@ directory   ./testrun/db.2.a
 rootdn         "cn=Replica,dc=example,dc=com"
 rootpw         secret
 updatedn       "cn=Replica,dc=example,dc=com"
-updateref      "ldap://localhost:9010"
+updateref      @URI1@
 #ldbm#index            objectClass     eq
 #ldbm#index            cn,sn,uid       pres,eq,sub
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
 
-#monitor#database monitor
+#monitor#database      monitor
index 44072b08a3b7350bd19d512feca32eacb9e49c61..d1f82f617718027ed08224542963706cb3b5c43c 100644 (file)
@@ -3,7 +3,7 @@
  :29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -24,6 +24,11 @@ include ./schema/inetorgperson.schema
 include ./schema/misc.schema
 include ./schema/nis.schema
 include ./schema/openldap.schema
+#
+include ./schema/duaconf.schema
+include ./schema/dyngroup.schema
+include ./schema/ppolicy.schema
+
 #
 pidfile     ./testrun/slapd.1.pid
 argsfile    ./testrun/slapd.1.args
index baa7afe83dc1133c12724c79a9351a18ec972844..3d3adacb6ec2688e004eda70c9d2092f665ed355 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -60,16 +60,16 @@ dbpasswd        secret
 #ibmdb2#concat_pattern         "?||?"
 #ibmdb2#children_cond          "ucase(ldap_entries.dn)=ucase(cast(? as varchar(255)))"
 #ibmdb2#create_needs_select    "yes"
-#ibmdb2#insentry_query         "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
+#ibmdb2#insentry_stmt          "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
 #
 # PostgreSQL
-#postgres#insentry_query  "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
-#postgres#upper_func      "upper"
-#postgres#strcast_func    "text"
-#postgres#concat_pattern  "?||?"
+#postgres#insentry_stmt                "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
+#postgres#upper_func           "upper"
+#postgres#strcast_func         "text"
+#postgres#concat_pattern       "?||?"
 #
 # MySQL
-#mysql#concat_pattern  "concat(?,?)"
+#mysql#concat_pattern  "concat(?,?)"
 
 has_ldapinfo_dn_ru      no
 
index 2b40f1473a47d2c9fb4ba63e9895a4500df784f9..b4e93e47f0456d5e495a902f7532a04f5a7fd387 100644 (file)
@@ -3,7 +3,7 @@
  15 22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -43,8 +43,9 @@ rootpw                secret
 #ldbm#index            cn,sn,uid       pres,eq,sub
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
+#bdb#index             entryUUID,entryCSN      eq
 
-#sessionlog 1 100
 overlay syncprov
+#syncprov-sessionlog 100
 
 #monitor#database monitor
index d3774589fd24c7cdb05e4495b6e18ac3faed87e1..75520f92684a2e679e01dfbd461488292857a20b 100644 (file)
@@ -3,7 +3,7 @@
  2003/12/15 22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,21 @@ argsfile    ./testrun/slapd.4.args
 #monitormod#moduleload back_monitor.la
 #syncprovmod#modulepath ../servers/slapd/overlays/
 #syncprovmod#moduleload syncprov.la
+#ldapmod#modulepath ../servers/slapd/back-ldap/
+#ldapmod#moduleload back_ldap.la
+
+#ldapyes#overlay               chain
+#ldapyes#chain-uri             @URI1@
+#ldapyes#chain-idassert-method "simple"
+#ldapyes#chain-idassert-authcDN        "cn=Manager,dc=example,dc=com"
+#ldapyes#chain-idassert-passwd secret
+#ldapyes#chain-idassert-mode   self
+#ldapmod#overlay               chain
+#ldapmod#chain-uri             @URI1@
+#ldapmod#chain-idassert-method "simple"
+#ldapmod#chain-idassert-authcDN        "cn=Manager,dc=example,dc=com"
+#ldapmod#chain-idassert-passwd secret
+#ldapmod#chain-idassert-mode   self
 
 #######################################################################
 # consumer database definitions
@@ -47,16 +62,16 @@ rootpw              secret
 # Don't change syncrepl spec yet
 syncrepl rid=1
                 provider=@URI1@
-                updatedn="cn=Replica,dc=example,dc=com"
                 binddn="cn=Manager,dc=example,dc=com"
                 bindmethod=simple
                 credentials=secret
                 searchbase="dc=example,dc=com"
                 filter="(objectClass=*)"
-                attrs="*"
+                attrs="*,+"
                 schemachecking=off
                 scope=sub
                 type=refreshAndPersist
+updateref      @URI1@
 
 overlay syncprov
 
index e305807604b71e3cd59493e4088d1a7de1e57c45..1f3f47c93507c5e91cffb5212d3534d97d31e0a4 100644 (file)
@@ -29,11 +29,11 @@ rootpw              secret
 #ldbm#index            cn,sn,uid       pres,eq,sub
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
+#bdb#index             entryUUID,entryCSN      eq
 
 # Don't change syncrepl spec yet
 syncrepl rid=1
                 provider=@URI4@
-                updatedn="cn=Replica,dc=example,dc=com"
                 binddn="cn=Replica,dc=example,dc=com"
                 bindmethod=simple
                 credentials=secret
index 2333a81f1ba1e33da891df9c9a26dd30ee674e76..cb4576cc24300f2bc5c072bbf82d9c75852a9a54 100644 (file)
@@ -3,7 +3,7 @@
  2003/12/15 22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -41,11 +41,11 @@ rootpw              secret
 #ldbm#index            cn,sn,uid       pres,eq,sub
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
+#bdb#index             entryUUID,entryCSN      eq
 
 # Don't change syncrepl spec yet
 syncrepl rid=1
                 provider=@URI1@
-                updatedn="cn=Replica,dc=example,dc=com"
                 binddn="cn=Manager,dc=example,dc=com"
                 bindmethod=simple
                 credentials=secret
index 67f65fe93300710e9a981fca0efeb6f876e41a94..ddf424dfb374bc6e6b141f71a86fad94efe19d10 100644 (file)
@@ -3,7 +3,7 @@
  2003/12/15 22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -41,15 +41,14 @@ rootdn              "cn=Replica,dc=example,dc=com"
 rootpw         secret
 #ldbm#index            objectClass     eq
 #ldbm#index            cn,sn,uid       pres,eq,sub
+#ldbm#index            entryUUID       eq
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
-
-sessionlog 1 100
+#bdb#index             entryUUID,entryCSN      eq
 
 # Don't change syncrepl spec yet
 syncrepl rid=1
                 provider=@URI1@
-                updatedn="cn=Replica,dc=example,dc=com"
                 binddn="cn=Manager,dc=example,dc=com"
                 bindmethod=simple
                 credentials=secret
@@ -60,8 +59,11 @@ syncrepl rid=1
                 scope=sub
                 type=refreshOnly
                 interval=00:00:00:10
+updateref      @URI1@
 
 overlay syncprov
+syncprov-sessionlog 100
+
 
 
-#monitor#database monitor
+#monitor#database      monitor
index 057ba197886df9b51a7957f8a1f36f43cb12ef94..780d2fde9a5b82bb1abe6ccf1a9efc66ca144691 100644 (file)
@@ -3,7 +3,7 @@
  2003/12/15 22:05:29 kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -39,13 +39,14 @@ rootdn              "cn=Replica,dc=example,dc=com"
 rootpw         secret
 #ldbm#index            objectClass     eq
 #ldbm#index            cn,sn,uid       pres,eq,sub
+#ldbm#index            entryUUID       eq
 #bdb#index             objectClass     eq
 #bdb#index             cn,sn,uid       pres,eq,sub
+#bdb#index             entryUUID,entryCSN      eq
 
 # Don't change syncrepl spec yet
 syncrepl rid=1
                 provider=@URI2@
-                updatedn="cn=Replica,dc=example,dc=com"
                 binddn="cn=Replica,dc=example,dc=com"
                 bindmethod=simple
                 credentials=secret
index d63f5f7084e0189e3351582c8d6b5281c46cc1ac..44794dc378cc2df9b4ca6d9e5a99a1a8d090faf8 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 80db9cc0e6e15534b3789a3e013bf24298f0e890..20d4ad379c4452cce2433cc03b3df622be5c94d5 100644 (file)
@@ -3,7 +3,7 @@
  kurt Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 5c99d08fad505820a950d79d37814ff772cf620b..abc0e2046ca33307e812e0a06b09b9c579a81124 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 90df2ada70ef0d81b8a149cdf1fdc035ec572c11..3517cdc2db3b2b7a14971a6eeae10ea31c25522e 100644 (file)
@@ -3,7 +3,7 @@
  t Exp $
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2003 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e1240ca268420094f52b2acb4f8e952ba3c22266..1dd93863542a008bec71d6ea9c67edd54d830ac6 100644 (file)
@@ -21,6 +21,8 @@ documentTitle: book2
 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
 documentIdentifier: document 2
 
+# refldap://localhost:9010/dc=example,dc=com??one
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -39,7 +41,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com
 givenName: Torvlobnor
 telephoneNumber: 545-4563
 
-# refldap://localhost/dc=example,dc=com??one
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
 
 # Testing subtree search...
 dn: documentTitle=book1,dc=example,dc=com
@@ -57,6 +63,8 @@ documentTitle: book2
 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
 documentIdentifier: document 2
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: dc=example,dc=com
 objectClass: organization
 objectClass: dcObject
@@ -81,10 +89,68 @@ seeAlso: documentTitle=book1,dc=example,dc=com
 givenName: Torvlobnor
 telephoneNumber: 545-4563
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+# Testing subtree search with manageDSAit...
+dn: documentTitle=book1,dc=example,dc=com
+objectClass: document
+description: abstract1
+documentTitle: book1
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com
+documentIdentifier: document 1
+
+dn: documentTitle=book2,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: book2
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: ou=Referral,dc=example,dc=com
+objectClass: referral
+objectClass: extensibleObject
+ou: Referral
+ref: ldap://localhost:9010/
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=book1,dc=example,dc=com
+seeAlso: documentTitle=book2,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: cn=Torvlobnor Puzdoy,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Torvlobnor Puzdoy
+sn: Puzdoy
+seeAlso: documentTitle=book1,dc=example,dc=com
+givenName: Torvlobnor
+telephoneNumber: 545-4563
+
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
 
 # Testing invalid filter...
 # Testing exact search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -96,6 +162,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing substrings initial search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -107,6 +175,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing substrings any search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -118,6 +188,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing substrings final search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -129,6 +201,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing approx search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -140,6 +214,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing extensible filter search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -151,6 +227,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing search for telephoneNumber...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -162,6 +240,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing AND search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -180,6 +260,8 @@ o: Example
 dc: example
 
 # Testing OR search...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -221,7 +303,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com
 givenName: Torvlobnor
 telephoneNumber: 545-4563
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
 
 # Testing NOT search on objectClass...
 dn: documentTitle=book1,dc=example,dc=com
@@ -239,6 +325,8 @@ documentTitle: book2
 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
 documentIdentifier: document 2
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: dc=example,dc=com
 objectClass: organization
 objectClass: dcObject
@@ -261,6 +349,8 @@ documentTitle: book2
 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
 documentIdentifier: document 2
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
 cn: Mitya Kovalev
@@ -279,7 +369,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com
 givenName: Torvlobnor
 telephoneNumber: 545-4563
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
 
 # Testing attribute inheritance in filter...
 dn: dc=example,dc=com
@@ -307,7 +401,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com
 givenName: Torvlobnor
 telephoneNumber: 545-4563
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
 
 # Testing "auxiliary" objectClass in filter...
 dn: dc=example,dc=com
@@ -317,14 +415,14 @@ o: Example
 dc: example
 
 # Testing hasSubordinates in filter...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: dc=example,dc=com
 objectClass: organization
 objectClass: dcObject
 o: Example
 dc: example
 
-# refldap://localhost/dc=example,dc=com??sub
-
 # Testing entryUUID in filter...
 dn: cn=Mitya Kovalev,dc=example,dc=com
 objectClass: inetOrgPerson
@@ -337,6 +435,8 @@ telephoneNumber: 222-3234
 telephoneNumber: 332-2334
 
 # Testing attribute inheritance in requested attributes...
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: cn=Mitya Kovalev,dc=example,dc=com
 cn: Mitya Kovalev
 sn: Kovalev
@@ -349,6 +449,8 @@ objectClass: document
 dn: documentTitle=book2,dc=example,dc=com
 objectClass: document
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: dc=example,dc=com
 objectClass: organization
 objectClass: dcObject
@@ -359,7 +461,8 @@ objectClass: inetOrgPerson
 dn: cn=Torvlobnor Puzdoy,dc=example,dc=com
 objectClass: inetOrgPerson
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
 
 # Testing operational attributes in request...
 dn: documentTitle=book1,dc=example,dc=com
@@ -376,6 +479,8 @@ subschemaSubentry: cn=Subschema
 hasSubordinates: FALSE
 entryUUID: 00000002-0000-0002-0000-000000000000
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
 dn: dc=example,dc=com
 structuralObjectClass: organization
 entryDN: dc=example,dc=com
@@ -397,5 +502,10 @@ subschemaSubentry: cn=Subschema
 hasSubordinates: FALSE
 entryUUID: 00000001-0000-0002-0000-000000000000
 
-# refldap://localhost/dc=example,dc=com??sub
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+structuralObjectClass: inetOrgPerson
+entryDN: cn=Akakiy Zinberstein,dc=example,dc=com
+subschemaSubentry: cn=Subschema
+hasSubordinates: FALSE
+entryUUID: 00000001-0000-0003-0000-000000000000
 
index 3e89e3fb15234648e64ea2b9b1a031912d193630..4573653d2d0f60bb13f7124715f19f2ad9b01416 100644 (file)
@@ -1,3 +1,324 @@
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+dn: documentTitle=book1,dc=example,dc=com
+objectClass: document
+description: abstract1
+documentTitle: book1
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com
+documentIdentifier: document 1
+
+dn: documentTitle=book2,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: book2
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=book1,dc=example,dc=com
+seeAlso: documentTitle=book2,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: cn=Torvlobnor Puzdoy,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Torvlobnor Puzdoy
+sn: Puzdoy
+seeAlso: documentTitle=book1,dc=example,dc=com
+givenName: Torvlobnor
+telephoneNumber: 545-4563
+
+# refldap://localhost:9010/dc=example,dc=com??sub
+
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+dn: o=An Org,dc=example,dc=com
+objectClass: organization
+o: An Org
+
+dn: documentTitle=book1,dc=example,dc=com
+objectClass: document
+description: abstract1
+documentTitle: book1
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com
+documentIdentifier: document 1
+
+dn: documentTitle=book2,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: book2
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Lev Tolstoij,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Lev Tolstoij
+sn: Tolstoij
+seeAlso: documentTitle=War and Peace,dc=example,dc=com
+givenName: Lev
+telephoneNumber: +39 02 XXXX YYYY
+telephoneNumber: +39 02 XXXX ZZZZ
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=book1,dc=example,dc=com
+seeAlso: documentTitle=book2,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: cn=Some One,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: simpleSecurityObject
+cn: Some One
+sn: One
+givenName: Some
+telephoneNumber: +1 800 900 1234
+telephoneNumber: +1 800 900 1235
+
+dn: dc=subnet,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet
+dc: subnet
+
+dn: cn=SubNet User,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: SubNet User
+sn: User
+givenName: SubNet
+
+dn: dc=subnet2,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet 2
+dc: subnet 2
+
+dn: cn=Torvlobnor Puzdoy,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Torvlobnor Puzdoy
+sn: Puzdoy
+seeAlso: documentTitle=book1,dc=example,dc=com
+givenName: Torvlobnor
+telephoneNumber: 545-4563
+
+dn: documentTitle=War and Peace,dc=example,dc=com
+objectClass: document
+description: Historical novel
+documentTitle: War and Peace
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentIdentifier: document 3
+
+# refldap://localhost:9010/dc=example,dc=com??sub
+
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+dn: o=An Org,dc=example,dc=com
+objectClass: organization
+o: An Org
+
+dn: documentTitle=book1,dc=example,dc=com
+objectClass: document
+description: abstract1
+documentTitle: book1
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com
+documentIdentifier: document 1
+
+dn: documentTitle=book2,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: book2
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Lev Tolstoij,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Lev Tolstoij
+sn: Tolstoij
+seeAlso: documentTitle=book1,dc=example,dc=com
+seeAlso: documentTitle=book2,dc=example,dc=com
+seeAlso: documentTitle=War and Peace,dc=example,dc=com
+givenName: Lev
+telephoneNumber: +39 02 XXXX ZZZZ
+telephoneNumber: +39 333 ZZZ 1234
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=book1,dc=example,dc=com
+seeAlso: documentTitle=book2,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: +1 800 123 4567
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: cn=Some One,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: simpleSecurityObject
+cn: Some One
+sn: One
+givenName: Some
+
+dn: dc=subnet,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet
+dc: subnet
+
+dn: cn=SubNet User,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: SubNet User
+sn: User
+givenName: SubNet
+
+dn: dc=subnet2,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet 2
+dc: subnet 2
+
+dn: cn=Torvlobnor Puzdoy,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Torvlobnor Puzdoy
+sn: Puzdoy
+seeAlso: documentTitle=book1,dc=example,dc=com
+givenName: Torvlobnor
+telephoneNumber: 545-4563
+
+dn: documentTitle=War and Peace,dc=example,dc=com
+objectClass: document
+description: Historical novel
+documentTitle: War and Peace
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentIdentifier: document 3
+
+# refldap://localhost:9010/dc=example,dc=com??sub
+
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+dn: o=An Org,dc=example,dc=com
+objectClass: organization
+o: An Org
+
+dn: documentTitle=book2,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: book2
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Lev Tolstoij,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Lev Tolstoij
+sn: Tolstoij
+seeAlso: documentTitle=book2,dc=example,dc=com
+seeAlso: documentTitle=War and Peace,dc=example,dc=com
+givenName: Lev
+telephoneNumber: +39 02 XXXX ZZZZ
+telephoneNumber: +39 333 ZZZ 1234
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=book2,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: +1 800 123 4567
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: cn=Some One,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: simpleSecurityObject
+cn: Some One
+sn: One
+givenName: Some
+
+dn: dc=subnet,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet
+dc: subnet
+
+dn: cn=SubNet User,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: SubNet User
+sn: User
+givenName: SubNet
+
+dn: documentTitle=War and Peace,dc=example,dc=com
+objectClass: document
+description: Historical novel
+documentTitle: War and Peace
+documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentIdentifier: document 3
+
+# refldap://localhost:9010/dc=example,dc=com??sub
+
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
 dn: dc=example,dc=com
 objectClass: organization
 objectClass: dcObject
@@ -62,3 +383,92 @@ documentTitle: War and Peace
 documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
 documentIdentifier: document 3
 
+# refldap://localhost:9010/dc=example,dc=com??sub
+
+# Using ldapsearch to retrieve the modified entry...
+dn: ou=Referral,dc=example,dc=com
+objectClass: referral
+objectClass: extensibleObject
+ou: Referral
+ref: ldap://localhost:9009/
+
+# Using ldapsearch to retrieve the renamed entry...
+dn: ou=Renamed Referral,dc=example,dc=com
+objectClass: referral
+objectClass: extensibleObject
+ou: Renamed Referral
+ref: ldap://localhost:9009/
+
+# Using ldapsearch to retrieve all the entries...
+dn: cn=Akakiy Zinberstein,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Akakiy Zinberstein
+sn: Zinberstein
+givenName: Akakiy
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example
+dc: example
+
+dn: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Lev Tolstoij
+sn: Tolstoij
+seeAlso: documentTitle=Renamed Book,dc=example,dc=com
+seeAlso: documentTitle=War and Peace,dc=example,dc=com
+givenName: Lev
+telephoneNumber: +39 02 XXXX ZZZZ
+telephoneNumber: +39 333 ZZZ 1234
+
+dn: cn=Mitya Kovalev,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Mitya Kovalev
+sn: Kovalev
+seeAlso: documentTitle=Renamed Book,dc=example,dc=com
+givenName: Mitya
+telephoneNumber: +1 800 123 4567
+telephoneNumber: 222-3234
+telephoneNumber: 332-2334
+
+dn: documentTitle=Renamed Book,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: Renamed Book
+documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentIdentifier: document 2
+
+dn: o=Renamed Org,dc=example,dc=com
+objectClass: organization
+o: Renamed Org
+
+dn: cn=Some One,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: simpleSecurityObject
+cn: Some One
+sn: One
+givenName: Some
+
+dn: dc=subnet,dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: SubNet
+dc: subnet
+
+dn: cn=SubNet User,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: SubNet User
+sn: User
+givenName: SubNet
+
+dn: documentTitle=War and Peace,dc=example,dc=com
+objectClass: document
+description: Historical novel
+documentTitle: War and Peace
+documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
+documentIdentifier: document 3
+
+# refldap://localhost:9009/dc=example,dc=com??sub
+
diff --git a/tests/data/test-chain1.ldif b/tests/data/test-chain1.ldif
new file mode 100644 (file)
index 0000000..7f419fd
--- /dev/null
@@ -0,0 +1,366 @@
+#LEAD COMMENT
+dn: dc=example,dc=com
+#EMBEDDED COMMENT
+objectclass: top
+objectclass: organization
+objectclass: domainRelatedObject
+objectclass: dcobject
+dc: example
+l: Anytown, Michigan
+st: Michigan
+o: Example, Inc.
+o: EX
+o: Ex.
+description: The Example, Inc. at Anytown
+postaladdress: Example, Inc. $ 535 W. William St. $ Anytown, MI 48109 $ US
+telephonenumber: +1 313 555 1817
+associateddomain: example.com
+
+dn: ou=People,dc=example,dc=com
+objectclass: organizationalUnit
+objectclass: extensibleObject
+ou: People
+uidNumber: 0
+gidNumber: 0
+
+dn: ou=Groups,dc=example,dc=com
+objectclass: referral
+objectclass: extensibleobject
+ou: Groups
+ref: @URI2@ou=Groups,dc=example,dc=com
+
+dn: ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: organizationalUnit
+ou: Alumni Association
+
+dn: ou=Information Technology Division,ou=People,dc=example,dc=com
+objectclass: organizationalUnit
+ou: Information Technology Division
+description:: aMODwoPDgsKCw4PCgsOCwotFVlZQw4PCg8OCwoPDg8KCw4LCv0zDg8KDw4LCgsOD
+ woLDgsKKT8ODwoPDgsKDw4PCgsOCwqs6w4PCg8OCwoLDg8KCw4LCjUQkw4PCg8OCwoLDg8KCw4LCi
+ 01QUcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4
+ LCgsODwoLDgsKLRCQoZitEJMODwoPDgsKCw4PCgsOCwrfDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoP
+ Dg8KCw4LCgcODwoPDgsKDw4PCgsOCwqHDg8KDw4LCgsODwoLDgsKLRCQkZitEJMODwoPDgsKCw4PC
+ gsOCwrfDg8KDw4LCg8ODwoLDgsKQw4PCg8OCwoPDg8KCw4LCisODwoPDgsKCw4PCgsOCwotFUVZqU
+ MODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKAw4PCg8OCwoLDg8KCw4LCik85dCTDg8KDw4
+ LCgsODwoLDgsKFQ8ODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4L
+ Cvzl0JMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPD
+ gsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKLRCTDg8KDw4LCgsODwoLDgsKDw4PCg8OCwoLDg8KCw
+ 4LCuMODwoPDgsKDw4PCgsOCwoR0Q8ODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LChMODwo
+ PDgsKDw4PCgsOCwoFOdTrDg8KDw4LCg8ODwoLDgsKHw4PCg8OCwoPDg8KCw4LChMODwoPDgsKDw4P
+ CgsOCwoFOw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwrtHw4PCg8OCwoLDg8KCw4LChcOD
+ woPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsK4dMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODw
+ oLDgsKtR8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwo
+ PDgsKDw4PCgsOCwr9SfGrDg8KDw4LCgsODwoLDgsKLQGgxw4PCg8OCwoPDg8KCw4LCoWhQw4PCg8O
+ CwoPDg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKT8ODwoPDgsKCw4PCgsOC
+ wotEJDDDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHTDg8KDw4LCgsODwoLDgsKDw4PCg
+ 8OCwoPDg8KCw4LCuHXDg8KDw4LCgsODwoLDgsKLRCRqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4
+ PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpPDg8K
+ Dw4LCg8ODwoLDgsKQXV9eW8ODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoPD
+ g8KCw4LCgsODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODw
+ oPDgsKDw4PCgsOCwozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgs
+ OCwoxWV8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKxw4PCg8OCwoLDg8KCw4LCi3wkw4P
+ Cg8OCwoLDg8KCw4LCjcODwoPDgsKCw4PCgsOCwofDg8KDw4LCg8ODwoLDgsKof8ODwoPDgsKDw4PC
+ gsOCwr/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCg8ODwoPDgsKDw4PCgsOCwrh5w4PCg
+ 8OCwoLDg8KCw4LChzQzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PCgsOCworDg8KDw4LCgsODwo
+ LDgsKIw4PCg8OCwoLDg8KCw4LCuDFBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNdDF
+ Bw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPD
+ gsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw
+ 4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgs
+ KCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKAdcODwoPDgsKDw4PCgsOCwqhtw4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCsMODwoPDgsKC
+ w4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCt
+ sODwoPDgsKDw4PCgsOCwq7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4
+ PCgsOCwoPDg8KDw4LCg8ODwoLDgsKoZsODwoPDgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4w4P
+ Cg8OCwoLDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwpUzw4PCg8OCwoPDg8KCw4LCicODwoPDgsKCw4PC
+ gsOCworDg8KDw4LCgsODwoLDgsKISDJBw4PCg8OCwoPDg8KCw4LCvyTDg8KDw4LCgsODwoLDgsKNN
+ DJBw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwo
+ PDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8O
+ DwoPDgsKDw4PCgsOCwojDg8KDw4LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCnEzDg8KDw4LCgsOD
+ woLDgsKLSEBmw4PCg8OCwoLDg8KCw4LCg3lwdSTDg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw
+ 4LCv8ODwoPDgsKCw4PCgsOCwobDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwp/Dg8KDw4LCgsODwoLDgsKBw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwoj
+ Dg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCwpPDg8KDw4LCgsOD
+ woLDgsKBw4PCg8OCwoPDg8KCw4LCv1rDg8KDw4LCgsODwoLDgsKAw4PCg8OCwoLDg8KCw4LChMODw
+ oPDgsKCw4PCgsOCwodqw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwoBqaMODwoPDgsKCw4
+ PCgsOCwpBQw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDIMODwoPDgsKCw4PCgsOCwopPw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKOacODwoPDgsKCw4PCgsOCwrhf
+ XsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCw
+ oLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKGw4PCg8OCwoLDg8KCw4LCgM
+ ODwoPDgsKCw4PCgsOCwoRJw4PCg8OCwoLDg8KCw4LCgcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsO
+ DwoLDgsKIw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQ9w4PCg8OCwoLDg8KCw4LCgcOD
+ woPDgsKDw4PCgsOCwr9aw4PCg8OCwoLDg8KCw4LCgMODwoPDgsKCw4PCgsOCwoQxw4PCg8OCwoLDg
+ 8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwoM9w4PCg8OCwoPDg8KCw4LCm0
+ 7Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsK
+ Cw4PCgsOCwrhfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODw
+ oPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgs
+ OCwo7Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoLDg8KCw4LCkMODwoPDgsKDw4PCgsOCwojDg8KDw4L
+ CgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsK+
+ S8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKww4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKDw
+ 4PCgsOCwoTDg8KDw4LCgsODwoLDgsKKT1DDg8KDw4LCg8ODwoLDgsKoRsODwoPDgsKCw4PCgsOCwo
+ vDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwrZ0Y8ODwoPDgsK
+ Cw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK/dF/Dg8KDw4LCgsODwoLDgsKhdHpPw4PCg8OCwoLDg8KC
+ w4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PCg8OCwoPDg8KCw4LCqC1Jw4PCg8OCwoLDg8KCw4LChcODw
+ oPDgsKDw4PCgsOCwoB1RMODwoPDgsKCw4PCgsOCwqFwek/Dg8KDw4LCgsODwoLDgsKLw4PCg8OCwo
+ PDg8KCw4LCj1DDg8KDw4LCg8ODwoLDgsKoScODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsK
+ AdTPDg8KDw4LCgsODwoLDgsKhbHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo5Qw4PC
+ g8OCwoPDg8KCw4LCqEnDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHXDg8KDw4LCgsODw
+ oLDgsKhaHpPw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo9Qw4PCg8OCwoPDg8KCw4LCqM
+ ODwoPDgsKDw4PCgsOCwrpIw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoB1M8ODwoPDgsK
+ Dw4PCgsOCwoBfXsODwoPDgsKDw4PCgsOCwoLDg8KDw4LCgsODwoLDgsK4X17Dg8KDw4LCg8ODwoLD
+ gsKCw4PCg8OCwoLDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgjPDg8KDw4LCg8ODwoLDgsKAX17Dg
+ 8KDw4LCg8ODwoLDgsKCw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo7Dg8KDw4LCg8ODwo
+ LDgsKoJ8ODwoPDgsKDw4PCgsOCwq3Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODwoP
+ DgsKCw4PCgsOCwoPDg8KDw4LCg8ODwoLDgsK4aHU5w4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PC
+ gsOCwovDg8KDw4LCg8ODwoLDgsKOw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpDDg8KDw
+ 4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgs
+ KIw4PCg8OCwoPDg8KCw4LCv8ODwoPDgsKCw4PCgsOCwpLDg8KDw4LCg8ODwoLDgsKEw4PCg8OCwoL
+ Dg8KCw4LChcODwoPDgsKDw4PCgsOCwoB0IcODwoPDgsKCw4PCgsOCwovDg8KDw4LCgsODwoLDgsKA
+ w4PCg8OCwoPDg8KCw4LCtMODwoPDgsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKAdGbDg8KDw4LCg
+ sODwoLDgsKLQGY9dGY9dTPDg8KDw4LCg8ODwoLDgsKAX17Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwo
+ LDg8KCw4LCuF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwrhfXsODwoPDgsKDw4PCgsO
+ CwoIzw4PCg8OCwoPDg8KCw4LCgF9ew4PCg8OCwoPDg8KCw4LCgsODwoPDgsKCw4PCgsOCwovDg8KD
+ w4LCg8ODwoLDgsK/Ri9BUC9BRi9BWi9BZC9BWzBBZC9BZTBBZC9BZC9BbzBBZC9BeTBBw4PCg8OCw
+ oLDg8KCw4LCgzBBMUFhMUFrMUE=
+description:: UF7Dg8KDw4LCg8ODwoLDgsKCw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOC
+ wozDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg
+ 8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCqFDDg8KDw4LCg8ODwoLDgsKpRsODwoPDgsKDw4PCgsOCwo
+ zDg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKDw4PCgsOCwozDg8KDw4LCg8O
+ DwoLDgsKMw4PCg8OCwoPDg8KCw4LCjMODwoPDgsKCw4PCgsOCwotEJCDDg8KDw4LCgsODwoLDgsKD
+ w4PCg8OCwoPDg8KCw4LCrMODwoPDgsKCw4PCgsOCwotUJCRTw4PCg8OCwoLDg8KCw4LCi1wkJFbDg
+ 8KDw4LCgsODwoLDgsKJTCRXVVBSU8ODwoPDgsKDw4PCgsOCwqjDg8KDw4LCg8ODwoLDgsKdT8ODwo
+ PDgsKCw4PCgsOCwoN8JDB1w4PCg8OCwoPDg8KCw4LCh8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8O
+ DwoLDgsKBTsODwoPDgsKDw4PCgsOCwqktw4PCg8OCwoLDg8KCw4LCg3wkMHTDg8KDw4LCgsODwoLD
+ gsKDfCQww4PCg8OCwoLDg8KCw4LChTPDg8KDw4LCg8ODwoLDgsK2OTXDg8KDw4LCg8ODwoLDgsKAw
+ 4PCg8OCwoPDg8KCw4LCgU7Dg8KDw4LCgsODwoLDgsKEIMODwoPDgsKCw4PCgsOCwqFIw4PCg8OCwo
+ PDg8KCw4LChU7Dg8KDw4LCgsODwoLDgsKJNcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCg8ODwoLDgsK
+ BTsODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsKIw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKD
+ w4PCgsOCwr9TXMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw
+ 4LChMODwoPDgsKCw4PCgsOCwpHDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLIEjDg8
+ KDw4LCg8ODwoLDgsKFTlDDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ngw4PCg8OCwoL
+ Dg8KCw4LCi8ODwoPDgsKDw4PCgsOCwpjDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCm3Rx
+ w4PCg8OCwoLDg8KCw4LCizvDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi8ODwoPDgsKDw
+ 4PCgsOCwr9XaMODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGdGLDg8KDw4LCgsODwo
+ LDgsKLf2zDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCi1D
+ Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8OD
+ woLDgsKow4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwq10SmgoT03Dg8KDw4LCgsODwoLDg
+ sKLw4PCg8OCwoPDg8KCw4LCjcODwoPDgsKDw4PCgsOCwqggTMODwoPDgsKCw4PCgsOCwoXDg8KDw4
+ LCg8ODwoLDgsKAdDrDg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLTSBQUcODwoPDgsK
+ Dw4PCgsOCwr/Dg8KDw4LCg8ODwoLDgsKMw4PCg8OCwoLDg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKL
+ RCQoZitEJCDDg8KDw4LCgsODwoLDgsK3w4PCg8OCwoPDg8KCw4LCiMODwoPDgsKDw4PCgsOCwoHDg
+ 8KDw4LCg8ODwoLDgsKhw4PCg8OCwoLDg8KCw4LCi0QkJGYrRCTDg8KDw4LCgsODwoLDgsK3w4PCg8
+ OCwoPDg8KCw4LCkMODwoPDgsKDw4PCgsOCworDg8KDw4LCgsODwoLDgsKLRSBRVmpQw4PCg8OCwoP
+ Dg8KCw4LCv8ODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsODwoLDgsKKTzl0JHXDg8KDw4LCgsODwoLD
+ gsKhOXQkw4PCg8OCwoLDg8KCw4LChW/Dg8KDw4LCg8ODwoLDgsK/w4PCg8OCwoPDg8KCw4LCv8ODw
+ oPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKhRMODwoPDgsKDw4PCgsOCwoVOw4PCg8OCwoLDg8
+ KCw4LCi8ODwoPDgsKDw4PCgsOCwojDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCv1Ncw4P
+ Cg8OCwoLDg8KCw4LCiUQkw4PCg8OCwoLDg8KCw4LChcODwoPDgsKDw4PCgsOCwoDDg8KDw4LCgsOD
+ woLDgsKEw4PCg8OCwoPDg8KCw4LCtjPDg8KDw4LCg8ODwoLDgsK2w4PCg8OCwoLDg8KCw4LCjUQkw
+ 4PCg8OCwoLDg8KCw4LCiyBEw4PCg8OCwoPDg8KCw4LChU5Qw4PCg8OCwoLDg8KCw4LCi8ODwoPDgs
+ KDw4PCgsOCwr9TYMODwoPDgsKCw4PCgsOCwovDg8KDw4LCg8ODwoLDgsK4w4PCg8OCwoLDg8KCw4L
+ ChcODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKEw4PCg8OCwoPDg8KCw4LCkMODwoPDgsKC
+ w4PCgsOCwovDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCj8ODwoPDgsKDw4PCgsOCwr9Ta
+ MODwoPDgsKCw4PCgsOCwolEJDvDg8KDw4LCg8ODwoLDgsKGw4PCg8OCwoLDg8KCw4LChMODwoPDgs
+ KCw4PCgsOCwr3Dg8KDw4LCgsODwoLDgsKNRCTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4L
+ Cj1DDg8KDw4LCg8ODwoLDgsK/U2zDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoPDg8KCw4LCqMODwoPD
+ gsKCw4PCgsOCwoXDg8KDw4LCg8ODwoLDgsKtw4PCg8OCwoLDg8KCw4LChMODwoPDgsKCw4PCgsOCw
+ p9oMMODwoPDgsKDw4PCgsOCwolMw4PCg8OCwoLDg8KCw4LCi8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4
+ LCg8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCq0vDg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4L
+ CgMODwoPDgsKCw4PCgsOCwoTDg8KDw4LCgsODwoLDgsKLw4PCg8OCwoLDg8KCw4LCi0QkOcODwoPD
+ gsKCw4PCgsOCwrDDg8KDw4LCg8ODwoLDgsKEdEU5w4PCg8OCwoLDg8KCw4LCtTR0PcODwoPDgsKCw
+ 4PCgsOCwovDg8KDw4LCg8ODwoLDgsKNw4PCg8OCwoPDg8KCw4LCqMODwoPDgsKDw4PCgsOCwo5Lw4
+ PCg8OCwoLDg8KCw4LCi0AgUMODwoPDgsKDw4PCgsOCwr/Dg8KDw4LCgsODwoLDgsKsw4PCg8OCwoL
+ Dg8KCw4LCik/Dg8KDw4LCgsODwoLDgsKFw4PCg8OCwoPDg8KCw4LCgHUow4PCg8OCwoLDg8KCw4LC
+ i8ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCgsODwoLDgsKJw4PCg8OCwoLDg8KCw4LCtTTDg8KDw4LCg
+ 8ODwoLDgsKow4PCg8OCwoPDg8KCw4LCl8ODwoPDgsKDw4PCgsOCwrtWw4PCg8OCwoLDg8KCw4LCi8
+ ODwoPDgsKDw4PCgsOCwo3Dg8KDw4LCg8ODwoLDgsKow4PCg8OCwoLDg8KCw4LCnw==
+
+dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
+ dc=com
+objectclass: OpenLDAPperson
+cn: Barbara Jensen
+cn: Babs Jensen
+sn:: IEplbnNlbiA=
+uid: bjensen
+title: Mythical Manager, Research Systems
+postaladdress: ITD Prod Dev & Deployment $ 535 W. William St. Room 4212 $ Anyt
+ own, MI 48103-4943
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+userpassword:: YmplbnNlbg==
+mail: bjensen@mailgw.example.com
+homepostaladdress: 123 Wesley $ Anytown, MI 48103
+description: Mythical manager of the rsdd unix project
+drink: water
+homephone: +1 313 555 2333
+pager: +1 313 555 3233
+facsimiletelephonenumber: +1 313 555 2274
+telephonenumber: +1 313 555 9022
+
+dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
+ =com
+objectclass: OpenLDAPperson
+cn: Bjorn Jensen
+cn: Biiff Jensen
+sn: Jensen
+uid: bjorn
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+userpassword:: Ympvcm4=
+homepostaladdress: 19923 Seven Mile Rd. $ South Lyon, MI 49999
+drink: Iced Tea
+description: Hiker, biker
+title: Director, Embedded Systems
+postaladdress: Info Tech Division $ 535 W. William St. $ Anytown, MI 48103
+mail: bjorn@mailgw.example.com
+homephone: +1 313 555 5444
+pager: +1 313 555 4474
+facsimiletelephonenumber: +1 313 555 2177
+telephonenumber: +1 313 555 0355
+
+dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: Dorothy Stevens
+cn: Dot Stevens
+sn: Stevens
+uid: dots
+title: Secretary, UM Alumni Association
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Lemonade
+homepostaladdress: 377 White St. Apt. 3 $ Anytown, MI 48104
+description: Very tall
+facsimiletelephonenumber: +1 313 555 3223
+telephonenumber: +1 313 555 3664
+mail: dots@mail.alumni.example.com
+homephone: +1 313 555 0454
+
+dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: James A Jones 1
+cn: James Jones
+cn: Jim Jones
+sn: Jones
+uid: jaj
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+userpassword:: amFq
+homepostaladdress: 3882 Beverly Rd. $ Anytown, MI 48105
+homephone: +1 313 555 4772
+description: Outstanding
+title: Mad Cow Researcher, UM Alumni Association
+pager: +1 313 555 3923
+mail: jaj@mail.alumni.example.com
+facsimiletelephonenumber: +1 313 555 4332
+telephonenumber: +1 313 555 0895
+
+dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example
+ ,dc=com
+objectclass: OpenLDAPperson
+cn: James A Jones 2
+cn: James Jones
+cn: Jim Jones
+sn: Doe
+uid: jjones
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+homepostaladdress: 933 Brooks $ Anytown, MI 48104
+homephone: +1 313 555 8838
+title: Senior Manager, Information Technology Division
+description: Not around very much
+mail: jjones@mailgw.example.com
+postaladdress: Info Tech Division $ 535 W William $ Anytown, MI 48103
+pager: +1 313 555 2833
+facsimiletelephonenumber: +1 313 555 8688
+telephonenumber: +1 313 555 7334
+
+dn: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: Jane Doe
+cn: Jane Alverson
+sn: Doe
+uid: jdoe
+title: Programmer Analyst, UM Alumni Association
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+homepostaladdress: 123 Anystreet $ Anytown, MI 48104
+drink: diet coke
+description: Enthusiastic
+mail: jdoe@woof.net
+homephone: +1 313 555 5445
+pager: +1 313 555 1220
+facsimiletelephonenumber: +1 313 555 2311
+telephonenumber: +1 313 555 4774
+
+dn: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: Jennifer Smith
+cn: Jen Smith
+sn: Smith
+uid: jen
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+drink: Sam Adams
+homepostaladdress: 1000 Maple #44 $ Anytown, MI 48103
+title: Telemarketer, UM Alumni Association
+mail: jen@mail.alumni.example.com
+homephone: +1 313 555 2333
+pager: +1 313 555 6442
+facsimiletelephonenumber: +1 313 555 2756
+telephonenumber: +1 313 555 8232
+
+dn: cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: John Doe
+cn: Jonathon Doe
+sn: Doe
+uid: johnd
+postaladdress: ITD $ 535 W. William $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+homepostaladdress: 912 East Bllvd $ Anytown, MI 48104
+title: System Administrator, Information Technology Division
+description: overworked!
+mail: johnd@mailgw.example.com
+homephone: +1 313 555 3774
+pager: +1 313 555 6573
+facsimiletelephonenumber: +1 313 555 4544
+telephonenumber: +1 313 555 9394
+
+dn: cn=Manager,dc=example,dc=com
+objectclass: person
+cn: Manager
+cn: Directory Manager
+cn: Dir Man
+sn: Manager
+description: Manager of the directory
+userpassword:: c2VjcmV0
+
+dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: Mark Elliot
+cn: Mark A Elliot
+sn: Elliot
+uid: melliot
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+homepostaladdress: 199 Outer Drive $ Ypsilanti, MI 48198
+homephone: +1 313 555 0388
+drink: Gasoline
+title: Director, UM Alumni Association
+mail: melliot@mail.alumni.example.com
+pager: +1 313 555 7671
+facsimiletelephonenumber: +1 313 555 7762
+telephonenumber: +1 313 555 4177
+
+dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+objectclass: OpenLDAPperson
+cn: Ursula Hampster
+sn: Hampster
+uid: uham
+title: Secretary, UM Alumni Association
+postaladdress: Alumni Association $ 111 Maple St $ Anytown, MI 48109
+seealso: cn=All Staff,ou=Groups,dc=example,dc=com
+homepostaladdress: 123 Anystreet $ Anytown, MI 48104
+mail: uham@mail.alumni.example.com
+homephone: +1 313 555 8421
+pager: +1 313 555 2844
+facsimiletelephonenumber: +1 313 555 9700
+telephonenumber: +1 313 555 5331
diff --git a/tests/data/test-chain2.ldif b/tests/data/test-chain2.ldif
new file mode 100644 (file)
index 0000000..fe0cd3e
--- /dev/null
@@ -0,0 +1,83 @@
+#LEAD COMMENT
+dn: dc=example,dc=com
+#EMBEDDED COMMENT
+objectclass: top
+objectclass: organization
+objectclass: domainRelatedObject
+objectclass: dcobject
+dc: example
+l: Anytown, Michigan
+st: Michigan
+o: Example, Inc.
+o: EX
+o: Ex.
+description: The Example, Inc. at Anytown
+postaladdress: Example, Inc. $ 535 W. William St. $ Anytown, MI 48109 $ US
+telephonenumber: +1 313 555 1817
+associateddomain: example.com
+
+dn: ou=People,dc=example,dc=com
+objectClass: referral
+objectclass: extensibleObject
+ou: People
+ref: @URI1@ou=People,dc=example,dc=com
+
+dn: ou=Groups,dc=example,dc=com
+objectclass: organizationalUnit
+ou: Groups
+
+dn: cn=All Staff,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+member: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=exam
+ ple,dc=com
+member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc
+ =com
+member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=exa
+ mple,dc=com
+member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=exampl
+ e,dc=com
+owner: cn=Manager,dc=example,dc=com
+cn: All Staff
+description: Everyone in the sample data
+objectclass: groupofnames
+
+dn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
+member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All Alumni Assoc Staff
+cn: Alumni Assoc Staff
+objectclass: groupofnames
+
+dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
+owner: cn=Manager,dc=example,dc=com
+description: All ITD Staff
+cn: ITD Staff
+objectclass: groupofuniquenames
+uniquemember: cn=Manager,dc=example,dc=com
+uniquemember: cn=Bjorn Jensen,OU=Information Technology Division,ou=People,dc=
+ example,dc=com
+uniquemember: cn=James A Jones 2,ou=Information Technology Division,ou=People,
+ dc=example,dc=com
+uniquemember: cn=John Doe,ou=Information Technology Division,ou=People,dc=exam
+ ple,dc=com
+
+dn: cn=Manager,dc=example,dc=com
+objectclass: person
+cn: Manager
+cn: Directory Manager
+cn: Dir Man
+sn: Manager
+description: Manager of the directory
+userpassword:: c2VjcmV0
index 0fca74166a7bde60a388dee6dcf67d0a8ef504fb..766ba1089bfec7b695dc805a0ad15491f0a188df 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 9e63c0a8320c1e7a0827d848db8b1e1d047ae1fb..39011cc1ece6ad5ddc05ff9a675bfe63e74f6d41 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 91473e6a62abcfec52ee24f71c8eee806ef5ad92..4b2377db56692a39d4b1e75cc81ed014b1cecb15 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index a2cc0b71665747a96be3a1815479c0d1884e327f..847785947ab07194e16ebe1344a11a9244657b50 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 54f4a2d1476879d48fd4469116e0d738a9ea718b..2ca60b4c0d5d0e9eddec6e52139fa00c1ec47ff8 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 83f6914c08d098f37b8ccf5032ff4ac38e0f8bec..bcc24a23810af417f91311f51b2275a97898bba0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 559a6c0cb6a534f8a84e3ad3157c754a599230bd..790b20dea676bb9e7b9996b2874b1171a07b089c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index bca80673c22dc5a2d750213f9a931dae112a56d0..2d3819870a63731e4b6d91638dcbb55b42bc9699 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
index 37aa4b66f5ee65e4125b4895aea698d9d4712fec..5b212f2386a8c1ed94c6cf14b1e70c71b9b83b81 100644 (file)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 7a90bcc9f15fdb5487e6e34162215f1dc2fc5559..5d7558c300c14d2e2ec59adb0daf85f4dad7a4cf 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 54f9fafc5e7fb125dbb95a1d97ccab2bef49d17e..baf1100f69ace70e2d36009cb73e24d140c25a41 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index abc94ea4359035c7339e44e388b9964e43781b87..139267d748ccd1809b1c966c7ce9fa646acf6407 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@ sed -e "s/@BACKEND@/${BACKEND}/"                      \
        -e "s/@RELAY@/${RELAY}/"                        \
        -e "s/^#${RELAY}#//"                            \
        -e "s/^#${BACKENDTYPE}#//"                      \
+       -e "s/^#${AC_glue}#//"                          \
        -e "s/^#${AC_ldap}#//"                          \
        -e "s/^#${AC_meta}#//"                          \
        -e "s/^#${AC_relay}#//"                         \
@@ -45,6 +46,7 @@ sed -e "s/@BACKEND@/${BACKEND}/"                      \
        -e "s/^#${AC_pcache}#//"                        \
        -e "s/^#${AC_ppolicy}#//"                       \
        -e "s/^#${AC_refint}#//"                        \
+       -e "s/^#${AC_syncprov}#//"                      \
        -e "s/^#${AC_unique}#//"                        \
        -e "s/^#${AC_rwm}#//"                   \
        -e "s/^#${MON}#//"                              \
index 98e89b9ae0641c4c6327cb11f274fd2ca3955c82..c083e666d8291cdf9718933ca8ff92211ca1f773 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -77,6 +77,8 @@ LDAPGLUECONF1=$DATADIR/slapd-ldapglue.conf
 LDAPGLUECONF2=$DATADIR/slapd-ldapgluepeople.conf
 LDAPGLUECONF3=$DATADIR/slapd-ldapgluegroups.conf
 RWMCONF=$DATADIR/slapd-relay.conf
+CHAINCONF1=$DATADIR/slapd-chain1.conf
+CHAINCONF2=$DATADIR/slapd-chain2.conf
 SQLCONF=$DATADIR/slapd-sql.conf
 
 CONF1=$TESTDIR/slapd.1.conf
@@ -160,6 +162,8 @@ LDIFLDAPGLUE1=$DATADIR/test-ldapglue.ldif
 LDIFLDAPGLUE2=$DATADIR/test-ldapgluepeople.ldif
 LDIFLDAPGLUE3=$DATADIR/test-ldapgluegroups.ldif
 LDIFCOMPMATCH=$DATADIR/test-compmatch.ldif
+LDIFCHAIN1=$DATADIR/test-chain1.ldif
+LDIFCHAIN2=$DATADIR/test-chain2.ldif
 SQLADD=$DATADIR/sql-add.ldif
 MONITOR=""
 REFDN="c=US"
@@ -230,6 +234,8 @@ IDASSERTOUT=$DATADIR/idassert.out
 LDAPGLUEOUT=$DATADIR/ldapglue.out
 LDAPGLUEANONYMOUSOUT=$DATADIR/ldapglueanonymous.out
 RELAYOUT=$DATADIR/relay.out
+CHAINOUT=$DATADIR/chain.out
+CHAINMODOUT=$DATADIR/chainmod.out
 SQLREAD=$DATADIR/sql-read.out
 SQLWRITE=$DATADIR/sql-write.out
 
index fd2caf2dfb3096016747c6b4f50973e589076933..6439908d002a8b884f8dd2299243728bf4fd9868 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 32486c8980eafe300331ff2ab5a961c81b1fbaef..5902876c174ef695afe7539181c79cbf54c98d4e 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 
-echo "Testing virtual naming context mapping with $RELAY backend..."
+echo "Using $RELAY backend..."
 echo ""
 
 echo "Starting slapd on TCP/IP port $PORT1..."
@@ -56,7 +56,7 @@ fi
 cat /dev/null > $SEARCHOUT
 
 BASEDN="dc=example,dc=com"
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -67,7 +67,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Example,c=US"
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -78,7 +78,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Esempio,c=IT"
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -89,7 +89,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Beispiel,c=DE"
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -104,7 +104,7 @@ fi
 #
 
 BASEDN="o=Beispiel,c=DE"
-echo "modifying database \"$BASEDN\"..."
+echo "Modifying database \"$BASEDN\"..."
 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
        -M >> $TESTOUT 2>&1 << EOMODS
 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
@@ -160,10 +160,10 @@ description: Just added as ldap://localhost.localdomain:389/ou=Referrals,$BASEDN
 dn: ou=Referrals,$BASEDN
 changetype: modify
 replace: ref
-ref: ldap://ldap.example.com:389/ou=Referrals,$BASEDN
+ref: ldap://localhost:9010/ou=Referrals,$BASEDN
 -
 add: description
-description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,$BASEDN
+description: ...and modified as ldap://localhost:9010/ou=Referrals,$BASEDN
 -
 EOMODS
 
@@ -174,7 +174,7 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -185,7 +185,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Esempio,c=IT"
-echo "searching base=\"$BASEDN\"..."
+echo "Searching base=\"$BASEDN\"..."
 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
 RC=$?
@@ -196,7 +196,7 @@ if test $RC != 0 ; then
 fi
 
 FILTER="(objectClass=referral)"
-echo "searching filter=\"$FILTER\""
+echo "Searching filter=\"$FILTER\""
 echo " attrs=\"'*' ref\""
 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
 echo "#        attrs=\"'*' ref\"" >> $SEARCHOUT
@@ -239,7 +239,7 @@ fi
 
 BASEDN="o=Example,c=US"
 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
-echo "searching filter=\"$FILTER\""
+echo "Searching filter=\"$FILTER\""
 echo " attrs=\"seeAlso\""
 echo " base=\"$BASEDN\"..."
 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
@@ -268,7 +268,7 @@ if test $? != 0 ; then
 fi
 
 BASEDN="o=Example,c=US"
-echo "changing password to database \"$BASEDN\"..."
+echo "Changing password to database \"$BASEDN\"..."
 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
        -s $PASSWD "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
        >> $TESTOUT 2>&1
@@ -280,7 +280,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Beispiel,c=DE"
-echo "binding with newly changed password to database \"$BASEDN\"..."
+echo "Binding with newly changed password to database \"$BASEDN\"..."
 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
        -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
        -w $PASSWD >> $TESTOUT 2>&1
@@ -292,7 +292,7 @@ if test $RC != 0 ; then
 fi
 
 BASEDN="o=Esempio,c=IT"
-echo "comparing to database \"$BASEDN\"..."
+echo "Comparing to database \"$BASEDN\"..."
 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
        "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
        "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
index 12715dbd7e2f45e7437695dccecb1f797d4fe0a7..47d13e1d6a39b13f570a03bd6620e778bb846755 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index a3281fd711460664ed55243388d4e853c2ef8b24..98ebe373267d89916dba9083ae2ce055e44d9cbc 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -110,6 +110,17 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
+echo "Testing subtree search with manageDSAit..."
+echo "# Testing subtree search with manageDSAit..." >> $SEARCHOUT
+$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M '*' ref >> $SEARCHOUT 2>&1
+
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Testing invalid filter..."
 echo "# Testing invalid filter..." >> $SEARCHOUT
 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
@@ -456,6 +467,25 @@ case $RC in
        ;;
 esac
 
+echo -n "Testing compare on hasSubordinates (should be TRUE)... "
+$LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BASEDN" \
+        "hasSubordinates:TRUE" >> $TESTOUT 2>&1
+
+RC=$?
+case $RC in
+6)
+       echo "TRUE"
+       ;;
+5)     echo "FALSE!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+*)     echo "failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
+
 echo "Filtering ldapsearch results..."
 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
 echo "Filtering original ldif..."
index 37e8eefa781d809e8a17e66d69eb00b85d885492..549b79b97bb4f53bc23f7472868018d6ee7bdb1f 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -61,15 +61,29 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
+cat /dev/null > $SEARCHOUT
+
 BASEDN="dc=example,dc=com"
+
+echo "Using ldapsearch to retrieve all the entries..."
+echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+        "objectClass=*" >> $SEARCHOUT 2>&1
+
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 case ${RDBMS} in
        # list here the RDBMSes whose mapping allows writes
 postgres|ibmdb2)
        MANAGERDN="cn=Manager,${BASEDN}"
        echo "Testing add..."
        $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
-               -h $LOCALHOST -p $PORT1 > \
-               $TESTOUT 2>&1 << EOMODS
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
 version: 1
 
 # Adding an organization...
@@ -86,6 +100,14 @@ objectClass: dcObject
 o: SubNet
 dc: subnet
 
+# Adding another organization with an "auxiliary" objectClass..
+dn: dc=subnet2,${BASEDN}
+changetype: add
+objectClass: organization
+objectClass: dcObject
+o: SubNet 2
+dc: subnet2
+
 # Adding a person...
 dn: cn=Lev Tolstoij,${BASEDN}
 changetype: add
@@ -125,7 +147,6 @@ description: Historical novel
 documentTitle: War and Peace
 documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
 documentIdentifier: document 3
-
 EOMODS
 
        RC=$?
@@ -135,10 +156,21 @@ EOMODS
                exit $RC
        fi
 
+       echo "Using ldapsearch to retrieve all the entries..."
+       echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+                "objectClass=*" >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
        echo "Testing modify..."
        $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
-               -h $LOCALHOST -p $PORT1 > \
-               $TESTOUT 2>&1 << EOMODS
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
 version: 1
 
 # Deleting all telephone numbers...
@@ -197,7 +229,6 @@ dn: cn=Lev Tolstoij,${BASEDN}
 changetype: modify
 delete: userPassword
 -
-
 EOMODS
 
        RC=$?
@@ -207,10 +238,21 @@ EOMODS
                exit $RC
        fi
 
+       echo "Using ldapsearch to retrieve all the entries..."
+       echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+                "objectClass=*" >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
        echo "Testing delete..."
        $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
-               -h $LOCALHOST -p $PORT1 > \
-               $TESTOUT 2>&1 << EOMODS
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
 version: 1
 
 # Deleting a person...
@@ -218,13 +260,12 @@ dn: cn=Torvlobnor Puzdoy,${BASEDN}
 changetype: delete
 
 # Deleting a document...
-dn: documentTitle=book1,dc=example,dc=com
+dn: documentTitle=book1,${BASEDN}
 changetype: delete
 
-# Deleting a person with an "auxiliary" objectClass...
-dn: cn=Akakiy Zinberstein,dc=example,dc=com
+# Deleting an organization with an "auxiliary" objectClass...
+dn: dc=subnet2,${BASEDN}
 changetype: delete
-
 EOMODS
 
        RC=$?
@@ -234,31 +275,223 @@ EOMODS
                exit $RC
        fi
 
+       echo "Using ldapsearch to retrieve all the entries..."
+       echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+                "objectClass=*" >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
        echo "Testing rename..."
        $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
-               -h $LOCALHOST -p $PORT1 > \
-               $TESTOUT 2>&1 << EOMODS
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
 version: 1
 
-# Renaming an organization
+# Renaming an organization...
 dn: o=An Org,${BASEDN}
 changetype: modrdn
 newrdn: o=Renamed Org
 deleteoldrdn: 1
 
-# Renaming a person
+# Moving a person to another subtree...
 dn: cn=Lev Tolstoij,${BASEDN}
 changetype: modrdn
 newrdn: cn=Lev Tolstoij
 deleteoldrdn: 0
 newsuperior: dc=subnet,${BASEDN}
 
-# Renaming a book
+# Renaming a book...
 dn: documentTitle=book2,${BASEDN}
 changetype: modrdn
 newrdn: documentTitle=Renamed Book
 deleteoldrdn: 1
+EOMODS
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Using ldapsearch to retrieve all the entries..."
+       echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+                "objectClass=*" >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Adding a child to a referral (should fail)..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: cn=Should Fail,ou=Referral,${BASEDN}
+changetype: add
+objectClass: inetOrgPerson
+cn: Should Fail
+sn: Fail
+telephoneNumber: +39 02 23456789
+EOMODS
+
+       RC=$?
+       if test $RC = 0 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
 
+       echo "Modifying a referral (should fail)..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Referral,${BASEDN}
+changetype: modify
+replace: ref
+ref: ldap://localhost:9009/
+-
+EOMODS
+
+       RC=$?
+       if test $RC = 0 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Renaming a referral (should fail)..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Referral,${BASEDN}
+changetype: modrdn
+newrdn: ou=Renamed Referral
+deleteoldrdn: 1
+EOMODS
+
+       RC=$?
+       if test $RC = 0 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Deleting a referral (should fail)..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Referral,${BASEDN}
+changetype: delete
+EOMODS
+
+       RC=$?
+       if test $RC = 0 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Adding a referral..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Another Referral,${BASEDN}
+changetype: add
+objectClass: referral
+objectClass: extensibleObject
+ou: Another Referral
+ref: ldap://localhost:9009/
+EOMODS
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Modifying a referral with manageDSAit..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Referral,${BASEDN}
+changetype: modify
+replace: ref
+ref: ldap://localhost:9009/
+-
+EOMODS
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Using ldapsearch to retrieve the modified entry..."
+       echo "# Using ldapsearch to retrieve the modified entry..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Referral,$BASEDN" -M \
+                "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Renaming a referral with manageDSAit..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Referral,${BASEDN}
+changetype: modrdn
+newrdn: ou=Renamed Referral
+deleteoldrdn: 1
+EOMODS
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Using ldapsearch to retrieve the renamed entry..."
+       echo "# Using ldapsearch to retrieve the renamed entry..." >> $SEARCHOUT
+       $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Renamed Referral,$BASEDN" -M \
+                "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Deleting a referral with manageDSAit..."
+       $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
+               -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
+version: 1
+
+dn: ou=Renamed Referral,${BASEDN}
+changetype: delete
 EOMODS
 
        RC=$?
@@ -304,8 +537,9 @@ EOMODS
        fi
 
        echo "Using ldapsearch to retrieve all the entries..."
+       echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
        $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
-                "objectClass=*" > $SEARCHOUT 2>&1
+                "objectClass=*" >> $SEARCHOUT 2>&1
 
        RC=$?
        if test $RC != 0 ; then
index 14cf9f52f49d808d6cf7df6fd7195fa6dd1dfa00..59d6886be30faf299b5521fcfc658893bbe3afbe 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index edaf64c1dd3749565f75f7d47356135da3110d30..f0a28ccd1268beac0be7842f6074f68ad0771393 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 14551d1414699fb02b8f3691395cbbafa72807cc..5b38c7ab16e6fcf82bfa0443ff6962b1842dd7af 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 33c43747fd8d19cefa1ea9a49409fa43f0f910f5..2711b7af52bbdef58a99c1b53a95e6f94b7aa4b1 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index ce65bfcfd8129f36a677a68690bd4b839559ce23..421b4d5e35b3cc8cb8eb5ba76e4ee7afa6d482bb 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index a5d50e7a79c29e365aa8507dde1f7eb8821cf4c9..1d6b9aab28b05d92a5b9f2aba3d3c8d2973c0c5f 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 04f7bedcfe0c2cdc5b4b2df942b335ccfa97668b..df82d1fee85f070d649eeb98a08ac2506a765149 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 4992740bd1d7f767fba9d65601a53254cceed730..8d15b5dc51d2dbcc139cf465982c6348a273fd8d 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f75435e16154ee119c664b953a6f68d818516b9a..cbbc9ee7efd234e06903b94c2c2e50418c857696 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 5fc3dde868f23b65872c8e385b38c18f758e8c7a..a82a7bde784f4edaef519f8d24e2d83b9d47cb84 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 32bed80a17716f8504a66b5ab93e47b041fb4755..fa495f21085e2e91d649df62439d8fb71072f074 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index d0941a3d56f9e53bb08bd03a07125a790b7c6d96..338b145fc9e5465c92cfe1890556bac7ca260839 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -56,16 +56,19 @@ fi
 
 cat /dev/null > $SEARCHOUT
 
-#
-# Try to read an entry inside the Alumni Association container.  It should
-# give us nothing if we're not bound, and should return all attributes
-# if we're bound as anyone under UM.
-#
-$LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "objectclass=*" \
-       >> $SEARCHOUT 2>&1
-
+echo "# Try to read an entry inside the Alumni Association container.
+# It should give us noSuchObject if we're not bound..." \
+>> $SEARCHOUT
+# FIXME: temporarily remove the "No such object" message to make
+# the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
+$LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "(objectclass=*)" \
+       2>&1 | grep -v "^No such object" >> $SEARCHOUT
+
+echo "# ... and should return all attributes if we're bound as anyone
+# under Example." \
+>> $SEARCHOUT
 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
-       -D "$BABSDN" -w bjensen "objectclass=*"  >> $SEARCHOUT 2>&1
+       -D "$BABSDN" -w bjensen "(objectclass=*)"  >> $SEARCHOUT 2>&1
 
 #
 # Check group access. Try to modify Babs' entry. Two attempts:
@@ -170,6 +173,7 @@ description: added by bjensen (should fail)
 EOMODS6
 
 echo "Using ldapsearch to retrieve all the entries..."
+echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
            'objectClass=*' >> $SEARCHOUT 2>&1
 RC=$?
@@ -189,7 +193,7 @@ echo "Comparing filter output..."
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 
 if test $? != 0 ; then
-       echo "comparison failed - modify operations did not complete correctly"
+       echo "comparison failed - operations did not complete correctly"
        exit 1
 fi
 
index d5b76d687217cc2a07a2d3eb24237ce9944344a4..e8f77b227729dd99bc3545efa4f140c7661826cb 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@ mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
 # - start slurpd
 # - populate over ldap
 # - perform some modifies and deleted
+# - attempt to modify the slave (referral or chain)
 # - retrieve database over ldap and compare against expected results
 #
 
@@ -190,6 +191,125 @@ fi
 echo "Waiting 15 seconds for slurpd to send changes..."
 sleep 15
 
+echo "Stopping the slave..."
+kill -HUP $SLAVEPID
+KILLPIDS="$PID $SLURPPID"
+
+echo "Waiting 5 seconds for slave slapd to die..."
+sleep 5
+
+echo "Applying more changes to the master slapd..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
+changetype: modify
+add: description
+description: This change was applied after killing the slave slapd...
+
+EOMODS
+
+RC=$?
+
+if test $RC != 0 ; then
+       echo "ldapmodify failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+
+echo "Stopping slurpd..."
+kill -HUP $SLURPPID
+KILLPIDS="$PID"
+
+echo "Waiting 5 seconds for slurpd to die..."
+sleep 5
+
+echo "Applying more changes to the master slapd..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
+changetype: modify
+add: description
+description: This change was applied after killing slurpd...
+
+EOMODS
+
+RC=$?
+
+if test $RC != 0 ; then
+       echo "ldapmodify failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Restarting slave slapd on TCP/IP port $PORT2..."
+echo "RESTART" >> $LOG2
+$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
+SLAVEPID=$!
+if test $WAIT != 0 ; then
+    echo SLAVEPID $SLAVEPID
+    read foo
+fi
+KILLPIDS="$KILLPIDS $SLAVEPID"
+
+echo "Using ldapsearch to check that slave slapd is running..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
+               'objectclass=*' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 0 ; then
+               break
+       fi
+       echo "Waiting 5 seconds for slapd to start..."
+       sleep 5
+done
+
+echo "Restarting slurpd..."
+echo "RESTART" >> $SLURPLOG
+$SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B >> $SLURPLOG 2>&1 &
+SLURPPID=$!
+if test $WAIT != 0 ; then
+    echo SLURPPID $SLURPPID
+    read foo
+fi
+KILLPIDS="$KILLPIDS $SLURPPID"
+
+echo "Waiting 15 seconds for slurpd to send changes..."
+sleep 15
+
+echo "Try updating the slave slapd..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
+changetype: modify
+add: description
+description: This write must fail because directed to a shadow context,
+description: unless the chain overlay is configured appropriately ;)
+
+EOMODS
+
+RC=$?
+
+if test $BACKLDAP = "ldapno" ; then
+       # expect 10 (LDAP_REFERRAL)...
+       if test $RC != 10 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+else
+       # expect 0 (LDAP_SUCCESS)...
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Waiting 15 seconds for slurpd to send changes..."
+       sleep 15
+fi
+
 echo "Using ldapsearch to read all the entries from the master..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
        'objectclass=*' > $MASTEROUT 2>&1
index 2f9b4f4f6fe5f5000ab8db62e51295af6e3485ef..080c1d5db676d19a6f422d34aa8d9890d4e63ba0 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 00a352393518bb7e05c205e39420410229fe5fd3..e9781843a0cf1de1ea3e58150dba76f24aa64391 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 812fced53ff33b522420c0358af8bd97210e1971..f79c5aca0a9d445ef25c9138b87ae862ae2a641f 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e4762a293b7ffa0f3e28ad38feaf60e3a8a29b83..df6afa1d581fa6166bfd97106400af02c9be17ed 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index f1c6c2fa14954851f9fe8374559299261afff2ec..085a005b4f9e472f364e9eafca598a358fd34e17 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 6a76e63fb5832dded269a7367db51633fafad445..a9cef2320b9ea5a90b8c7c70099889c7a290265e 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index fda1405651ee08cad6c72bb4e2ba24f6a98e6cd9..a612864b909207d02cbddd6d76a199a0bf0ba14c 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index e9b3d78cd6b35a7619b44dbb05acdc2e243f3d9f..5f101d61b30f55b7af228ec48bfeadf799c892c0 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 7e4eb660cdc56f69aeabd77b2540b85692b6b2d7..4c39beb527ce3d4fab9295913b5b2f5f76afe7c4 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 73c6474b485cab16bd230912e748688f1efe481a..3b01f1a0bfac9e284b94e656ddd7c2855de2cd55 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@ if test $SYNCPROV = syncprovno; then
        exit 0
 fi 
 
-mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
+mkdir -p $TESTDIR $DBDIR1 $DBDIR2
 
 #
 # Test replication:
@@ -29,6 +29,7 @@ mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
 # - start slave
 # - populate over ldap
 # - perform some modifies and deleted
+# - attempt to modify the slave (referral)
 # - retrieve database over ldap and compare against expected results
 #
 
@@ -200,6 +201,26 @@ fi
 echo "Waiting 15 seconds for syncrepl to receive changes..."
 sleep 15
 
+echo "Try updating the slave slapd..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
+changetype: modify
+add: description
+description: This write must fail because directed to a shadow context,
+description: unless the chain overlay is configured appropriately ;)
+
+EOMODS
+
+RC=$?
+
+# expect 10 (LDAP_REFERRAL)...
+if test $RC != 10 ; then
+       echo "ldapmodify should have failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Using ldapsearch to read all the entries from the master..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
        'objectclass=*' > $MASTEROUT 2>&1
index c24c521269717c0705ad0ba8d13058c8a1938432..b08c7facebc5de820a4115030f1b65d8cd2a6302 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@ mkdir -p $TESTDIR $DBDIR1 $DBDIR4
 # - start slave
 # - populate over ldap
 # - perform some modifies and deleted
+# - attempt to modify the slave (referral or chain)
 # - retrieve database over ldap and compare against expected results
 #
 
@@ -116,6 +117,36 @@ fi
 echo "Waiting 15 seconds for syncrepl to receive changes..."
 sleep 15
 
+echo "Stopping the provider, sleeping 10 seconds and restarting it..."
+kill -HUP "$PID"
+sleep 10
+echo "RESTART" >> $LOG1
+$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
+PID=$!
+if test $WAIT != 0 ; then
+    echo PID $PID
+    read foo
+fi
+KILLPIDS="$PID $SLAVEPID"
+
+echo "Using ldapsearch to check that master slapd is running..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
+               'objectclass=*' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 0 ; then
+               break
+       fi
+       echo "Waiting 5 seconds for slapd to start..."
+       sleep 5
+done
+
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Using ldapmodify to modify master directory..."
 
 #
@@ -242,6 +273,39 @@ KILLPIDS="$PID $SLAVEPID"
 echo "Waiting 25 seconds for syncrepl to receive changes..."
 sleep 25
 
+echo "Try updating the slave slapd..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
+changetype: modify
+add: description
+description: This write must fail because directed to a shadow context,
+description: unless the chain overlay is configured appropriately ;)
+
+EOMODS
+
+RC=$?
+
+if test $BACKLDAP = "ldapno" ; then
+       # expect 10 (LDAP_REFERRAL)...
+       if test $RC != 10 ; then
+               echo "ldapmodify should have failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+else
+       # expect 0 (LDAP_SUCCESS)...
+       if test $RC != 0 ; then
+               echo "ldapmodify failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Waiting 15 seconds for syncrepl to receive changes..."
+       sleep 15
+fi
+
 echo "Using ldapsearch to read all the entries from the master..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
        'objectclass=*' > $MASTEROUT 2>&1
index 98776d3707875d3d3a8971d16c470973f264ce7b..fce1baac19a172dc451ebcbb30ca6f407b5ad360 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index c428601b13b37bf40b1a3fc4f5a61768709a462b..a4eace2ca7bf7b5d9aec21e8ccdf289b3e087ed9 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 655d1ac0f675e8a4d684d0ec7e0b4f4b1d96fc11..777f0d66d10df9ad916fefb8da1fd5f2dbe94245 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index b7e74b7c559fde81ede7d9008c28f40c90069970..158dd6a8e310b75374020ead3ee715c92c48d9d7 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 2b1337b53fca46a57dba905793cfb2c442d64626..b38993c61fa328323226ee0dbb935b0ff673f719 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index cac31941d9ce9f40c24b8288bcf7134c4e0f93a1..9f2db4aa8e4a607558ba61850b7a14bd0d839afc 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 812419d663c0ec24370cf92fe0b3b8896e7947f1..93c0221f9e76063f37ae615ae2f8b0265350a63c 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 0178af4933f5c7366695e1602a3f07fc48ec807a..5d7f618b05e5f57df2717e0252d284683ac996b0 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 1b752f84b314fa436fae09612e3909907bd8bca6..e4e2eb2cff0fd781d773cefef8af17ee9337ef66 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004 The OpenLDAP Foundation.
+## Copyright 2004-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 4418a1c331a1d64862547152b1e3948d0ad7e77a..ea364bc8d4f9c9b2c76d8119f382bd32bf736aaf 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index 79976b9ae0b616959431050d6afcdb4c47151550..572e7e8199b51a696d71f888249ce9eb5c686d96 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
index d6bc8b5728acf4e08e496d72f8ceeaabcc9161b7..656cc616f91cfc8d7a28538a9d13f918ce3b9d03 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -29,25 +29,40 @@ if test "x$RELAYS" = "x" ; then
        if test $BACKRELAY = relayno ; then 
                echo "relay backend not available, test skipped"
        else
-               RELAYS="${RELAYS}relay "
+               if test "x$RELAYS" != "x" ; then
+                       RELAYS="${RELAYS} "
+               fi
+               RELAYS="${RELAYS}relay"
        fi
 
        # back-ldap
        if test $BACKLDAP = ldapno ; then 
                echo "ldap backend not available, test skipped"
        else
-               RELAYS="${RELAYS}ldap "
+               if test "x$RELAYS" != "x" ; then
+                       RELAYS="${RELAYS} "
+               fi
+               RELAYS="${RELAYS}ldap"
        fi
 
        # back-meta
        if test $BACKMETA = metano ; then 
                echo "meta backend not available, test skipped"
        else
-               RELAYS="${RELAYS}meta "
+               if test "x$RELAYS" != "x" ; then
+                       RELAYS="${RELAYS} "
+               fi
+               RELAYS="${RELAYS}meta"
        fi 
 fi
 
-echo "Using $RELAYS..."
+if test "x$RELAYS" = "x" ; then
+       echo "no relaying capable backend is available"
+       echo ">>>>> Test succeeded"
+       exit 0
+fi
+
+echo "Testing virtual naming context mapping with $RELAYS backend(s)..."
 echo ""
 
 first=1
index 5698e02cd2ee42f182bb2bc97a7bebb130352730..0edf704842705e97cdf22776171fad4c06928345 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
diff --git a/tests/scripts/test032-chain b/tests/scripts/test032-chain
new file mode 100755 (executable)
index 0000000..de27ec0
--- /dev/null
@@ -0,0 +1,246 @@
+#! /bin/sh
+# $OpenLDAP$
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
+##
+## Copyright 1998-2005 The OpenLDAP Foundation.
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted only as authorized by the OpenLDAP
+## Public License.
+##
+## A copy of this license is available in the file LICENSE in the
+## top-level directory of the distribution or, alternatively, at
+## <http://www.OpenLDAP.org/license.html>.
+
+echo "running defines.sh"
+. $SRCDIR/scripts/defines.sh
+
+if test $BACKLDAP = "ldapno" ; then 
+       echo "LDAP backend not available, test skipped"
+       exit 0
+fi 
+
+mkdir -p $TESTDIR $DBDIR1 $DBDIR2
+
+echo "Running slapadd to build slapd database..."
+. $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $ADDCONF
+. $CONFFILTER < $LDIFCHAIN1 > $SEARCHOUT
+$SLAPADD -f $ADDCONF -l $SEARCHOUT
+RC=$?
+if test $RC != 0 ; then
+       echo "slapadd 1 failed ($RC)!"
+       exit $RC
+fi
+
+. $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $ADDCONF
+. $CONFFILTER < $LDIFCHAIN2 > $SEARCHOUT
+$SLAPADD -f $ADDCONF -l $SEARCHOUT
+RC=$?
+if test $RC != 0 ; then
+       echo "slapadd 2 failed ($RC)!"
+       exit $RC
+fi
+
+echo "Starting first slapd on TCP/IP port $PORT1..."
+. $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $CONF1
+$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
+PID1=$!
+if test $WAIT != 0 ; then
+    echo PID $PID1
+    read foo
+fi
+
+echo "Starting second slapd on TCP/IP port $PORT2..."
+. $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
+$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
+PID2=$!
+if test $WAIT != 0 ; then
+    echo PID $PID2
+    read foo
+fi
+
+KILLPIDS="$PID1 $PID2"
+
+echo "Using ldapsearch to check that first slapd is running..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
+               'objectclass=*' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 0 ; then
+               break
+       fi
+       echo "Waiting 5 seconds for slapd to start..."
+       sleep 5
+done
+
+echo "Using ldapsearch to check that second slapd is running..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
+               'objectclass=*' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 0 ; then
+               break
+       fi
+       echo "Waiting 5 seconds for slapd to start..."
+       sleep 5
+done
+
+for P in $PORT1 $PORT2 ; do
+       echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
+       $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
+                > $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Filtering ldapsearch results..."
+       . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+       echo "Filtering original ldif used to create database..."
+       . $LDIFFILTER < $CHAINOUT > $LDIFFLT
+       echo "Comparing filter output..."
+       $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+       
+       if test $? != 0 ; then
+               echo "comparison failed - chained search didn't succeed"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit 1
+       fi
+done
+
+#
+# Testing writes to first server
+#
+echo "Writing to first server with scope on second server..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=New Group,ou=Groups,dc=example,dc=com
+changetype: add
+objectClass: groupOfNames
+cn: New Group
+member:
+
+dn: cn=New Group,ou=Groups,dc=example,dc=com
+changetype: modify
+add: description
+description: testing chain overlay writes...
+-
+replace: member
+member: cn=New Group,ou=Groups,dc=example,dc=com
+member: cn=Manager,dc=example,dc=com
+-
+add: owner
+owner: cn=Manager,dc=example,dc=com
+-
+
+dn: cn=New Group,ou=Groups,dc=example,dc=com
+changetype: modrdn
+newrdn: cn=Renamed Group
+deleteoldrdn: 1
+
+dn: cn=All Staff,ou=Groups,dc=example,dc=com
+changetype: delete
+EOMODS
+
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapmodify failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+#
+# Testing writes to second server
+#
+echo "Writing to second server with scope on first server..."
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
+       $TESTOUT 2>&1 << EOMODS
+dn: cn=New User,ou=People,dc=example,dc=com
+changetype: add
+objectClass: person
+cn: New User
+sn: User
+seeAlso: cn=New Group,ou=Groups,dc=example,dc=com
+
+dn: cn=New User,ou=People,dc=example,dc=com
+changetype: modify
+add: description
+description: testing chain overlay writes...
+-
+replace: seeAlso
+seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
+-
+
+dn: cn=New User,ou=People,dc=example,dc=com
+changetype: modrdn
+newrdn: cn=Renamed User
+deleteoldrdn: 1
+
+dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
+changetype: delete
+EOMODS
+
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapmodify failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+for P in $PORT1 $PORT2 ; do
+       echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
+       $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
+                > $SEARCHOUT 2>&1
+
+       RC=$?
+       if test $RC != 0 ; then
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Filtering ldapsearch results..."
+       . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+       echo "Filtering original ldif used to create database..."
+       . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT
+       echo "Comparing filter output..."
+       $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+       
+       if test $? != 0 ; then
+               echo "comparison failed - chained search didn't succeed"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit 1
+       fi
+done
+
+NEWPW=newsecret
+echo "Using ldappasswd on second server with scope on first server..."
+$LDAPPASSWD -h $LOCALHOST -p $PORT2 \
+       -w secret -s $NEWPW \
+       -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldappasswd failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Binding with newly changed password on first server..."
+$LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
+       -D "$BJORNSDN" -w $NEWPW
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapwhoami failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
+echo ">>>>> Test succeeded"
+exit 0
+