]> git.sur5r.net Git - openldap/commitdiff
Add ManageDSAit support to back-dnssrv
authorKurt Zeilenga <kurt@openldap.org>
Mon, 5 Jun 2000 03:10:46 +0000 (03:10 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 5 Jun 2000 03:10:46 +0000 (03:10 +0000)
Fix backend critical controls crash
Move 'associatedDomain' to core.schema

14 files changed:
clients/tools/ldapsearch.c
servers/slapd/back-dnssrv/add.c
servers/slapd/back-dnssrv/back-dnssrv.h
servers/slapd/back-dnssrv/compare.c
servers/slapd/back-dnssrv/delete.c
servers/slapd/back-dnssrv/init.c
servers/slapd/back-dnssrv/modify.c
servers/slapd/back-dnssrv/modrdn.c
servers/slapd/back-dnssrv/request.c
servers/slapd/back-dnssrv/search.c
servers/slapd/charray.c
servers/slapd/schema/core.schema
servers/slapd/schema/cosine.schema
servers/slapd/schema/pilot.schema

index 460b199f1f17acbfe75bbb796c893edf9970942d..319b31b8860fef9c2025a93950a4d293179492ff 100644 (file)
@@ -671,7 +671,7 @@ static int dosearch(
        char    *value)
 {
        char            filter[ BUFSIZ ];
-       int                     rc, first, matches, err;
+       int                     rc, first, matches;
        LDAPMessage             *res, *e;
 
        if( filtpatt != NULL ) {
@@ -721,8 +721,7 @@ static int dosearch(
        ldap_perror( ld, "ldap_result" );
        return( rc );
        }
-       rc = ldap_parse_result( ld, res, &err, NULL, NULL, NULL, NULL, 0 );
-       if ( rc != LDAP_SUCCESS || rc != LDAP_SUCCESS ) {
+       if (( rc = ldap_result2error( ld, res, 0 )) != LDAP_SUCCESS ) {
                ldap_perror( ld, "ldap_search" );
        }
        if ( sortattr != NULL ) {
index aed74a3e6a49a7b306888c1d0b01981e17cad6b9..67292e7bb716bfa44478aaefe1a8dcc13c52ad00 100644 (file)
@@ -23,5 +23,6 @@ dnssrv_back_add(
     Entry      *e
 )
 {
-       return dnssrv_back_request( be, conn, op, e->e_dn, e->e_ndn );
+       return dnssrv_back_request( be, conn, op, e->e_dn, e->e_ndn,
+               0, NULL, NULL, 0 );
 }
index 878e85f71acec56aec422e75206e9f20af86e310..e4a401d8c84ec0d5745e973b583dd0eb6b57e2cb 100644 (file)
@@ -20,7 +20,9 @@ int dnssrv_result();
 extern int dnssrv_back_request LDAP_P((
        BackendDB *bd,
        Connection *conn, Operation *op,
-       const char *dn, const char *ndn ));
+       const char *dn, const char *ndn,
+       int scope, Filter *filter,
+       char **attrs, int attrsonly ));
 
 LDAP_END_DECL
 
index 2ec14988ada6d69c1c528a92817e605d9c42b9a5..140121e3c7aba1c5ba132edbba6737fa45c60986 100644 (file)
@@ -29,5 +29,6 @@ dnssrv_back_compare(
 #endif
 )
 {
-       return dnssrv_back_request( be, conn, op, dn, ndn );
+       return dnssrv_back_request( be, conn, op, dn, ndn,
+               0, NULL, NULL, 0 );
 }
index 4ab5049e782873ea6dd66f3ccdb8fda8dd3c1aec..abcbf3fe679599f71aee51848833baeb67b9fcac 100644 (file)
@@ -25,5 +25,6 @@ dnssrv_back_delete(
     const char *ndn
 )
 {
-       return dnssrv_back_request( be, conn, op, dn, ndn );
+       return dnssrv_back_request( be, conn, op, dn, ndn,
+               0, NULL, NULL, 0 );
 }
index 743c17114ea143e6828f680987c1f9c0dc298411..7e7679f8cdcb4af60270d80952fcca3c90d77e59 100644 (file)
@@ -34,6 +34,13 @@ dnssrv_back_initialize(
     BackendInfo        *bi
 )
 {
+       static char *controls[] = {
+               LDAP_CONTROL_MANAGEDSAIT,
+               NULL
+       };
+
+       bi->bi_controls = controls;
+
        bi->bi_open = 0;
        bi->bi_config = 0;
        bi->bi_close = 0;
index 4da2f55093458016f71b13e600219740b9c4552f..53d7c23a5265b051870b869077ae15e5e3cd7a04 100644 (file)
@@ -26,5 +26,6 @@ dnssrv_back_modify(
     Modifications      *ml
 )
 {
-       return dnssrv_back_request( be, conn, op, dn, ndn );
+       return dnssrv_back_request( be, conn, op, dn, ndn,
+               0, NULL, NULL, 0 );
 }
index c461cdf4fb8521658ed655194fb4ec4cc009d3de..c595dcbc4f31ff793f4d5fde6698b57930c2fecd 100644 (file)
@@ -27,5 +27,6 @@ dnssrv_back_modrdn(
     const char *newSuperior
 )
 {
-       return dnssrv_back_request( be, conn, op, dn, ndn );
+       return dnssrv_back_request( be, conn, op, dn, ndn,
+               0, NULL, NULL, 0 );
 }
index 3e68d5db6719f2f3b7bced2422f1080e2de813a4..a781ef94aaa9c719ae125180cc12c1963111d87c 100644 (file)
@@ -21,7 +21,9 @@ dnssrv_back_request(
     Connection *conn,
     Operation  *op,
     const char *dn,
-    const char *ndn )
+    const char *ndn,
+       int scope, Filter *filter,
+       char **attrs, int attrsonly )
 {
        int i;
        int rc;
@@ -29,6 +31,7 @@ dnssrv_back_request(
        char *hostlist = NULL;
        char **hosts = NULL;
        struct berval **urls = NULL;
+       int             manageDSAit = get_manageDSAit( op );
 
        if( ndn == NULL || *ndn == '\0' ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
@@ -87,12 +90,122 @@ dnssrv_back_request(
            "conn=%ld op=%d DNSSRV p=%d dn=\"%s\" url=\"%s\"\n",
            op->o_connid, op->o_opid, op->o_protocol, dn, urls[0]->bv_val );
 
-       Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=\"%s\" -> url=\"%s\"\n",
+       Debug( LDAP_DEBUG_TRACE, "DNSSRV: %sdn=\"%s\" -> url=\"%s\"\n",
+               manageDSAit ? "ManageDSAit " : "",
                dn == NULL ? "" : dn,
-               urls[0]->bv_val, 0 );
+               urls[0]->bv_val );
 
-       send_ldap_result( conn, op, LDAP_REFERRAL,
-               NULL, "DNS SRV generated referrals", urls, NULL );
+       if( manageDSAit ) {
+               if( op->o_tag != LDAP_REQ_SEARCH ) {
+                       send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+                               dn, "DNS SRV ManageDSAIT control disallowed",
+                               NULL, NULL );
+
+               } else if ( scope != LDAP_SCOPE_ONELEVEL ) {
+                       struct berval   val;
+                       struct berval   *vals[2];
+                       Entry *e = ch_calloc( 1, sizeof(Entry) );
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+                       AttributeDescription *ad_objectClass
+                               = slap_schema.si_ad_objectClass;
+                       AttributeDescription *ad_ref = slap_schema.si_ad_ref;
+#else
+                       const char ad_objectClass = "objectClass";
+                       const char ad_ref = "ref";
+#endif
+                       e->e_dn = strdup( dn );
+                       e->e_ndn = strdup( ndn );
+
+                       e->e_attrs = NULL;
+                       e->e_private = NULL;
+
+                       vals[0] = &val;
+                       vals[1] = NULL;
+
+                       val.bv_val = "top";
+                       val.bv_len = sizeof("top")-1;
+                       attr_merge( e, ad_objectClass, vals );
+
+                       val.bv_val = "referral";
+                       val.bv_len = sizeof("referral")-1;
+                       attr_merge( e, ad_objectClass, vals );
+
+                       val.bv_val = "extensibleObject";
+                       val.bv_len = sizeof("extensibleObject")-1;
+                       attr_merge( e, ad_objectClass, vals );
+
+                       {
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+                               AttributeDescription *ad = NULL;
+                               const char *text;
+
+                               rc = slap_str2ad( "dc", &ad, &text );
+#else
+                               rc = LDAP_SUCCESS;
+                               const char *ad = "dc";
+#endif
+
+                               if( rc == LDAP_SUCCESS ) {
+                                       char *p;
+                                       val.bv_val = ch_strdup( domain );
+
+                                       p = strchr( val.bv_val, '.' );
+                                       
+                                       if( p == val.bv_val ) {
+                                               val.bv_val[1] = '\0';
+                                       } else if ( p != NULL ) {
+                                               *p = '\0';
+                                       }
+
+                                       val.bv_len = strlen(val.bv_val);
+                                       attr_merge( e, ad, vals );
+
+                                       ad_free( ad, 1 );
+                               }
+                       }
+
+                       {
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+                               AttributeDescription *ad = NULL;
+                               const char *text;
+
+                               rc = slap_str2ad( "associatedDomain", &ad, &text );
+#else
+                               rc = LDAP_SUCCESS;
+                               const char *ad = "associatedDomain";
+#endif
+
+                               if( rc == LDAP_SUCCESS ) {
+                                       val.bv_val = domain;
+                                       val.bv_len = strlen(domain);
+                                       attr_merge( e, ad, vals );
+
+                                       ad_free( ad, 1 );
+                               }
+                       }
+
+                       attr_merge( e, ad_ref, urls );
+
+                       rc = test_filter( be, conn, op, e, filter ); 
+
+                       if( rc == LDAP_COMPARE_TRUE ) {
+                               send_search_entry( be, conn, op,
+                                       e, attrs, attrsonly, NULL );
+                       }
+
+                       entry_free( e );
+                       
+                       send_ldap_result( conn, op, LDAP_SUCCESS,
+                               NULL, NULL, NULL, NULL );
+
+               } else {
+                       send_ldap_result( conn, op, LDAP_SUCCESS,
+                               NULL, NULL, NULL, NULL );
+               }
+       } else {
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       NULL, "DNS SRV generated referrals", urls, NULL );
+       }
 
 done:
        if( domain != NULL ) ch_free( domain );
index 93f26d3a3805399c8a4732b5aa6291b9775fe42e..d9dea2e3ed8fab39fa6a2f252058302ee63f5389 100644 (file)
@@ -34,5 +34,6 @@ dnssrv_back_search(
     int                attrsonly
 )
 {
-       return dnssrv_back_request( be, conn, op, dn, ndn );
+       return dnssrv_back_request( be, conn, op, dn, ndn,
+               scope, filter, attrs, attrsonly );
 }
index b67ec5a4db95fde28871c0e66a95773dcd2e79d3..b51659141a24ccfe13a5fb12d7a16c9d12ec0da5 100644 (file)
@@ -86,6 +86,8 @@ charray_inlist(
 {
        int     i;
 
+       if( a == NULL ) return 0;
+
        for ( i = 0; a[i] != NULL; i++ ) {
                if ( strcasecmp( s, a[i] ) == 0 ) {
                        return( 1 );
index 880c668fc3fe00006cfaa1cccb0c7b70c332c98e..bbf2dd593fa626e2fa69388112c5c9cc3153c8fa 100644 (file)
@@ -582,6 +582,14 @@ objectclass ( 1.3.6.1.4.1.4203.666.3.2
        SUP top STRUCTURAL MAY cn )
 
 
+#
+# From Cosine Pilot
+#
+attributetype ( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain'
+       EQUALITY caseIgnoreIA5Match
+       SUBSTR caseIgnoreIA5SubstringsMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
 #
 # From U-Mich
 #
index 3e23f587f824f82de5f0cd2e0d086cd96e1bdf40..ff2d9f98118f141f83ca5b099974529937df1f19 100644 (file)
@@ -527,10 +527,10 @@ attributetype ( 0.9.2342.19200300.100.1.31 NAME 'cNAMERecord'
 #            caseIgnoreIA5StringSyntax
 #    ::= {pilotAttributeType 37}
 #
-attributetype ( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain'
-       EQUALITY caseIgnoreIA5Match
-       SUBSTR caseIgnoreIA5SubstringsMatch
-       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+#attributetype ( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain'
+#      EQUALITY caseIgnoreIA5Match
+#      SUBSTR caseIgnoreIA5SubstringsMatch
+#      SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
 
 # 9.3.28.  Associated Name
 #
index 0feb3a6981171515c025d67156eb37db07ee2df3..05e9552af780098983cf6ab8fbad457c0248ade4 100644 (file)
@@ -122,14 +122,10 @@ attributetype ( 0.9.2342.19200300.100.1.26 NAME 'dNSRecord'
 # 0.9.2342.19200300.100.1.30 was sOARecord in RFC1274
 # 0.9.2342.19200300.100.1.31 was cNAMERecord in RFC1274
 
-# Terrific, we don't know about caseIgnoreIA5SubstringsMatch
 #attribute ( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain'
 #      EQUALITY caseIgnoreIA5Match
 #      SUBSTR caseIgnoreIA5SubstringsMatch
 #      SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
-attributetype ( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain'
-       EQUALITY caseIgnoreIA5Match
-       SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
 
 attributetype ( 0.9.2342.19200300.100.1.38 NAME 'associatedName'
        EQUALITY distinguishedNameMatch