s3-winbindd: copy acct_info to wb_acct_info so we dont need passdb for it.
[samba.git] / source3 / winbindd / winbindd_reconnect.c
index 1d71a754586e4e3c9a48a567f9ee03715a53fc1f..62bf57ea4add35b04eb2e51f9eb9ea9b77662698 100644 (file)
 
 extern struct winbindd_methods msrpc_methods;
 
+static bool reconnect_need_retry(NTSTATUS status)
+{
+       if (NT_STATUS_IS_OK(status)) {
+               return false;
+       }
+
+       if (!NT_STATUS_IS_ERR(status)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_GROUP)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_ALIAS)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_MEMBER)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_DOMAIN)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_PRIVILEGE)) {
+               return false;
+       }
+
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
+               return false;
+       }
+
+       return true;
+}
+
 /* List all users */
 static NTSTATUS query_user_list(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
                                uint32 *num_entries, 
-                               WINBIND_USERINFO **info)
+                               struct wbint_userinfo **info)
 {
        NTSTATUS result;
 
        result = msrpc_methods.query_user_list(domain, mem_ctx,
                                               num_entries, info);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.query_user_list(domain, mem_ctx,
                                                       num_entries, info);
        return result;
@@ -48,14 +93,14 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
                                uint32 *num_entries, 
-                               struct acct_info **info)
+                               struct wb_acct_info **info)
 {
        NTSTATUS result;
 
        result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
                                               num_entries, info);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
                                                       num_entries, info);
        return result;
@@ -66,14 +111,14 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
                                  TALLOC_CTX *mem_ctx,
                                  uint32 *num_entries, 
-                                 struct acct_info **info)
+                                 struct wb_acct_info **info)
 {
        NTSTATUS result;
 
        result = msrpc_methods.enum_local_groups(domain, mem_ctx,
                                                 num_entries, info);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.enum_local_groups(domain, mem_ctx,
                                                         num_entries, info);
 
@@ -86,7 +131,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
                            const char *domain_name,
                            const char *name,
                            uint32_t flags,
-                           DOM_SID *sid,
+                           struct dom_sid *sid,
                            enum lsa_SidType *type)
 {
        NTSTATUS result;
@@ -94,7 +139,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
        result = msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
                                           flags, sid, type);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.name_to_sid(domain, mem_ctx,
                                                   domain_name, name, flags,
                                                   sid, type);
@@ -107,7 +152,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
 */
 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
                            TALLOC_CTX *mem_ctx,
-                           const DOM_SID *sid,
+                           const struct dom_sid *sid,
                            char **domain_name,
                            char **name,
                            enum lsa_SidType *type)
@@ -117,7 +162,7 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
        result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
                                           domain_name, name, type);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
                                                   domain_name, name, type);
 
@@ -126,7 +171,7 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
 
 static NTSTATUS rids_to_names(struct winbindd_domain *domain,
                              TALLOC_CTX *mem_ctx,
-                             const DOM_SID *sid,
+                             const struct dom_sid *sid,
                              uint32 *rids,
                              size_t num_rids,
                              char **domain_name,
@@ -138,7 +183,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
        result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
                                             rids, num_rids,
                                             domain_name, names, types);
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL)) {
+       if (reconnect_need_retry(result)) {
                result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
                                                     rids, num_rids,
                                                     domain_name, names,
@@ -151,15 +196,15 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
 /* Lookup user information from a rid or username. */
 static NTSTATUS query_user(struct winbindd_domain *domain, 
                           TALLOC_CTX *mem_ctx, 
-                          const DOM_SID *user_sid,
-                          WINBIND_USERINFO *user_info)
+                          const struct dom_sid *user_sid,
+                          struct wbint_userinfo *user_info)
 {
        NTSTATUS result;
 
        result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
                                          user_info);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
                                                  user_info);
 
@@ -169,8 +214,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
 /* Lookup groups a user is a member of.  I wish Unix had a call like this! */
 static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
                                  TALLOC_CTX *mem_ctx,
-                                 const DOM_SID *user_sid,
-                                 uint32 *num_groups, DOM_SID **user_gids)
+                                 const struct dom_sid *user_sid,
+                                 uint32 *num_groups, struct dom_sid **user_gids)
 {
        NTSTATUS result;
 
@@ -178,7 +223,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
                                                 user_sid, num_groups,
                                                 user_gids);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.lookup_usergroups(domain, mem_ctx,
                                                         user_sid, num_groups,
                                                         user_gids);
@@ -188,7 +233,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
 
 static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
                                   TALLOC_CTX *mem_ctx,
-                                  uint32 num_sids, const DOM_SID *sids,
+                                  uint32 num_sids, const struct dom_sid *sids,
                                   uint32 *num_aliases, uint32 **alias_rids)
 {
        NTSTATUS result;
@@ -198,7 +243,7 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
                                                  num_aliases,
                                                  alias_rids);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
                                                          num_sids, sids,
                                                          num_aliases,
@@ -210,20 +255,23 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
 /* Lookup group membership given a rid.   */
 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
-                               const DOM_SID *group_sid, uint32 *num_names, 
-                               DOM_SID **sid_mem, char ***names, 
+                               const struct dom_sid *group_sid,
+                               enum lsa_SidType type,
+                               uint32 *num_names,
+                               struct dom_sid **sid_mem, char ***names,
                                uint32 **name_types)
 {
        NTSTATUS result;
 
        result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
-                                              group_sid, num_names,
+                                              group_sid, type, num_names,
                                               sid_mem, names,
                                               name_types);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
-                                                      group_sid, num_names,
+                                                      group_sid, type,
+                                                      num_names,
                                                       sid_mem, names,
                                                       name_types);
 
@@ -237,7 +285,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
 
        result = msrpc_methods.sequence_number(domain, seq);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.sequence_number(domain, seq);
 
        return result;
@@ -252,7 +300,7 @@ static NTSTATUS lockout_policy(struct winbindd_domain *domain,
 
        result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
 
        return result;
@@ -267,7 +315,7 @@ static NTSTATUS password_policy(struct winbindd_domain *domain,
  
        result = msrpc_methods.password_policy(domain, mem_ctx, policy);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.password_policy(domain, mem_ctx, policy);
        
        return result;
@@ -276,21 +324,15 @@ static NTSTATUS password_policy(struct winbindd_domain *domain,
 /* get a list of trusted domains */
 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
-                               uint32 *num_domains,
-                               char ***names,
-                               char ***alt_names,
-                               DOM_SID **dom_sids)
+                               struct netr_DomainTrustList *trusts)
 {
        NTSTATUS result;
 
-       result = msrpc_methods.trusted_domains(domain, mem_ctx,
-                                              num_domains, names,
-                                              alt_names, dom_sids);
+       result = msrpc_methods.trusted_domains(domain, mem_ctx, trusts);
 
-       if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
+       if (reconnect_need_retry(result))
                result = msrpc_methods.trusted_domains(domain, mem_ctx,
-                                                      num_domains, names,
-                                                      alt_names, dom_sids);
+                                                      trusts);
 
        return result;
 }