nsswitch/winbindd_reconnect.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003 
00004    Wrapper around winbindd_rpc.c to centralize retry logic.
00005 
00006    Copyright (C) Volker Lendecke 2005
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 
00023 #include "includes.h"
00024 #include "winbindd.h"
00025 
00026 #undef DBGC_CLASS
00027 #define DBGC_CLASS DBGC_WINBIND
00028 
00029 extern struct winbindd_methods msrpc_methods;
00030 
00031 /* List all users */
00032 static NTSTATUS query_user_list(struct winbindd_domain *domain,
00033                                 TALLOC_CTX *mem_ctx,
00034                                 uint32 *num_entries, 
00035                                 WINBIND_USERINFO **info)
00036 {
00037         NTSTATUS result;
00038 
00039         result = msrpc_methods.query_user_list(domain, mem_ctx,
00040                                                num_entries, info);
00041 
00042         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00043                 result = msrpc_methods.query_user_list(domain, mem_ctx,
00044                                                        num_entries, info);
00045         return result;
00046 }
00047 
00048 /* list all domain groups */
00049 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
00050                                 TALLOC_CTX *mem_ctx,
00051                                 uint32 *num_entries, 
00052                                 struct acct_info **info)
00053 {
00054         NTSTATUS result;
00055 
00056         result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
00057                                                num_entries, info);
00058 
00059         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00060                 result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
00061                                                        num_entries, info);
00062         return result;
00063 }
00064 
00065 /* List all domain groups */
00066 
00067 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
00068                                   TALLOC_CTX *mem_ctx,
00069                                   uint32 *num_entries, 
00070                                   struct acct_info **info)
00071 {
00072         NTSTATUS result;
00073 
00074         result = msrpc_methods.enum_local_groups(domain, mem_ctx,
00075                                                  num_entries, info);
00076 
00077         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00078                 result = msrpc_methods.enum_local_groups(domain, mem_ctx,
00079                                                          num_entries, info);
00080 
00081         return result;
00082 }
00083 
00084 /* convert a single name to a sid in a domain */
00085 static NTSTATUS name_to_sid(struct winbindd_domain *domain,
00086                             TALLOC_CTX *mem_ctx,
00087                             const char *domain_name,
00088                             const char *name,
00089                             DOM_SID *sid,
00090                             enum lsa_SidType *type)
00091 {
00092         NTSTATUS result;
00093 
00094         result = msrpc_methods.name_to_sid(domain, mem_ctx,
00095                                            domain_name, name,
00096                                            sid, type);
00097 
00098         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00099                 result = msrpc_methods.name_to_sid(domain, mem_ctx,
00100                                                    domain_name, name,
00101                                                    sid, type);
00102 
00103         return result;
00104 }
00105 
00106 /*
00107   convert a domain SID to a user or group name
00108 */
00109 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
00110                             TALLOC_CTX *mem_ctx,
00111                             const DOM_SID *sid,
00112                             char **domain_name,
00113                             char **name,
00114                             enum lsa_SidType *type)
00115 {
00116         NTSTATUS result;
00117 
00118         result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
00119                                            domain_name, name, type);
00120 
00121         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00122                 result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
00123                                                    domain_name, name, type);
00124 
00125         return result;
00126 }
00127 
00128 static NTSTATUS rids_to_names(struct winbindd_domain *domain,
00129                               TALLOC_CTX *mem_ctx,
00130                               const DOM_SID *sid,
00131                               uint32 *rids,
00132                               size_t num_rids,
00133                               char **domain_name,
00134                               char ***names,
00135                               enum lsa_SidType **types)
00136 {
00137         NTSTATUS result;
00138 
00139         result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
00140                                              rids, num_rids,
00141                                              domain_name, names, types);
00142         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL)) {
00143                 result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
00144                                                      rids, num_rids,
00145                                                      domain_name, names,
00146                                                      types);
00147         }
00148 
00149         return result;
00150 }
00151 
00152 /* Lookup user information from a rid or username. */
00153 static NTSTATUS query_user(struct winbindd_domain *domain, 
00154                            TALLOC_CTX *mem_ctx, 
00155                            const DOM_SID *user_sid,
00156                            WINBIND_USERINFO *user_info)
00157 {
00158         NTSTATUS result;
00159 
00160         result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
00161                                           user_info);
00162 
00163         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00164                 result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
00165                                                   user_info);
00166 
00167         return result;
00168 }
00169 
00170 /* Lookup groups a user is a member of.  I wish Unix had a call like this! */
00171 static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
00172                                   TALLOC_CTX *mem_ctx,
00173                                   const DOM_SID *user_sid,
00174                                   uint32 *num_groups, DOM_SID **user_gids)
00175 {
00176         NTSTATUS result;
00177 
00178         result = msrpc_methods.lookup_usergroups(domain, mem_ctx,
00179                                                  user_sid, num_groups,
00180                                                  user_gids);
00181 
00182         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00183                 result = msrpc_methods.lookup_usergroups(domain, mem_ctx,
00184                                                          user_sid, num_groups,
00185                                                          user_gids);
00186 
00187         return result;
00188 }
00189 
00190 static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
00191                                    TALLOC_CTX *mem_ctx,
00192                                    uint32 num_sids, const DOM_SID *sids,
00193                                    uint32 *num_aliases, uint32 **alias_rids)
00194 {
00195         NTSTATUS result;
00196 
00197         result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
00198                                                   num_sids, sids,
00199                                                   num_aliases,
00200                                                   alias_rids);
00201 
00202         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00203                 result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
00204                                                           num_sids, sids,
00205                                                           num_aliases,
00206                                                           alias_rids);
00207 
00208         return result;
00209 }
00210 
00211 /* Lookup group membership given a rid.   */
00212 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
00213                                 TALLOC_CTX *mem_ctx,
00214                                 const DOM_SID *group_sid, uint32 *num_names, 
00215                                 DOM_SID **sid_mem, char ***names, 
00216                                 uint32 **name_types)
00217 {
00218         NTSTATUS result;
00219 
00220         result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
00221                                                group_sid, num_names,
00222                                                sid_mem, names,
00223                                                name_types);
00224 
00225         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00226                 result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
00227                                                        group_sid, num_names,
00228                                                        sid_mem, names,
00229                                                        name_types);
00230 
00231         return result;
00232 }
00233 
00234 /* find the sequence number for a domain */
00235 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
00236 {
00237         NTSTATUS result;
00238 
00239         result = msrpc_methods.sequence_number(domain, seq);
00240 
00241         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00242                 result = msrpc_methods.sequence_number(domain, seq);
00243 
00244         return result;
00245 }
00246 
00247 /* find the lockout policy of a domain */
00248 static NTSTATUS lockout_policy(struct winbindd_domain *domain, 
00249                                TALLOC_CTX *mem_ctx,
00250                                SAM_UNK_INFO_12 *policy)
00251 {
00252         NTSTATUS result;
00253 
00254         result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
00255 
00256         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00257                 result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
00258 
00259         return result;
00260 }
00261 
00262 /* find the password policy of a domain */
00263 static NTSTATUS password_policy(struct winbindd_domain *domain, 
00264                                 TALLOC_CTX *mem_ctx,
00265                                 SAM_UNK_INFO_1 *policy)
00266 {
00267         NTSTATUS result;
00268  
00269         result = msrpc_methods.password_policy(domain, mem_ctx, policy);
00270 
00271         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00272                 result = msrpc_methods.password_policy(domain, mem_ctx, policy);
00273         
00274         return result;
00275 }
00276 
00277 /* get a list of trusted domains */
00278 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
00279                                 TALLOC_CTX *mem_ctx,
00280                                 uint32 *num_domains,
00281                                 char ***names,
00282                                 char ***alt_names,
00283                                 DOM_SID **dom_sids)
00284 {
00285         NTSTATUS result;
00286 
00287         result = msrpc_methods.trusted_domains(domain, mem_ctx,
00288                                                num_domains, names,
00289                                                alt_names, dom_sids);
00290 
00291         if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
00292                 result = msrpc_methods.trusted_domains(domain, mem_ctx,
00293                                                        num_domains, names,
00294                                                        alt_names, dom_sids);
00295 
00296         return result;
00297 }
00298 
00299 /* the rpc backend methods are exposed via this structure */
00300 struct winbindd_methods reconnect_methods = {
00301         False,
00302         query_user_list,
00303         enum_dom_groups,
00304         enum_local_groups,
00305         name_to_sid,
00306         sid_to_name,
00307         rids_to_names,
00308         query_user,
00309         lookup_usergroups,
00310         lookup_useraliases,
00311         lookup_groupmem,
00312         sequence_number,
00313         lockout_policy,
00314         password_policy,
00315         trusted_domains,
00316 };

Sambaに対してSat Aug 29 21:23:11 2009に生成されました。  doxygen 1.4.7