From: Pierangelo Masarati Date: Fri, 28 Jan 2005 23:19:02 +0000 (+0000) Subject: need to catch the '' base in search as well; selected cleanup and improvements X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~226 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1e351da986bf205a07b26bf7ae4b15cc773769ca;p=openldap need to catch the '' base in search as well; selected cleanup and improvements --- diff --git a/servers/slapd/back-dnssrv/init.c b/servers/slapd/back-dnssrv/init.c index e3f26d4aa0..dcf2628ac8 100644 --- a/servers/slapd/back-dnssrv/init.c +++ b/servers/slapd/back-dnssrv/init.c @@ -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 ) diff --git a/servers/slapd/back-dnssrv/proto-dnssrv.h b/servers/slapd/back-dnssrv/proto-dnssrv.h index 700afe641a..0ee0bb2224 100644 --- a/servers/slapd/back-dnssrv/proto-dnssrv.h +++ b/servers/slapd/back-dnssrv/proto-dnssrv.h @@ -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 */ diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index b191fca7fa..27c5c7b9e4 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -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 );