sync'ing up for 3.0alpha20 release
[kai/samba.git] / source3 / nsswitch / winbindd_rpc.c
index 5af42ee041bb1b5b3d8e3b37aaa5ac306f25417f..047280e21e48bc2c31a1c7a77dc4ea19e6192401 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "winbindd.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_WINBIND
+
 /* Query display info for a domain.  This returns enough information plus a
    bit extra to give an overview of domain users for the User Manager
    application. */
@@ -38,6 +41,8 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
        uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
        int i;
 
+       DEBUG(3,("rpc: query_user_list\n"));
+
        *num_entries = 0;
        *info = NULL;
 
@@ -130,6 +135,8 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
        *num_entries = 0;
        *info = NULL;
 
+       DEBUG(3,("rpc: enum_dom_groups\n"));
+
        if (!(hnd = cm_get_sam_handle(domain->name))) {
                return NT_STATUS_UNSUCCESSFUL;
        }
@@ -187,9 +194,10 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
        NTSTATUS status;
        DOM_SID *sids = NULL;
        uint32 *types = NULL;
-       int num_sids;
        const char *full_name;
 
+       DEBUG(3,("rpc: name_to_sid name=%s\n", name));
+
        if (!(mem_ctx = talloc_init_named("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
                DEBUG(0, ("talloc_init failed!\n"));
                return NT_STATUS_NO_MEMORY;
@@ -209,9 +217,10 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
        }
 
        status = cli_lsa_lookup_names(hnd->cli, mem_ctx, &hnd->pol, 1, 
-                                     &full_name, &sids, &types, &num_sids);
+                                     &full_name, &sids, &types);
         
-       /* Return rid and type if lookup successful */        
+       /* Return rid and type if lookup successful */
+
        if (NT_STATUS_IS_OK(status)) {
                sid_copy(sid, &sids[0]);
                *type = types[0];
@@ -234,15 +243,15 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
        char **domains;
        char **names;
        uint32 *types;
-       int num_names;
        NTSTATUS status;
 
+       DEBUG(3,("rpc: sid_to_name\n"));
+
        if (!(hnd = cm_get_lsa_handle(domain->name)))
                return NT_STATUS_UNSUCCESSFUL;
         
        status = cli_lsa_lookup_sids(hnd->cli, mem_ctx, &hnd->pol,
-                                    1, sid, &domains, &names, &types, 
-                                    &num_names);
+                                    1, sid, &domains, &names, &types);
 
        if (NT_STATUS_IS_OK(status)) {
                *type = types[0];
@@ -270,6 +279,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
        BOOL got_dom_pol = False, got_user_pol = False;
        SAM_USERINFO_CTR *ctr;
 
+       DEBUG(3,("rpc: query_user rid=%u\n", user_rid));
+
        /* Get sam handle */
        if (!(hnd = cm_get_sam_handle(domain->name)))
                goto done;
@@ -298,9 +309,13 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
        result = cli_samr_query_userinfo(hnd->cli, mem_ctx, &user_pol, 
                                         0x15, &ctr);
 
+       if (!NT_STATUS_IS_OK(result))
+               goto done;
+
        cli_samr_close(hnd->cli, mem_ctx, &user_pol);
        got_user_pol = False;
 
+       user_info->user_rid = user_rid;
        user_info->group_rid = ctr->info.id21->group_rid;
        user_info->acct_name = unistr2_tdup(mem_ctx, 
                                            &ctr->info.id21->uni_user_name);
@@ -332,6 +347,8 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
        DOM_GID *user_groups;
        int i;
 
+       DEBUG(3,("rpc: lookup_usergroups rid=%u\n", user_rid));
+
        *num_groups = 0;
 
        /* First try cached universal groups from logon */
@@ -403,6 +420,8 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
         uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
         BOOL got_dom_pol = False, got_group_pol = False;
 
+       DEBUG(10,("rpc: lookup_groupmem %s rid=%u\n", domain->name, group_rid));
+
        *num_names = 0;
 
         /* Get sam handle */
@@ -505,6 +524,8 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
        BOOL got_dom_pol = False;
        uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
 
+       DEBUG(10,("rpc: fetch sequence_number for %s\n", domain->name));
+
        *seq = DOM_SEQUENCE_NONE;
 
        if (!(mem_ctx = talloc_init_named("sequence_number[rpc]")))
@@ -555,20 +576,24 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
                                uint32 *num_domains,
                                char ***names,
+                               char ***alt_names,
                                DOM_SID **dom_sids)
 {
        CLI_POLICY_HND *hnd;
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
        uint32 enum_ctx = 0;
 
+       DEBUG(3,("rpc: trusted_domains\n"));
+
        *num_domains = 0;
+       *alt_names = NULL;
 
        if (!(hnd = cm_get_lsa_handle(lp_workgroup())))
                goto done;
 
        result = cli_lsa_enum_trust_dom(hnd->cli, mem_ctx,
-                                       &hnd->pol, &enum_ctx, num_domains, 
-                                       names, dom_sids);
+                                       &hnd->pol, &enum_ctx,
+                                       num_domains, names, dom_sids);
 done:
        return result;
 }
@@ -581,6 +606,8 @@ static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
        CLI_POLICY_HND *hnd;
        fstring level5_dom;
 
+       DEBUG(3,("rpc: domain_sid\n"));
+
        if (!(mem_ctx = talloc_init_named("domain_sid[rpc]")))
                return NT_STATUS_NO_MEMORY;
 
@@ -596,6 +623,13 @@ done:
        return status;
 }
 
+/* find alternate names list for the domain - none for rpc */
+static NTSTATUS alternate_name(struct winbindd_domain *domain)
+{
+       return NT_STATUS_OK;
+}
+
+
 /* the rpc backend methods are exposed via this structure */
 struct winbindd_methods msrpc_methods = {
        False,
@@ -608,5 +642,6 @@ struct winbindd_methods msrpc_methods = {
        lookup_groupmem,
        sequence_number,
        trusted_domains,
-       domain_sid
+       domain_sid,
+       alternate_name
 };