Fix build break
[jra/samba/.git] / source3 / winbindd / winbindd_ads.c
index ae8ad9dd1a868edf2ebc7e62886d0a92597ff42c..1febddf110b422bcc29e959847130bb4eca30ab7 100644 (file)
@@ -393,7 +393,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
         * using LDAP.
         *
         * if we ever need to enumerate domain local groups separately, 
-        * then this the optimization in enum_dom_groups() will need 
+        * then this optimization in enum_dom_groups() will need
         * to be split out
         */
        *num_entries = 0;
@@ -1023,10 +1023,11 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                        DEBUG(10,("ads: lookup_groupmem: got sid %s from "
                                  "cache\n", sid_string_dbg(&sid)));
                        sid_copy(&(*sid_mem)[*num_names], &sid);
-                       (*names)[*num_names] = talloc_asprintf(*names, "%s%c%s",
-                                                              domain_name,
-                                                              *lp_winbind_separator(),
-                                                              name );
+                       (*names)[*num_names] = fill_domain_username_talloc(
+                                                       *names,
+                                                       domain_name,
+                                                       name,
+                                                       true);
 
                        (*name_types)[*num_names] = name_type;
                        (*num_names)++;
@@ -1071,11 +1072,12 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                                {
                                        sid_copy(&(*sid_mem)[*num_names],
                                                 &sid_mem_nocache[i]);
-                                       (*names)[*num_names] = talloc_asprintf( *names, 
-                                                                               "%s%c%s",
-                                                                               domains_nocache[i],
-                                                                               *lp_winbind_separator(),
-                                                                               names_nocache[i] );
+                                       (*names)[*num_names] =
+                                               fill_domain_username_talloc(
+                                                       *names,
+                                                       domains_nocache[i],
+                                                       names_nocache[i],
+                                                       true);
                                        (*name_types)[*num_names] = name_types_nocache[i];
                                        (*num_names)++;
                                }
@@ -1195,7 +1197,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
        }
 
        result = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
-                                                     cli->cli->desthost,
+                                                     cli->desthost,
                                                      flags,
                                                      &trusts,
                                                      NULL);
@@ -1225,6 +1227,8 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                for (i = 0; i < trusts.count; i++) {
                        struct winbindd_domain d;
                        
+                       ZERO_STRUCT(d);
+
                        /* drop external trusts if this is not our primary 
                           domain.  This means that the returned number of 
                           domains may be less that the ones actually trusted
@@ -1241,13 +1245,21 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                        
                        (*names)[ret_count] = CONST_DISCARD(char *, trusts.array[i].netbios_name);
                        (*alt_names)[ret_count] = CONST_DISCARD(char *, trusts.array[i].dns_name);
-                       sid_copy(&(*dom_sids)[ret_count], trusts.array[i].sid);
+                       if (trusts.array[i].sid) {
+                               sid_copy(&(*dom_sids)[ret_count], trusts.array[i].sid);
+                       } else {
+                               sid_copy(&(*dom_sids)[ret_count], &global_sid_NULL);
+                       }
 
                        /* add to the trusted domain cache */
 
                        fstrcpy( d.name,  trusts.array[i].netbios_name);
                        fstrcpy( d.alt_name, trusts.array[i].dns_name);
-                       sid_copy( &d.sid, trusts.array[i].sid);
+                       if (trusts.array[i].sid) {
+                               sid_copy( &d.sid, trusts.array[i].sid);
+                       } else {
+                               sid_copy(&d.sid, &global_sid_NULL);
+                       }
 
                        if ( domain->primary ) {
                                DEBUG(10,("trusted_domains(ads):  Searching "