]> git.sur5r.net Git - openldap/commitdiff
fix user/operational mix of attribute request
authorPierangelo Masarati <ando@openldap.org>
Tue, 30 Nov 2004 01:49:06 +0000 (01:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 30 Nov 2004 01:49:06 +0000 (01:49 +0000)
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/search.c

index 6ca43efec8861e5184d8a60e3aebc74026265ea0..cb6250733c01c286a88fb61d683a2c5a12e89d3c 100644 (file)
@@ -269,10 +269,12 @@ typedef struct backsql_srch_info {
 
        unsigned                bsi_flags;
 #define        BSQL_SF_NONE                    0x0000U
-#define        BSQL_SF_ALL_OPER                0x0001U
-#define BSQL_SF_FILTER_HASSUBORDINATE  0x0002U
-#define BSQL_SF_FILTER_ENTRYUUID       0x0004U
-#define BSQL_SF_FILTER_ENTRYCSN                0x0008U
+#define        BSQL_SF_ALL_USER                0x0001U
+#define        BSQL_SF_ALL_OPER                0x0002U
+#define        BSQL_SF_ALL_ATTRS               (BSQL_SF_ALL_USER|BSQL_SF_ALL_OPER)
+#define BSQL_SF_FILTER_HASSUBORDINATE  0x0010U
+#define BSQL_SF_FILTER_ENTRYUUID       0x0020U
+#define BSQL_SF_FILTER_ENTRYCSN                0x0040U
 #define BSQL_SF_RETURN_ENTRYUUID       (BSQL_SF_FILTER_ENTRYUUID << 8)
 
        struct berval           *bsi_base_ndn;
index c229a65c8e35dc190f1566e434a5ef9b27c789d9..d75bfe0ddae0d5d50e8737f4624cc654dda22c31 100644 (file)
@@ -510,7 +510,14 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
                return rc;
        }
 
-       if ( bsi->bsi_attrs != NULL ) {
+       if ( bsi->bsi_attrs == NULL || ( bsi->bsi_flags & BSQL_SF_ALL_USER ) )
+       {
+               Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
+                       "retrieving all attributes\n", 0, 0, 0 );
+               avl_apply( bsi->bsi_oc->bom_attrs, backsql_get_attr_vals,
+                               bsi, 0, AVL_INORDER );
+
+       } 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++ ) {
@@ -555,12 +562,6 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
 
 next:;
                }
-
-       } else {
-               Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
-                       "retrieving all attributes\n", 0, 0, 0 );
-               avl_apply( bsi->bsi_oc->bom_attrs, backsql_get_attr_vals,
-                               bsi, 0, AVL_INORDER );
        }
 
        if ( bsi->bsi_flags & BSQL_SF_RETURN_ENTRYUUID ) {
@@ -600,7 +601,9 @@ next:;
                }
 
                if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER )
-                               || an_find( bsi->bsi_attrs, &AllOper ) ) {
+                               || an_find( bsi->bsi_attrs, &AllOper )
+                               || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) )
+               {
                        rc = attr_merge_normalize_one( bsi->bsi_e,
                                        slap_schema.si_ad_structuralObjectClass,
                                        &soc, bsi->bsi_op->o_tmpmemctx );
index 2351a2e5fdb65dd15cb5fcca4f8ee2198e5b14cc..3fbe8cd13d7fbf267ed0ed5566372ceb43da8270 100644 (file)
@@ -132,8 +132,10 @@ backsql_init_search(
        /*
         * handle "*"
         */
-       if ( attrs == NULL || an_find( attrs, &AllUser ) ) {
+       if ( attrs == NULL ) {
+               /* also add request for all operational */
                bsi->bsi_attrs = NULL;
+               bsi->bsi_flags |= BSQL_SF_ALL_USER;
 
        } else {
                int     got_oc = 0;
@@ -146,7 +148,11 @@ backsql_init_search(
                        /*
                         * ignore "1.1"; handle "+"
                         */
-                       if ( BACKSQL_NCMP( &p->an_name, &AllOper ) == 0 ) {
+                       if ( BACKSQL_NCMP( &p->an_name, &AllUser ) == 0 ) {
+                               bsi->bsi_flags |= BSQL_SF_ALL_USER;
+                               continue;
+
+                       } else if ( BACKSQL_NCMP( &p->an_name, &AllOper ) == 0 ) {
                                bsi->bsi_flags |= BSQL_SF_ALL_OPER;
                                continue;