TODO sort trusts
authorStefan Metzmacher <metze@samba.org>
Thu, 2 Mar 2017 07:05:48 +0000 (08:05 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 17 Feb 2020 11:31:13 +0000 (12:31 +0100)
source3/winbindd/winbindd_ads.c

index 20f47eb5954f67d569aaa250d75ac0524c50fc36..ee9764fd67fd008f292eb19394b8db4eb6cd8f13 100644 (file)
@@ -1387,6 +1387,30 @@ static NTSTATUS password_policy(struct winbindd_domain *domain,
        return msrpc_methods.password_policy(domain, mem_ctx, policy);
 }
 
+
+static int trusted_domains_cmp(struct netr_DomainTrust *d1,
+                              struct netr_DomainTrust *d2)
+{
+
+       return 0;
+#if 0
+       /* Silly cases */
+
+       if (!j1 && !j2)
+               return 0;
+       if (!j1)
+               return -1;
+       if (!j2)
+               return 1;
+
+       /* Sort on job start time */
+
+       if (j1->time == j2->time)
+               return 0;
+       return (j1->time > j2->time) ? 1 : -1;
+#endif
+}
+
 /* get a list of trusted domains */
 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
@@ -1445,7 +1469,8 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
 
        /* Copy across names and sids */
 
-       ret_count = 0;
+       TYPESAFE_QSORT(trusts->array, trusts->count, trusted_domains_cmp);
+
        for (i = 0; i < trusts->count; i++) {
                struct netr_DomainTrust *trust = &trusts->array[i];
                struct winbindd_domain d;
@@ -1492,7 +1517,6 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                        d.domain_trust_attribs = trust->trust_attributes;
 
                        wcache_tdc_add_domain( &d );
-                       ret_count++;
                } else if (domain_is_forest_root(domain)) {
                        /* Check if we already have this record. If
                         * we are following our forest root that is not
@@ -1514,7 +1538,6 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                                        trust->trust_attributes;
 
                                wcache_tdc_add_domain( &d );
-                               ret_count++;
                        }
                        TALLOC_FREE(exist);
                } else {
@@ -1555,7 +1578,6 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                        trust->trust_attributes = d.domain_trust_attribs;
 
                        wcache_tdc_add_domain( &d );
-                       ret_count++;
                }
        }
        return result;