]> git.sur5r.net Git - openldap/commitdiff
added backend-side support for on-the-fly operational attributes; added hasSubordinat...
authorPierangelo Masarati <ando@openldap.org>
Sat, 22 Dec 2001 11:50:16 +0000 (11:50 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 22 Dec 2001 11:50:16 +0000 (11:50 +0000)
servers/slapd/back-ldbm/Makefile.in
servers/slapd/back-ldbm/external.h
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/operational.c [new file with mode: 0644]
servers/slapd/backend.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/schema/core.schema
servers/slapd/schema_prep.c
servers/slapd/slap.h

index 45c280d38f873b5b61465b81c7a60b2b7c470b57..14e1b8bec9f95e727f65047e8dde26937c7d0486 100644 (file)
@@ -5,13 +5,13 @@ SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c \
                compare.c group.c modify.c modrdn.c delete.c init.c \
                config.c bind.c attr.c filterindex.c unbind.c close.c \
                alias.c tools.c key.c extended.c passwd.c sasl.c \
-               referral.c attribute.c
+               referral.c attribute.c operational.c
 OBJS = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo \
                id2entry.lo index.lo id2children.lo nextid.lo abandon.lo \
                compare.lo group.lo modify.lo modrdn.lo delete.lo init.lo \
                config.lo bind.lo attr.lo filterindex.lo unbind.lo close.lo \
                alias.lo tools.lo key.lo extended.lo passwd.lo sasl.lo \
-               referral.lo attribute.lo
+               referral.lo attribute.lo operational.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index 76a3771f0501c5cc3e4547451766071354be06b5..243b1bc1eaa26747e82d99e3231d401c28140670 100644 (file)
@@ -88,6 +88,12 @@ extern int   ldbm_back_attribute LDAP_P(( BackendDB *bd,
        AttributeDescription* entry_at,
        struct berval ***vals));
 
+extern int     ldbm_back_operational LDAP_P((BackendDB *bd,
+       Connection *conn, Operation *op,
+       Entry *e,
+       char **attrs,
+       int opattrs,
+       Attribute **a ));
 
 /* hooks for slap tools */
 extern int ldbm_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
index bba57e967d4d0e60fedd89ac799904e95b777d3e..ff836b9cb951262796887a852fdb3a106fd8f09f 100644 (file)
@@ -69,6 +69,7 @@ ldbm_back_initialize(
        bi->bi_acl_group = ldbm_back_group;
        bi->bi_acl_attribute = ldbm_back_attribute;
        bi->bi_chk_referrals = ldbm_back_referrals;
+       bi->bi_operational = ldbm_back_operational;
 
        /*
         * hooks for slap tools
diff --git a/servers/slapd/back-ldbm/operational.c b/servers/slapd/back-ldbm/operational.c
new file mode 100644 (file)
index 0000000..81fe0ef
--- /dev/null
@@ -0,0 +1,54 @@
+/* operational.c - ldbm backend operational attributes function */
+/*
+ * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldbm.h"
+#include "proto-back-ldbm.h"
+
+/*
+ * sets the supported operational attributes (if required)
+ */
+
+int
+ldbm_back_operational(
+       BackendDB       *be,
+       Connection      *conn, 
+       Operation       *op,
+       Entry           *e,
+       char            **attrs,
+       int             opattrs,
+       Attribute       **a )
+{
+       Attribute       **aa = a;
+
+       assert( e );
+
+       if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
+               int     hs;
+
+               hs = has_children( be, e );
+
+               *aa = ch_malloc( sizeof( Attribute ) );
+               (*aa)->a_desc = slap_schema.si_ad_hasSubordinates;
+
+               (*aa)->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
+               (*aa)->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
+               (*aa)->a_vals[1] = NULL;
+
+               (*aa)->a_next = NULL;
+               aa = &(*aa)->a_next;
+       }
+       
+       return 0;
+}
+
index 6054ff89e27fde0a7e83c9e86f3c66c1a360cb83..8b1469ef38e26fb9674db03247a41e30ad0a5681 100644 (file)
@@ -1087,9 +1087,11 @@ Attribute *backend_operational(
        Backend *be,
        Connection *conn,
        Operation *op,
-       Entry *e )
+       Entry *e,
+       char **attrs,
+       int opattrs     )
 {
-       Attribute *a = NULL;
+       Attribute *a = NULL, **ap = &a;
 
 #ifdef SLAPD_SCHEMA_DN
        a = ch_malloc( sizeof( Attribute ) );
@@ -1101,7 +1103,19 @@ Attribute *backend_operational(
        a->a_vals[1] = NULL;
 
        a->a_next = NULL;
+       ap = &a->a_next;
 #endif
 
+       /*
+        * If operational attributes (allegedly) are required, 
+        * and the backend supports specific operational attributes, 
+        * add them to the attribute list
+        */
+       if ( ( opattrs || attrs ) && be->be_operational != NULL ) {
+               ( void )be->be_operational( be, conn, op, e, 
+                                           attrs, opattrs, ap );
+       }
+
        return a;
 }
+
index 20762b2811dbce6663169d310f928744b38f789d..f25c69e769deef4674460e29ead59adb00ae66b7 100644 (file)
@@ -210,7 +210,9 @@ LDAP_SLAPD_F (Attribute *) backend_operational(
        BackendDB *,
        Connection *conn,
        Operation *op,
-       Entry * );
+       Entry *e,
+       char **attrs,
+       int opattrs );
 
 
 /*
index 48638cad56e007d4063408919405c1d583addaa8..e9b066a5e6f39c2f5b63cb21bc20dc919c3069c7 100644 (file)
@@ -839,7 +839,7 @@ send_search_entry(
 
        /* eventually will loop through generated operational attributes */
        /* only have subschemaSubentry implemented */
