]> git.sur5r.net Git - openldap/commitdiff
need to catch the '' base in search as well; selected cleanup and improvements
authorPierangelo Masarati <ando@openldap.org>
Fri, 28 Jan 2005 23:19:02 +0000 (23:19 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 28 Jan 2005 23:19:02 +0000 (23:19 +0000)
servers/slapd/back-dnssrv/init.c
servers/slapd/back-dnssrv/proto-dnssrv.h
servers/slapd/back-dnssrv/search.c

index e3f26d4aa0c4e4ab80e20d71bf3fb40061c18edd..dcf2628ac83342aaf21c5939920c9199bfb494cc 100644 (file)
@@ -40,7 +40,7 @@ dnssrv_back_initialize(
 
        bi->bi_controls = controls;
 
-       bi->bi_open = 0;
+       bi->bi_open = dnssrv_back_open;
        bi->bi_config = 0;
        bi->bi_close = 0;
        bi->bi_destroy = 0;
@@ -71,6 +71,21 @@ dnssrv_back_initialize(
        return 0;
 }
 
+AttributeDescription   *ad_dc;
+AttributeDescription   *ad_associatedDomain;
+
+int
+dnssrv_back_open(
+    BackendInfo *bi )
+{
+       const char *text;
+
+       (void)slap_str2ad( "dc", &ad_dc, &text );
+       (void)slap_str2ad( "associatedDomain", &ad_associatedDomain, &text );
+
+       return 0;
+}
+
 int
 dnssrv_back_db_init(
     Backend    *be )
index 700afe641a7a19a9fa6ef203917fd5c4b101571d..0ee0bb2224c43c5d9adbf0dafb719b03ada267c3 100644 (file)
@@ -38,6 +38,9 @@ extern BI_op_compare          dnssrv_back_compare;
 
 extern BI_chk_referrals                dnssrv_back_referrals;
 
+extern AttributeDescription    *ad_dc;
+extern AttributeDescription    *ad_associatedDomain;
+
 LDAP_END_DECL
 
 #endif /* PROTO_DNSSRV_H */
index b191fca7fa523b0db4cc27e28ec52665c654963d..27c5c7b9e405769ba285b072475116892f2e3603 100644 (file)
@@ -47,11 +47,25 @@ dnssrv_back_search(
 
        rs->sr_ref = NULL;
 
+       if ( BER_BVISEMPTY( &op->o_req_ndn ) ) {
+#ifdef LDAP_DEVEL
+#if 0
+               /* FIXME: need some means to determine whether the database
+                * is a glue instance; if we got here with empty DN, then
+                * we passed this same test in dnssrv_back_referrals() */
+               if ( SLAP_GLUE_INSTANCE( op->o_bd ) ) {
+                       return LDAP_SUCCESS;
+               }
+#endif
+               return LDAP_SUCCESS;
+#endif /* LDAP_DEVEL */
+       }
+
        manageDSAit = get_manageDSAit( op );
        /*
         * FIXME: we may return a referral if manageDSAit is not set
         */
-       if ( ! manageDSAit ) {
+       if ( !manageDSAit ) {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                "manageDSAit must be set" );
                goto done;
@@ -166,52 +180,36 @@ dnssrv_back_search(
 
                vals[1].bv_val = NULL;
 
-               vals[0].bv_val = "top";
-               vals[0].bv_len = sizeof("top")-1;
-               attr_mergeit( e, ad_objectClass, vals );
-
-               vals[0].bv_val = "referral";
-               vals[0].bv_len = sizeof("referral")-1;
-               attr_mergeit( e, ad_objectClass, vals );
-
-               vals[0].bv_val = "extensibleObject";
-               vals[0].bv_len = sizeof("extensibleObject")-1;
-               attr_mergeit( e, ad_objectClass, vals );
+               BER_BVSTR( &vals[0], "top" );
+               attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_top->soc_cname );
 
-               {
-                       AttributeDescription *ad = NULL;
-                       const char *text;
+               BER_BVSTR( &vals[0], "referral" );
+               attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_referral->soc_cname );
 
-                       rc = slap_str2ad( "dc", &ad, &text );
+               BER_BVSTR( &vals[0], "extensibleObject" );
+               attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_extensibleObject->soc_cname );
 
-                       if( rc == LDAP_SUCCESS ) {
-                               char *p;
-                               vals[0].bv_val = ch_strdup( domain );
+               if ( ad_dc ) {
+                       char *p;
+                       vals[0].bv_val = ch_strdup( domain );
 
-                               p = strchr( vals[0].bv_val, '.' );
+                       p = strchr( vals[0].bv_val, '.' );
                                        
-                               if( p == vals[0].bv_val ) {
-                                       vals[0].bv_val[1] = '\0';
-                               } else if ( p != NULL ) {
-                                       *p = '\0';
-                               }
-
-                               vals[0].bv_len = strlen(vals[0].bv_val);
-                               attr_mergeit( e, ad, vals );
-                       }
-               }
+                       if ( p == vals[0].bv_val ) {
+                               vals[0].bv_val[1] = '\0';
 
-               {
-                       AttributeDescription *ad = NULL;
-                       const char *text;
+                       } else if ( p != NULL ) {
+                               *p = '\0';
+                       }
 
-                       rc = slap_str2ad( "associatedDomain", &ad, &text );
+                       vals[0].bv_len = strlen( vals[0].bv_val );
+                       attr_mergeit( e, ad_dc, vals );
+               }
 
-                       if( rc == LDAP_SUCCESS ) {
-                               vals[0].bv_val = domain;
-                               vals[0].bv_len = strlen(domain);
-                               attr_mergeit( e, ad, vals );
-                       }
+               if ( ad_associatedDomain ) {
+                       vals[0].bv_val = domain;
+                       vals[0].bv_len = strlen(domain);
+                       attr_mergeit( e, ad_associatedDomain, vals );
                }
 
                attr_mergeit( e, ad_ref, urls );