/* dyngroup.c - Demonstration of overlay code */
/* $OpenLDAP$ */
-/*
- * Copyright 2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003 by 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>.
*/
-/*
- * Copyright 2003, Howard Chu, All rights reserved. <hyc@symas.com>
- *
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of this
- * software, no matter how awful, even if they arise from flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either by
- * explicit claim or by omission. Since few users ever read sources,
- * credits should appear in the documentation.
- *
- * 3. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software. Since few users
- * ever read sources, credits should appear in the documentation.
- *
- * 4. This notice may not be removed or altered.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Howard Chu for inclusion in
+ * OpenLDAP Software.
*/
#include "portable.h"
+#ifdef SLAPD_OVER_DYNGROUP
+
#include <stdio.h>
#include <ac/string.h>
int cache = op->o_do_not_cache;
op->o_do_not_cache = 1;
- if ( backend_group( op, NULL, &op->o_req_ndn,
- &op->oq_compare.rs_ava->aa_value, NULL, ap->ap_uri ) == 0 )
- rs->sr_err = LDAP_COMPARE_TRUE;
+ rs->sr_err = backend_group( op, NULL, &op->o_req_ndn,
+ &op->oq_compare.rs_ava->aa_value, NULL, ap->ap_uri );
op->o_do_not_cache = cache;
+ if ( rs->sr_err == LDAP_SUCCESS )
+ rs->sr_err = LDAP_COMPARE_TRUE;
break;
}
}
if ( strcasecmp( argv[0], "attrpair" ) == 0 ) {
const char *text;
if ( argc != 3 ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: attribute description missing in \"attrpair <member-attribute> <URL-attribute>\" line.\n",
- fname, lineno, 0 );
- return( 1 );
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "attribute description missing in "
+ "\"attrpair <member-attribute> <URL-attribute>\" line.\n",
+ fname, lineno, 0 );
+ return( 1 );
}
if ( slap_str2ad( argv[1], &ap.ap_mem, &text ) ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
- fname, lineno, text );
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "attribute description unknown \"attrpair\" line: %s.\n",
+ fname, lineno, text );
return( 1 );
}
if ( slap_str2ad( argv[2], &ap.ap_uri, &text ) ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
- fname, lineno, text );
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+ "attribute description unknown \"attrpair\" line: %s.\n",
+ fname, lineno, text );
return( 1 );
}
/* The on->on_bi.bi_private pointer can be used for
a2->ap_mem = ap.ap_mem;
a2->ap_uri = ap.ap_uri;
on->on_bi.bi_private = a2;
+ } else {
+ return SLAP_CONF_UNKNOWN;
}
return 0;
}
* initialized and registered by some other function inside slapd.
*/
-int init_module(int argc, char *argv[]) {
+int dyngroup_init() {
dyngroup.on_bi.bi_type = "dyngroup";
dyngroup.on_bi.bi_db_config = dyngroup_config;
dyngroup.on_bi.bi_db_close = dyngroup_close;
return overlay_register( &dyngroup );
}
+
+#if SLAPD_OVER_DYNGROUP == SLAPD_MOD_DYNAMIC
+int init_module(int argc, char *argv[]) {
+ return dyngroup_init();
+}
+#endif
+
+#endif /* defined(SLAPD_OVER_DYNGROUP) */