added ads_domain_sid() function
authorAndrew Tridgell <tridge@samba.org>
Thu, 20 Dec 2001 23:35:14 +0000 (23:35 +0000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 20 Dec 2001 23:35:14 +0000 (23:35 +0000)
source/libads/ldap.c
source/nsswitch/winbindd_ads.c

index d2b9f74c4d6ac1221875eb933d6661dd45c5d87f..8966ceb32a9c263d99cc4a4b10c01abeb5609bda 100644 (file)
@@ -680,4 +680,22 @@ ADS_STATUS ads_trusted_domains(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
        return ADS_SUCCESS;
 }
 
+/* find the domain sid for our domain */
+ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, DOM_SID *sid)
+{
+       const char *attrs[] = {"objectSid", NULL};
+       void *res;
+       ADS_STATUS rc;
+
+       rc = ads_do_search(ads, ads->bind_path, LDAP_SCOPE_BASE, "(objectclass=*)", 
+                          attrs, &res);
+       if (!ADS_ERR_OK(rc)) return rc;
+       if (!ads_pull_sid(ads, res, "objectSid", sid)) {
+               return ADS_ERROR_SYSTEM(ENOENT);
+       }
+       ads_msgfree(ads, res);
+       
+       return ADS_SUCCESS;
+}
+
 #endif
index 8d0c78b2d5c22b40722a5fff78fff107c5bd3efc..a0d35030bf631acbae15a7fcae538d3a902337ef 100644 (file)
@@ -706,7 +706,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                                char ***names,
                                DOM_SID **dom_sids)
 {
-       ADS_STRUCT *ads = NULL;
+       ADS_STRUCT *ads;
        ADS_STATUS rc;
 
        *num_domains = 0;
@@ -723,25 +723,15 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
 /* find the domain sid for a domain */
 static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
 {
-       NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
-       const char *attrs[] = {"objectSid", NULL};
-       ADS_STRUCT *ads = NULL;
-       void *res;
+       ADS_STRUCT *ads;
        ADS_STATUS rc;
 
        ads = ads_cached_connection(domain);
-       if (!ads) goto done;
+       if (!ads) return NT_STATUS_UNSUCCESSFUL;
 
-       rc = ads_do_search(ads, ads->bind_path, LDAP_SCOPE_BASE, "(objectclass=*)", 
-                          attrs, &res);
-       if (!ADS_ERR_OK(rc)) goto done;
-       if (ads_pull_sid(ads, res, "objectSid", sid)) {
-               status = NT_STATUS_OK;
-       }
-       ads_msgfree(ads, res);
+       rc = ads_domain_sid(ads, sid);
 
-done:
-       return status;
+       return ads_ntstatus(rc);
 }
 
 /* the ADS backend methods are exposed via this structure */