s3-winbindd: add and use winbindd_lookup_sids().
[ira/wip.git] / source3 / winbindd / winbindd_ads.c
index 450d2ee3e5dd918fa5c273183bda279845f390de..119e81d3e2e7f61cd132a35a2777b5b79a0d1ad1 100644 (file)
@@ -983,8 +983,6 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
        int i;
        size_t num_members = 0;
        ads_control args;
-        struct rpc_pipe_client *cli;
-        struct policy_handle lsa_policy;
        DOM_SID *sid_mem_nocache = NULL;
        char **names_nocache = NULL;
        enum lsa_SidType *name_types_nocache = NULL;
@@ -1126,31 +1124,14 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
 
        /* handle sids not resolved from cache by lsa_lookup_sids */
        if (num_nocache > 0) {
-               unsigned int orig_timeout;
 
-               status = cm_connect_lsa(domain, tmp_ctx, &cli, &lsa_policy);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       goto done;
-               }
-
-               /*
-                * This call can take a long time
-                * allow the server to time out.
-                * 35 seconds should do it.
-                */
-               orig_timeout = rpccli_set_timeout(cli, 35000);
-
-               status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
-                                               &lsa_policy,
-                                               num_nocache,
-                                               sid_mem_nocache,
-                                               &domains_nocache,
-                                               &names_nocache,
-                                               &name_types_nocache);
-
-               /* And restore our original timeout. */
-               rpccli_set_timeout(cli, orig_timeout);
+               status = winbindd_lookup_sids(tmp_ctx,
+                                             domain,
+                                             num_nocache,
+                                             sid_mem_nocache,
+                                             &domains_nocache,
+                                             &names_nocache,
+                                             &name_types_nocache);
 
                if (!(NT_STATUS_IS_OK(status) ||
                      NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED) ||
@@ -1159,30 +1140,13 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                        DEBUG(1, ("lsa_lookupsids call failed with %s "
                                  "- retrying...\n", nt_errstr(status)));
 
-                       status = cm_connect_lsa(domain, tmp_ctx, &cli,
-                                               &lsa_policy);
-
-                       if (!NT_STATUS_IS_OK(status)) {
-                               goto done;
-                       }
-
-                       /*
-                        * This call can take a long time
-                        * allow the server to time out.
-                        * 35 seconds should do it.
-                        */
-                       orig_timeout = rpccli_set_timeout(cli, 35000);
-
-                       status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
-                                                       &lsa_policy,
-                                                       num_nocache,
-                                                       sid_mem_nocache,
-                                                       &domains_nocache,
-                                                       &names_nocache,
-                                                       &name_types_nocache);
-
-                       /* And restore our original timeout. */
-                       rpccli_set_timeout(cli, orig_timeout);
+                       status = winbindd_lookup_sids(tmp_ctx,
+                                                     domain,
+                                                     num_nocache,
+                                                     sid_mem_nocache,
+                                                     &domains_nocache,
+                                                     &names_nocache,
+                                                     &name_types_nocache);
                }
 
                if (NT_STATUS_IS_OK(status) ||