]> git.sur5r.net Git - openldap/commitdiff
Added numsubordinates operational attribute
authorHoward Chu <hyc@openldap.org>
Thu, 28 Oct 1999 07:09:30 +0000 (07:09 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 28 Oct 1999 07:09:30 +0000 (07:09 +0000)
servers/slapd/back-ldbm/search.c

index 67a6c82e176588f06575c9f6f869f97528983576..b680818cd99f2a104aaf21e133429aa5222a59b6 100644 (file)
@@ -282,8 +282,52 @@ ldbm_back_search(
                                }
 
                                if (e) {
-                                       switch ( send_search_entry( be, conn, op, e,
-                                               attrs, attrsonly, NULL ) ) {
+                                       /* Tack on subordinates attr */
+                                       int result;
+                                       ID_BLOCK *idl = NULL;
+                                       char CATTR_SUBS[] = "numsubordinates";
+
+                                       if (attrs &&
+                                           charray_inlist(attrs,
+                                                          CATTR_SUBS))
+                                       {
+                                           idl = dn2idl(be, e->e_ndn,
+                                                        DN_ONE_PREFIX);
+                                           if (idl)
+                                           {
+                                               char buf[30];
+                                               struct berval val, *vals[2];
+
+                                               vals[0] = &val;
+                                               vals[1] = NULL;
+
+                                               sprintf(buf, "%lu",
+                                                       ID_BLOCK_NIDS(idl));
+
+                                               val.bv_val = buf;
+                                               val.bv_len = strlen(buf);
+
+                                               attr_merge(e, CATTR_SUBS,
+                                                          vals);
+                                           }
+                                       }
+
+                                       result = send_search_entry(be,
+                                                                  conn,
+                                                                  op,
+                                                                  e,
+                                                                  attrs,
+                                                                  attrsonly,
+                                                                  NULL);
+                                       if (idl)
+                                       {
+                                           idl_free(idl);
+                                           attr_delete(&e->e_attrs,
+                                                       CATTR_SUBS);
+                                       }
+
+                                       switch (result)
+                                       {
                                        case 0:         /* entry sent ok */
                                                nentries++;
                                                break;