]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/dyngroup.c
trim listed modules
[openldap] / servers / slapd / overlays / dyngroup.c
index 1fff053dc4416a3e054be70d84df96710770dd99..6b28ecc8c5590aa9ae2adb1b80fe3ed7c966479a 100644 (file)
@@ -2,7 +2,8 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003 The OpenLDAP Foundation.
+ * Copyright 2003-2007 The OpenLDAP Foundation.
+ * Copyright 2003 by Howard Chu.
  * 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>.
  */
-/* This is an altered version */
-/*
- * 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.
@@ -41,6 +21,8 @@
 
 #include "portable.h"
 
+#ifdef SLAPD_OVER_DYNGROUP
+
 #include <stdio.h>
 
 #include <ac/string.h>
@@ -82,10 +64,18 @@ dyngroup_response( Operation *op, SlapReply *rs )
                                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;
+                               switch ( rs->sr_err ) {
+                               case LDAP_SUCCESS:
+                                       rs->sr_err = LDAP_COMPARE_TRUE;
+                                       break;
+
+                               case LDAP_NO_SUCH_OBJECT:
+                                       rs->sr_err = LDAP_COMPARE_FALSE;
+                                       break;
+                               }
                                break;
                        }
                }
@@ -135,6 +125,8 @@ static int dyngroup_config(
                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;
 }
@@ -161,7 +153,7 @@ static slap_overinst dyngroup;
  * initialized and registered by some other function inside slapd.
  */
 
-int init_module(int argc, char *argv[]) {
+int dyngroup_initialize() {
        dyngroup.on_bi.bi_type = "dyngroup";
        dyngroup.on_bi.bi_db_config = dyngroup_config;
        dyngroup.on_bi.bi_db_close = dyngroup_close;
@@ -169,3 +161,13 @@ int init_module(int argc, char *argv[]) {
 
        return overlay_register( &dyngroup );
 }
+
+#if SLAPD_OVER_DYNGROUP == SLAPD_MOD_DYNAMIC
+int
+init_module( int argc, char *argv[] )
+{
+       return dyngroup_initialize();
+}
+#endif
+
+#endif /* defined(SLAPD_OVER_DYNGROUP) */