s4/schema: Handle Object(OR-Name) syntax in extended_dn_out module
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Sun, 22 Nov 2009 15:48:32 +0000 (17:48 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 23 Nov 2009 13:15:06 +0000 (14:15 +0100)
Windows displays attribute values with Object(OR-Name) syntax
in plain DN format when queried through LDAP.
Hence, we need to post-process such values specially
in extended_dn_out.c module so they are always shown as plain DN,
no matter what controls are passed for search request.

source4/dsdb/samdb/ldb_modules/extended_dn_out.c

index 1249a9c..c52953c 100644 (file)
@@ -398,6 +398,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 
        /* Walk the retruned elements (but only if we have a schema to interpret the list with) */
        for (i = 0; ac->schema && i < msg->num_elements; i++) {
+               bool make_extended_dn;
                const struct dsdb_attribute *attribute;
                attribute = dsdb_attribute_by_lDAPDisplayName(ac->schema, msg->elements[i].name);
                if (!attribute) {
@@ -425,6 +426,13 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
                        continue;
                }
 
+               make_extended_dn = ac->inject;
+
+               /* Always show plain DN in case of Object(OR-Name) syntax */
+               if (make_extended_dn) {
+                       make_extended_dn = (strcmp(attribute->syntax->ldap_oid, DSDB_SYNTAX_OR_NAME) != 0);
+               }
+
                for (j = 0; j < msg->elements[i].num_values; j++) {
                        const char *dn_str;
                        struct ldb_dn *dn;
@@ -470,12 +478,12 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
                                }
                        }
                        
-                       if (!ac->inject) {
+                       if (make_extended_dn) {
+                               dn_str = dsdb_dn_get_extended_linearized(msg->elements[i].values,
+                                                                        dsdb_dn, ac->extended_type);
+                       } else {
                                dn_str = dsdb_dn_get_linearized(msg->elements[i].values, 
                                                                dsdb_dn);
-                       } else {
-                               dn_str = dsdb_dn_get_extended_linearized(msg->elements[i].values, 
-                                                                        dsdb_dn, ac->extended_type);
                        }
                        
                        if (!dn_str) {