r7055: automatically add the dn to all ldbSearch results
authorAndrew Tridgell <tridge@samba.org>
Sat, 28 May 2005 08:59:46 +0000 (08:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:09 +0000 (13:17 -0500)
(This used to be commit d6fa28080831700f80ff46320e0b0831337b822a)

source4/web_server/calls.c

index 3626f33981b8344d5f795d6c56ac0fcfcb909997..fc23a113fefc40f9832d9175d63eee48615e55ae 100644 (file)
@@ -78,11 +78,12 @@ static struct MprVar mprLdbMessage(struct ldb_message *msg)
           need a special case for the single value case */
        const char *multivalued[] = { "objectClass", "memberOf", "privilege", 
                                            "member", NULL };
+       struct MprVar val;
 
        var = mprCreateObjVar(msg->dn, ESP_HASH_SIZE);
+
        for (i=0;i<msg->num_elements;i++) {
                struct ldb_message_element *el = &msg->elements[i];
-               struct MprVar val;
                if (el->num_values == 1 &&
                    !str_list_check_ci(multivalued, el->name)) {
                        val = mprData(el->values[0].data, el->values[0].length);
@@ -97,6 +98,12 @@ static struct MprVar mprLdbMessage(struct ldb_message *msg)
                }
                mprCreateProperty(&var, el->name, &val);
        }
+
+       /* add the dn if it is not already specified */
+       if (mprGetProperty(&var, "dn", 0) == 0) {
+               val = mprCreateStringVar(msg->dn, 1);
+               mprCreateProperty(&var, "dn", &val);
+       }
        
        return var;             
 }