-       aa = backend_operational( be, conn, op, e );
+       aa = backend_operational( be, conn, op, e, attrs, opattrs );
        
        for (a = aa ; a != NULL; a = a->a_next ) {
                AttributeDescription *desc = a->a_desc;
index d0b0ceede1ccd7eac52544b581e5600c80257a71..3801c48b6a32b08016778e48455a5734c3c7953d 100644 (file)
@@ -51,6 +51,12 @@ attributetype ( 2.5.18.4 NAME 'modifiersName'
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
        SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
 
+attributetype ( 2.5.18.9 NAME 'hasSubordinates'
+       DESC 'X.501: entry has children'
+       EQUALITY booleanMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
+       SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
+
 attributetype ( 2.5.18.10 NAME 'subschemaSubentry'
        DESC 'RFC2252: name of controlling subschema entry'
        EQUALITY distinguishedNameMatch
index f713d5e18e07acf30b09e28c7a2665bcda674b0c..34412ba580d09b3b08ba2faa80bd459c89d34936 100644 (file)
@@ -165,6 +165,8 @@ struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_modifiersName) },
        { "modifyTimestamp", NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
+       { "hasSubordinates", NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
        { "subschemaSubentry", NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
 
index 1987230afe33d0f8dbd1ed232b2d7f21e7bed21f..d883542beade67f72f2863f6bca09e7fb3802dfe 100644 (file)
@@ -483,6 +483,7 @@ struct slap_internal_schema {
        AttributeDescription *si_ad_createTimestamp;
        AttributeDescription *si_ad_modifiersName;
        AttributeDescription *si_ad_modifyTimestamp;
+       AttributeDescription *si_ad_hasSubordinates;
        AttributeDescription *si_ad_subschemaSubentry;
 
        /* root DSE attribute descriptions */
@@ -918,6 +919,7 @@ struct slap_backend_db {
 #define                be_chk_referrals        bd_info->bi_chk_referrals
 #define                be_group        bd_info->bi_acl_group
 #define                be_attribute    bd_info->bi_acl_attribute
+#define                be_operational  bd_info->bi_operational
 
 #define                be_controls     bd_info->bi_controls
 
@@ -1139,6 +1141,10 @@ struct slap_backend_info {
                AttributeDescription *entry_at,
                struct berval ***vals ));
 
+       int     (*bi_operational)  LDAP_P((Backend *bd,
+               struct slap_conn *c, struct slap_op *o,
+               Entry *e, char **attrs, int opattrs, Attribute **a ));
+
        int     (*bi_connection_init) LDAP_P((BackendDB *bd,
                struct slap_conn *c));
        int     (*bi_connection_destroy) LDAP_P((BackendDB *bd,