Apply some const
[samba.git] / source / nsswitch / winbindd_cache.c
index bc6967dee1cd13d720ac6b0d34f19105daaece7c..73918d74f7db99ef61f1a40a8ebb122dbaeb10a8 100644 (file)
@@ -22,6 +22,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include "includes.h"
 #include "winbindd.h"
 
 #undef DBGC_CLASS
@@ -106,12 +107,18 @@ static struct winbind_cache *get_cache(struct winbindd_domain *domain)
                case SEC_ADS: {
                        extern struct winbindd_methods ads_methods;
                        /* always obey the lp_security parameter for our domain */
-                       if ( strequal(lp_realm(), domain->alt_name) || strequal(lp_workgroup(), domain->name) ) {
+                       if (domain->primary) {
                                domain->backend = &ads_methods;
                                break;
                        }
 
+                       /* only use ADS for native modes at the momment.
+                          The problem is the correct detection of mixed 
+                          mode domains from NT4 BDC's    --jerry */
+                       
                        if ( domain->native_mode ) {
+                               DEBUG(5,("get_cache: Setting ADS methods for domain %s\n",
+                                       domain->name));
                                domain->backend = &ads_methods;
                                break;
                        }
@@ -120,6 +127,8 @@ static struct winbind_cache *get_cache(struct winbindd_domain *domain)
                }       
 #endif
                default:
+                       DEBUG(5,("get_cache: Setting MS-RPC methods for domain %s\n",
+                               domain->name));
                        domain->backend = &msrpc_methods;
                }
        }
@@ -330,10 +339,12 @@ static void refresh_sequence_number(struct winbindd_domain *domain, BOOL force)
 
        get_cache( domain );
 
+#if 0  /* JERRY -- disable as the default cache time is now 5 minutes */
        /* trying to reconnect is expensive, don't do it too often */
        if (domain->sequence_number == DOM_SEQUENCE_NONE) {
                cache_time *= 8;
        }
+#endif
 
        time_diff = t - domain->last_seq_check;
 
@@ -585,7 +596,7 @@ static void centry_end(struct cache_entry *centry, const char *format, ...)
 
 static void wcache_save_name_to_sid(struct winbindd_domain *domain, 
                                    NTSTATUS status, 
-                                   const char *name, DOM_SID *sid, 
+                                   const char *name, const DOM_SID *sid, 
                                    enum SID_NAME_USE type)
 {
        struct cache_entry *centry;
@@ -604,7 +615,7 @@ static void wcache_save_name_to_sid(struct winbindd_domain *domain,
 }
 
 static void wcache_save_sid_to_name(struct winbindd_domain *domain, NTSTATUS status, 
-                                   DOM_SID *sid, const char *name, enum SID_NAME_USE type)
+                                   const DOM_SID *sid, const char *name, enum SID_NAME_USE type)
 {
        struct cache_entry *centry;
        fstring sid_string;
@@ -972,7 +983,7 @@ do_query:
    given */
 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
                            TALLOC_CTX *mem_ctx,
-                           DOM_SID *sid,
+                           const DOM_SID *sid,
                            char **name,
                            enum SID_NAME_USE *type)
 {
@@ -1030,7 +1041,7 @@ do_query:
 /* Lookup user information from a rid */
 static NTSTATUS query_user(struct winbindd_domain *domain, 
                           TALLOC_CTX *mem_ctx, 
-                          DOM_SID *user_sid, 
+                          const DOM_SID *user_sid, 
                           WINBIND_USERINFO *info)
 {
        struct winbind_cache *cache = get_cache(domain);
@@ -1093,7 +1104,7 @@ do_query:
 /* Lookup groups a user is a member of. */
 static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
                                  TALLOC_CTX *mem_ctx,
-                                 DOM_SID *user_sid, 
+                                 const DOM_SID *user_sid, 
                                  uint32 *num_groups, DOM_SID ***user_gids)
 {
        struct winbind_cache *cache = get_cache(domain);
@@ -1176,7 +1187,7 @@ skip_save:
 
 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
-                               DOM_SID *group_sid, uint32 *num_names, 
+                               const DOM_SID *group_sid, uint32 *num_names, 
                                DOM_SID ***sid_mem, char ***names, 
                                uint32 **name_types)
 {