]> git.sur5r.net Git - openldap/commitdiff
backend_group selects the correct backend for the group.
authorMark Valence <mrv@openldap.org>
Mon, 5 Jun 2000 04:34:59 +0000 (04:34 +0000)
committerMark Valence <mrv@openldap.org>
Mon, 5 Jun 2000 04:34:59 +0000 (04:34 +0000)
servers/slapd/backend.c

index e9f4c0e4de910a7aa3f96f547d0a8715f2cddf12..be9b3d0647e31abef5998b71dd41a512182c66ea 100644 (file)
@@ -644,8 +644,41 @@ backend_group(
 #endif
 )
 {
-       if (be->be_group)
-               return( be->be_group(be, target, gr_ndn, op_ndn,
+       int dnlen, i;
+       Backend *gr_be = NULL;
+
+       dnlen = strlen( gr_ndn );
+       if (be != NULL && be->be_nsuffix != NULL) {
+               /* search through all the backend suffixes
+                * to see if the group dn belongs to this
+                * backend.
+                */
+               for (   i = 0;
+                               be->be_nsuffix[i] != NULL;
+                               i++ )
+               {
+                       int len = strlen( be->be_nsuffix[i] );
+                       if ( len > dnlen )
+                               continue;
+
+                       if (strcmp(be->be_nsuffix[i], gr_ndn + (dnlen - len)) == 0) {
+                               gr_be = be;
+                               break;
+                       }
+               }
+       }
+
+       if (gr_be == NULL) {
+               /* if the gr_ndn does not belong to
+                * the given backend, then find the
+                * backend that it does belong to.
+                */
+               gr_be = select_backend(gr_ndn);
+               if (gr_be == NULL)
+                       return(1);
+       }
+       if (gr_be->be_group)
+               return( gr_be->be_group(gr_be, target, gr_ndn, op_ndn,
                        group_oc, group_at) );
        else
                return LDAP_UNWILLING_TO_PERFORM;