winbind: Add wbint_QueryUserRidList
authorVolker Lendecke <vl@samba.org>
Thu, 29 Dec 2016 18:13:28 +0000 (18:13 +0000)
committerVolker Lendecke <vl@samba.org>
Mon, 2 Jan 2017 17:04:14 +0000 (18:04 +0100)
This is an equivalent of QueryUserList with simpler output. The next
commit will use it to go through wb_getpwsid for getent passwd, to
make sure we get the same results. Eventually, this might get a simpler
backend.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
librpc/idl/winbind.idl
source3/winbindd/winbindd_dual_srv.c

index ab1a32e059c715e937025d7dbe56283730b4b08a..d38b17a0da4bdf5bba7d319f10cff659be1a2572 100644 (file)
@@ -147,6 +147,10 @@ interface winbind
        [out] wbint_Principals *groups
        );
 
+    NTSTATUS wbint_QueryUserRidList(
+       [out] wbint_RidArray *rids
+       );
+
     NTSTATUS wbint_DsGetDcName(
        [in,string,charset(UTF8)]               char *domain_name,
        [in,unique]                             GUID *domain_guid,
index cf4846d00db03e58c4fdbdc5652f91d29413c74d..a75e5771068916519c4bfbe031b5f07ca5d76383 100644 (file)
@@ -511,6 +511,53 @@ NTSTATUS _wbint_QueryGroupList(struct pipes_struct *p,
        return NT_STATUS_OK;
 }
 
+NTSTATUS _wbint_QueryUserRidList(struct pipes_struct *p,
+                                struct wbint_QueryUserRidList *r)
+{
+       struct winbindd_domain *domain = wb_child_domain();
+       uint32_t i, num_userinfos;
+       struct wbint_userinfo *userinfos;
+       NTSTATUS status;
+
+       if (domain == NULL) {
+               return NT_STATUS_REQUEST_NOT_ACCEPTED;
+       }
+
+       /*
+        * Right now this is overkill. We should add a backend call
+        * just querying the rids.
+        */
+
+       status = wb_cache_query_user_list(domain, p->mem_ctx,
+                                         &num_userinfos, &userinfos);
+       reset_cm_connection_on_error(domain, status);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       r->out.rids->rids = talloc_array(r->out.rids, uint32_t, num_userinfos);
+       if (r->out.rids->rids == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       for (i=0; i<num_userinfos; i++) {
+               struct wbint_userinfo *info = &userinfos[i];
+
+               if (!dom_sid_in_domain(&domain->sid, &info->user_sid)) {
+                       fstring sidstr, domstr;
+                       DBG_WARNING("Got sid %s in domain %s\n",
+                                   sid_to_fstring(sidstr, &info->user_sid),
+                                   sid_to_fstring(domstr, &domain->sid));
+                       continue;
+               }
+               sid_split_rid(&info->user_sid,
+                             &r->out.rids->rids[r->out.rids->num_rids++]);
+       }
+
+       return status;
+}
+
 NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
 {
        struct winbindd_domain *domain = wb_child_domain();