r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[ira/wip.git] / source3 / nsswitch / winbindd_rpc.c
index 27feea2f6715d84c83d3dde6998ddb62a74bbc03..d8797ee2bc6e15d6c2cec49525b6fb637c06bda4 100644 (file)
@@ -318,6 +318,58 @@ NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
        return NT_STATUS_OK;
 }
 
+NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
+                            TALLOC_CTX *mem_ctx,
+                            const DOM_SID *sid,
+                            uint32 *rids,
+                            size_t num_rids,
+                            char **domain_name,
+                            char ***names,
+                            enum SID_NAME_USE **types)
+{
+       char **domains;
+       NTSTATUS result;
+       struct rpc_pipe_client *cli;
+       POLICY_HND lsa_policy;
+       DOM_SID *sids;
+       size_t i;
+
+       DEBUG(3, ("rids_to_names [rpc] for domain %s\n", domain->name ));
+
+       sids = TALLOC_ARRAY(mem_ctx, DOM_SID, num_rids);
+       if (sids == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       for (i=0; i<num_rids; i++) {
+               if (!sid_compose(&sids[i], sid, rids[i])) {
+                       return NT_STATUS_INTERNAL_ERROR;
+               }
+       }
+
+       result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
+       if (!NT_STATUS_IS_OK(result)) {
+               return result;
+       }
+
+       result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
+                                       num_rids, sids, &domains,
+                                       names, types);
+       if (!NT_STATUS_IS_OK(result) &&
+           !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
+               return result;
+       }
+
+       for (i=0; i<num_rids; i++) {
+               if ((*types)[i] != SID_NAME_UNKNOWN) {
+                       *domain_name = domains[i];
+                       break;
+               }
+       }
+
+       return result;
+}
+
 /* Lookup user information from a rid or username. */
 static NTSTATUS query_user(struct winbindd_domain *domain, 
                           TALLOC_CTX *mem_ctx, 
@@ -772,7 +824,6 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
        NTSTATUS result;
        POLICY_HND dom_pol;
        BOOL got_seq_num = False;
-       int retry;
        struct rpc_pipe_client *cli;
 
        DEBUG(10,("rpc: fetch sequence_number for %s\n", domain->name));
@@ -782,8 +833,6 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
        if (!(mem_ctx = talloc_init("sequence_number[rpc]")))
                return NT_STATUS_NO_MEMORY;
 
-       retry = 0;
-
 #ifdef HAVE_LDAP
        if ( domain->native_mode ) 
        {
@@ -985,6 +1034,7 @@ struct winbindd_methods msrpc_methods = {
        enum_local_groups,
        msrpc_name_to_sid,
        msrpc_sid_to_name,
+       msrpc_rids_to_names,
        query_user,
        lookup_usergroups,
        msrpc_lookup_useraliases,