2 Unix SMB/CIFS implementation.
4 Winbind cache backend functions
6 Copyright (C) Andrew Tridgell 2001
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define DBGC_CLASS DBGC_WINBIND
28 struct winbind_cache {
29 struct winbindd_methods *backend;
35 uint32 sequence_number;
40 #define WINBINDD_MAX_CACHE_SIZE (50*1024*1024)
42 static struct winbind_cache *wcache;
45 void wcache_flush_cache(void)
47 extern BOOL opt_nocache;
51 tdb_close(wcache->tdb);
54 if (opt_nocache) return;
56 wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000,
57 TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
60 DEBUG(0,("Failed to open winbindd_cache.tdb!\n"));
64 void winbindd_check_cache_size(time_t t)
66 static time_t last_check_time;
69 if (last_check_time == (time_t)0)
72 if (t - last_check_time < 60 && t - last_check_time > 0)
75 if (wcache == NULL || wcache->tdb == NULL) {
76 DEBUG(0, ("Unable to check size of tdb cache - cache not open !\n"));
80 if (fstat(wcache->tdb->fd, &st) == -1) {
81 DEBUG(0, ("Unable to check size of tdb cache %s!\n", strerror(errno) ));
85 if (st.st_size > WINBINDD_MAX_CACHE_SIZE) {
86 DEBUG(10,("flushing cache due to size (%lu) > (%lu)\n",
87 (unsigned long)st.st_size,
88 (unsigned long)WINBINDD_MAX_CACHE_SIZE));
93 /* get the winbind_cache structure */
94 static struct winbind_cache *get_cache(struct winbindd_domain *domain)
96 extern struct winbindd_methods msrpc_methods;
97 struct winbind_cache *ret = wcache;
101 ret = smb_xmalloc(sizeof(*ret));
104 if (!strcmp(domain->name, lp_workgroup()) && (lp_security() == SEC_USER)) {
105 extern struct winbindd_methods passdb_methods;
106 ret->backend = &passdb_methods;
108 } else switch (lp_security()) {
111 extern struct winbindd_methods ads_methods;
112 ret->backend = &ads_methods;
117 ret->backend = &msrpc_methods;
121 wcache_flush_cache();
127 free a centry structure
129 static void centry_free(struct cache_entry *centry)
132 SAFE_FREE(centry->data);
138 pull a uint32 from a cache entry
140 static uint32 centry_uint32(struct cache_entry *centry)
143 if (centry->len - centry->ofs < 4) {
144 DEBUG(0,("centry corruption? needed 4 bytes, have %d\n",
145 centry->len - centry->ofs));
146 smb_panic("centry_uint32");
148 ret = IVAL(centry->data, centry->ofs);
154 pull a uint8 from a cache entry
156 static uint8 centry_uint8(struct cache_entry *centry)
159 if (centry->len - centry->ofs < 1) {
160 DEBUG(0,("centry corruption? needed 1 bytes, have %d\n",
161 centry->len - centry->ofs));
162 smb_panic("centry_uint32");
164 ret = CVAL(centry->data, centry->ofs);
169 /* pull a string from a cache entry, using the supplied
172 static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
177 len = centry_uint8(centry);
180 /* a deliberate NULL string */
184 if (centry->len - centry->ofs < len) {
185 DEBUG(0,("centry corruption? needed %d bytes, have %d\n",
186 len, centry->len - centry->ofs));
187 smb_panic("centry_string");
190 ret = talloc(mem_ctx, len+1);
192 smb_panic("centry_string out of memory\n");
194 memcpy(ret,centry->data + centry->ofs, len);
200 /* pull a string from a cache entry, using the supplied
203 static DOM_SID *centry_sid(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
207 sid = talloc(mem_ctx, sizeof(*sid));
208 if (!sid) return NULL;
210 sid_string = centry_string(centry, mem_ctx);
211 if (!string_to_sid(sid, sid_string)) {
217 /* the server is considered down if it can't give us a sequence number */
218 static BOOL wcache_server_down(struct winbindd_domain *domain)
220 if (!wcache->tdb) return False;
221 return (domain->sequence_number == DOM_SEQUENCE_NONE);
224 static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now )
231 return NT_STATUS_UNSUCCESSFUL;
233 snprintf( key, sizeof(key), "SEQNUM/%s", domain->name );
235 data = tdb_fetch_by_string( wcache->tdb, key );
236 if ( !data.dptr || data.dsize!=8 )
237 return NT_STATUS_UNSUCCESSFUL;
239 domain->sequence_number = IVAL(data.dptr, 0);
240 domain->last_seq_check = IVAL(data.dptr, 4);
242 /* have we expired? */
244 time_diff = now - domain->last_seq_check;
245 if ( time_diff > lp_winbind_cache_time() )
246 return NT_STATUS_UNSUCCESSFUL;
248 DEBUG(10,("fetch_cache_seqnum: success [%s][%u @ %u]\n",
249 domain->name, domain->sequence_number,
250 (uint32)domain->last_seq_check));
255 static NTSTATUS store_cache_seqnum( struct winbindd_domain *domain )
262 return NT_STATUS_UNSUCCESSFUL;
264 snprintf( key_str, sizeof(key_str), "SEQNUM/%s", domain->name );
266 key.dsize = strlen(key_str)+1;
268 SIVAL(buf, 0, domain->sequence_number);
269 SIVAL(buf, 4, domain->last_seq_check);
273 if ( tdb_store( wcache->tdb, key, data, TDB_REPLACE) == -1 )
274 return NT_STATUS_UNSUCCESSFUL;
276 DEBUG(10,("store_cache_seqnum: success [%s][%u @ %u]\n",
277 domain->name, domain->sequence_number,
278 (uint32)domain->last_seq_check));
286 refresh the domain sequence number. If force is True
287 then always refresh it, no matter how recently we fetched it
290 static void refresh_sequence_number(struct winbindd_domain *domain, BOOL force)
294 time_t t = time(NULL);
295 unsigned cache_time = lp_winbind_cache_time();
297 /* trying to reconnect is expensive, don't do it too often */
298 if (domain->sequence_number == DOM_SEQUENCE_NONE) {
302 time_diff = t - domain->last_seq_check;
304 /* see if we have to refetch the domain sequence number */
305 if (!force && (time_diff < cache_time)) {
309 /* try to get the sequence number from the tdb cache first */
310 /* this will update the timestamp as well */
312 status = fetch_cache_seqnum( domain, t );
313 if ( NT_STATUS_IS_OK(status) )
316 status = wcache->backend->sequence_number(domain, &domain->sequence_number);
318 if (!NT_STATUS_IS_OK(status)) {
319 domain->sequence_number = DOM_SEQUENCE_NONE;
322 domain->last_seq_check = time(NULL);
324 /* save the new sequence number ni the cache */
325 store_cache_seqnum( domain );
328 DEBUG(10, ("refresh_sequence_number: seq number is now %d\n",
329 domain->sequence_number));
335 decide if a cache entry has expired
337 static BOOL centry_expired(struct winbindd_domain *domain, struct cache_entry *centry)
339 /* if the server is OK and our cache entry came from when it was down then
340 the entry is invalid */
341 if (domain->sequence_number != DOM_SEQUENCE_NONE &&
342 centry->sequence_number == DOM_SEQUENCE_NONE) {
346 /* if the server is down or the cache entry is not older than the
347 current sequence number then it is OK */
348 if (wcache_server_down(domain) ||
349 centry->sequence_number == domain->sequence_number) {
358 fetch an entry from the cache, with a varargs key. auto-fetch the sequence
359 number and return status
361 static struct cache_entry *wcache_fetch(struct winbind_cache *cache,
362 struct winbindd_domain *domain,
363 const char *format, ...) PRINTF_ATTRIBUTE(3,4);
364 static struct cache_entry *wcache_fetch(struct winbind_cache *cache,
365 struct winbindd_domain *domain,
366 const char *format, ...)
371 struct cache_entry *centry;
374 refresh_sequence_number(domain, False);
376 va_start(ap, format);
377 smb_xvasprintf(&kstr, format, ap);
381 key.dsize = strlen(kstr);
382 data = tdb_fetch(wcache->tdb, key);
389 centry = smb_xmalloc(sizeof(*centry));
390 centry->data = data.dptr;
391 centry->len = data.dsize;
394 if (centry->len < 8) {
395 /* huh? corrupt cache? */
400 centry->status = NT_STATUS(centry_uint32(centry));
401 centry->sequence_number = centry_uint32(centry);
403 if (centry_expired(domain, centry)) {
404 extern BOOL opt_dual_daemon;
406 if (opt_dual_daemon) {
407 extern BOOL background_process;
408 background_process = True;
419 make sure we have at least len bytes available in a centry
421 static void centry_expand(struct cache_entry *centry, uint32 len)
424 if (centry->len - centry->ofs >= len) return;
426 p = realloc(centry->data, centry->len);
428 DEBUG(0,("out of memory: needed %d bytes in centry_expand\n", centry->len));
429 smb_panic("out of memory in centry_expand");
435 push a uint32 into a centry
437 static void centry_put_uint32(struct cache_entry *centry, uint32 v)
439 centry_expand(centry, 4);
440 SIVAL(centry->data, centry->ofs, v);
445 push a uint8 into a centry
447 static void centry_put_uint8(struct cache_entry *centry, uint8 v)
449 centry_expand(centry, 1);
450 SCVAL(centry->data, centry->ofs, v);
455 push a string into a centry
457 static void centry_put_string(struct cache_entry *centry, const char *s)
462 /* null strings are marked as len 0xFFFF */
463 centry_put_uint8(centry, 0xFF);
468 /* can't handle more than 254 char strings. Truncating is probably best */
469 if (len > 254) len = 254;
470 centry_put_uint8(centry, len);
471 centry_expand(centry, len);
472 memcpy(centry->data + centry->ofs, s, len);
476 static void centry_put_sid(struct cache_entry *centry, const DOM_SID *sid)
479 centry_put_string(centry, sid_to_string(sid_string, sid));
483 start a centry for output. When finished, call centry_end()
485 struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status)
487 struct cache_entry *centry;
489 if (!wcache->tdb) return NULL;
491 centry = smb_xmalloc(sizeof(*centry));
493 centry->len = 8192; /* reasonable default */
494 centry->data = smb_xmalloc(centry->len);
496 centry->sequence_number = domain->sequence_number;
497 centry_put_uint32(centry, NT_STATUS_V(status));
498 centry_put_uint32(centry, centry->sequence_number);
503 finish a centry and write it to the tdb
505 static void centry_end(struct cache_entry *centry, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
506 static void centry_end(struct cache_entry *centry, const char *format, ...)
512 va_start(ap, format);
513 smb_xvasprintf(&kstr, format, ap);
517 key.dsize = strlen(kstr);
518 data.dptr = centry->data;
519 data.dsize = centry->ofs;
521 tdb_store(wcache->tdb, key, data, TDB_REPLACE);
525 static void wcache_save_name_to_sid(struct winbindd_domain *domain,
527 const char *name, DOM_SID *sid,
528 enum SID_NAME_USE type)
530 struct cache_entry *centry;
534 centry = centry_start(domain, status);
536 centry_put_sid(centry, sid);
537 fstrcpy(uname, name);
539 centry_end(centry, "NS/%s", sid_to_string(sid_string, sid));
543 static void wcache_save_sid_to_name(struct winbindd_domain *domain, NTSTATUS status,
544 DOM_SID *sid, const char *name, enum SID_NAME_USE type)
546 struct cache_entry *centry;
549 centry = centry_start(domain, status);
551 if (NT_STATUS_IS_OK(status)) {
552 centry_put_uint32(centry, type);
553 centry_put_string(centry, name);
555 centry_end(centry, "SN/%s", sid_to_string(sid_string, sid));
560 static void wcache_save_user(struct winbindd_domain *domain, NTSTATUS status, WINBIND_USERINFO *info)
562 struct cache_entry *centry;
565 centry = centry_start(domain, status);
567 centry_put_string(centry, info->acct_name);
568 centry_put_string(centry, info->full_name);
569 centry_put_sid(centry, info->user_sid);
570 centry_put_sid(centry, info->group_sid);
571 centry_end(centry, "U/%s", sid_to_string(sid_string, info->user_sid));
576 /* Query display info. This is the basic user list fn */
577 static NTSTATUS query_user_list(struct winbindd_domain *domain,
580 WINBIND_USERINFO **info)
582 struct winbind_cache *cache = get_cache(domain);
583 struct cache_entry *centry = NULL;
587 if (!cache->tdb) goto do_query;
589 centry = wcache_fetch(cache, domain, "UL/%s", domain->name);
590 if (!centry) goto do_query;
592 *num_entries = centry_uint32(centry);
594 if (*num_entries == 0) goto do_cached;
596 (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries));
597 if (! (*info)) smb_panic("query_user_list out of memory");
598 for (i=0; i<(*num_entries); i++) {
599 (*info)[i].acct_name = centry_string(centry, mem_ctx);
600 (*info)[i].full_name = centry_string(centry, mem_ctx);
601 (*info)[i].user_sid = centry_sid(centry, mem_ctx);
602 (*info)[i].group_sid = centry_sid(centry, mem_ctx);
606 status = centry->status;
614 if (wcache_server_down(domain)) {
615 return NT_STATUS_SERVER_DISABLED;
618 status = cache->backend->query_user_list(domain, mem_ctx, num_entries, info);
621 refresh_sequence_number(domain, False);
622 centry = centry_start(domain, status);
623 if (!centry) goto skip_save;
624 centry_put_uint32(centry, *num_entries);
625 for (i=0; i<(*num_entries); i++) {
626 centry_put_string(centry, (*info)[i].acct_name);
627 centry_put_string(centry, (*info)[i].full_name);
628 centry_put_sid(centry, (*info)[i].user_sid);
629 centry_put_sid(centry, (*info)[i].group_sid);
630 if (cache->backend->consistent) {
631 /* when the backend is consistent we can pre-prime some mappings */
632 wcache_save_name_to_sid(domain, NT_STATUS_OK,
633 (*info)[i].acct_name,
636 wcache_save_sid_to_name(domain, NT_STATUS_OK,
638 (*info)[i].acct_name,
640 wcache_save_user(domain, NT_STATUS_OK, &(*info)[i]);
643 centry_end(centry, "UL/%s", domain->name);
650 /* list all domain groups */
651 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
654 struct acct_info **info)
656 struct winbind_cache *cache = get_cache(domain);
657 struct cache_entry *centry = NULL;
661 if (!cache->tdb) goto do_query;
663 centry = wcache_fetch(cache, domain, "GL/%s/domain", domain->name);
664 if (!centry) goto do_query;
666 *num_entries = centry_uint32(centry);
668 if (*num_entries == 0) goto do_cached;
670 (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries));
671 if (! (*info)) smb_panic("enum_dom_groups out of memory");
672 for (i=0; i<(*num_entries); i++) {
673 fstrcpy((*info)[i].acct_name, centry_string(centry, mem_ctx));
674 fstrcpy((*info)[i].acct_desc, centry_string(centry, mem_ctx));
675 (*info)[i].rid = centry_uint32(centry);
679 status = centry->status;
687 if (wcache_server_down(domain)) {
688 return NT_STATUS_SERVER_DISABLED;
691 status = cache->backend->enum_dom_groups(domain, mem_ctx, num_entries, info);
694 refresh_sequence_number(domain, False);
695 centry = centry_start(domain, status);
696 if (!centry) goto skip_save;
697 centry_put_uint32(centry, *num_entries);
698 for (i=0; i<(*num_entries); i++) {
699 centry_put_string(centry, (*info)[i].acct_name);
700 centry_put_string(centry, (*info)[i].acct_desc);
701 centry_put_uint32(centry, (*info)[i].rid);
703 centry_end(centry, "GL/%s/domain", domain->name);
710 /* list all domain groups */
711 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
714 struct acct_info **info)
716 struct winbind_cache *cache = get_cache(domain);
717 struct cache_entry *centry = NULL;
721 if (!cache->tdb) goto do_query;
723 centry = wcache_fetch(cache, domain, "GL/%s/local", domain->name);
724 if (!centry) goto do_query;
726 *num_entries = centry_uint32(centry);
728 if (*num_entries == 0) goto do_cached;
730 (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries));
731 if (! (*info)) smb_panic("enum_dom_groups out of memory");
732 for (i=0; i<(*num_entries); i++) {
733 fstrcpy((*info)[i].acct_name, centry_string(centry, mem_ctx));
734 fstrcpy((*info)[i].acct_desc, centry_string(centry, mem_ctx));
735 (*info)[i].rid = centry_uint32(centry);
740 /* If we are returning cached data and the domain controller
741 is down then we don't know whether the data is up to date
742 or not. Return NT_STATUS_MORE_PROCESSING_REQUIRED to
745 if (wcache_server_down(domain)) {
746 DEBUG(10, ("query_user_list: returning cached user list and server was down\n"));
747 status = NT_STATUS_MORE_PROCESSING_REQUIRED;
749 status = centry->status;
758 if (wcache_server_down(domain)) {
759 return NT_STATUS_SERVER_DISABLED;
762 status = cache->backend->enum_local_groups(domain, mem_ctx, num_entries, info);
765 refresh_sequence_number(domain, False);
766 centry = centry_start(domain, status);
767 if (!centry) goto skip_save;
768 centry_put_uint32(centry, *num_entries);
769 for (i=0; i<(*num_entries); i++) {
770 centry_put_string(centry, (*info)[i].acct_name);
771 centry_put_string(centry, (*info)[i].acct_desc);
772 centry_put_uint32(centry, (*info)[i].rid);
774 centry_end(centry, "GL/%s/local", domain->name);
781 /* convert a single name to a sid in a domain */
782 static NTSTATUS name_to_sid(struct winbindd_domain *domain,
786 enum SID_NAME_USE *type)
788 struct winbind_cache *cache = get_cache(domain);
789 struct cache_entry *centry = NULL;
794 if (!cache->tdb) goto do_query;
796 fstrcpy(uname, name);
798 centry = wcache_fetch(cache, domain, "NS/%s/%s", domain->name, uname);
799 if (!centry) goto do_query;
800 *type = centry_uint32(centry);
801 sid2 = centry_sid(centry, mem_ctx);
808 status = centry->status;
815 if (wcache_server_down(domain)) {
816 return NT_STATUS_SERVER_DISABLED;
818 status = cache->backend->name_to_sid(domain, mem_ctx, name, sid, type);
821 wcache_save_name_to_sid(domain, status, name, sid, *type);
823 /* We can't save the sid to name mapping as we don't know the
824 correct case of the name without looking it up */
829 /* convert a sid to a user or group name. The sid is guaranteed to be in the domain
831 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
835 enum SID_NAME_USE *type)
837 struct winbind_cache *cache = get_cache(domain);
838 struct cache_entry *centry = NULL;
842 if (!cache->tdb) goto do_query;
844 centry = wcache_fetch(cache, domain, "SN/%s", sid_to_string(sid_string, sid));
845 if (!centry) goto do_query;
846 if (NT_STATUS_IS_OK(centry->status)) {
847 *type = centry_uint32(centry);
848 *name = centry_string(centry, mem_ctx);
850 status = centry->status;
857 if (wcache_server_down(domain)) {
858 return NT_STATUS_SERVER_DISABLED;
860 status = cache->backend->sid_to_name(domain, mem_ctx, sid, name, type);
863 refresh_sequence_number(domain, False);
864 wcache_save_sid_to_name(domain, status, sid, *name, *type);
865 wcache_save_name_to_sid(domain, status, *name, sid, *type);
871 /* Lookup user information from a rid */
872 static NTSTATUS query_user(struct winbindd_domain *domain,
875 WINBIND_USERINFO *info)
877 struct winbind_cache *cache = get_cache(domain);
878 struct cache_entry *centry = NULL;
882 if (!cache->tdb) goto do_query;
884 centry = wcache_fetch(cache, domain, "U/%s", sid_to_string(sid_string, user_sid));
885 if (!centry) goto do_query;
887 info->acct_name = centry_string(centry, mem_ctx);
888 info->full_name = centry_string(centry, mem_ctx);
889 info->user_sid = centry_sid(centry, mem_ctx);
890 info->group_sid = centry_sid(centry, mem_ctx);
891 status = centry->status;
898 if (wcache_server_down(domain)) {
899 return NT_STATUS_SERVER_DISABLED;
902 status = cache->backend->query_user(domain, mem_ctx, user_sid, info);
905 refresh_sequence_number(domain, False);
906 wcache_save_user(domain, status, info);
912 /* Lookup groups a user is a member of. */
913 static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
916 uint32 *num_groups, DOM_SID ***user_gids)
918 struct winbind_cache *cache = get_cache(domain);
919 struct cache_entry *centry = NULL;
924 if (!cache->tdb) goto do_query;
926 centry = wcache_fetch(cache, domain, "UG/%s", sid_to_string(sid_string, user_sid));
927 if (!centry) goto do_query;
929 *num_groups = centry_uint32(centry);
931 if (*num_groups == 0) goto do_cached;
933 (*user_gids) = talloc(mem_ctx, sizeof(**user_gids) * (*num_groups));
934 if (! (*user_gids)) smb_panic("lookup_usergroups out of memory");
935 for (i=0; i<(*num_groups); i++) {
936 (*user_gids)[i] = centry_sid(centry, mem_ctx);
940 status = centry->status;
948 if (wcache_server_down(domain)) {
949 return NT_STATUS_SERVER_DISABLED;
951 status = cache->backend->lookup_usergroups(domain, mem_ctx, user_sid, num_groups, user_gids);
954 refresh_sequence_number(domain, False);
955 centry = centry_start(domain, status);
956 if (!centry) goto skip_save;
957 centry_put_uint32(centry, *num_groups);
958 for (i=0; i<(*num_groups); i++) {
959 centry_put_sid(centry, (*user_gids)[i]);
961 centry_end(centry, "UG/%s", sid_to_string(sid_string, user_sid));
969 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
971 DOM_SID *group_sid, uint32 *num_names,
972 DOM_SID ***sid_mem, char ***names,
975 struct winbind_cache *cache = get_cache(domain);
976 struct cache_entry *centry = NULL;
981 if (!cache->tdb) goto do_query;
983 centry = wcache_fetch(cache, domain, "GM/%s", sid_to_string(sid_string, group_sid));
984 if (!centry) goto do_query;
986 *num_names = centry_uint32(centry);
988 if (*num_names == 0) goto do_cached;
990 (*sid_mem) = talloc(mem_ctx, sizeof(**sid_mem) * (*num_names));
991 (*names) = talloc(mem_ctx, sizeof(**names) * (*num_names));
992 (*name_types) = talloc(mem_ctx, sizeof(**name_types) * (*num_names));
994 if (! (*sid_mem) || ! (*names) || ! (*name_types)) {
995 smb_panic("lookup_groupmem out of memory");
998 for (i=0; i<(*num_names); i++) {
999 (*sid_mem)[i] = centry_sid(centry, mem_ctx);
1000 (*names)[i] = centry_string(centry, mem_ctx);
1001 (*name_types)[i] = centry_uint32(centry);
1005 status = centry->status;
1006 centry_free(centry);
1013 (*name_types) = NULL;
1016 if (wcache_server_down(domain)) {
1017 return NT_STATUS_SERVER_DISABLED;
1019 status = cache->backend->lookup_groupmem(domain, mem_ctx, group_sid, num_names,
1020 sid_mem, names, name_types);
1023 refresh_sequence_number(domain, False);
1024 centry = centry_start(domain, status);
1025 if (!centry) goto skip_save;
1026 centry_put_uint32(centry, *num_names);
1027 for (i=0; i<(*num_names); i++) {
1028 centry_put_sid(centry, (*sid_mem)[i]);
1029 centry_put_string(centry, (*names)[i]);
1030 centry_put_uint32(centry, (*name_types)[i]);
1032 centry_end(centry, "GM/%s", sid_to_string(sid_string, group_sid));
1033 centry_free(centry);
1039 /* find the sequence number for a domain */
1040 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
1042 refresh_sequence_number(domain, False);
1044 *seq = domain->sequence_number;
1046 return NT_STATUS_OK;
1049 /* enumerate trusted domains */
1050 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
1051 TALLOC_CTX *mem_ctx,
1052 uint32 *num_domains,
1057 struct winbind_cache *cache = get_cache(domain);
1059 /* we don't cache this call */
1060 return cache->backend->trusted_domains(domain, mem_ctx, num_domains,
1061 names, alt_names, dom_sids);
1064 /* find the domain sid */
1065 static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
1067 struct winbind_cache *cache = get_cache(domain);
1069 /* we don't cache this call */
1070 return cache->backend->domain_sid(domain, sid);
1073 /* find the alternate names for the domain, if any */
1074 static NTSTATUS alternate_name(struct winbindd_domain *domain)
1076 struct winbind_cache *cache = get_cache(domain);
1078 /* we don't cache this call */
1079 return cache->backend->alternate_name(domain);
1082 /* the ADS backend methods are exposed via this structure */
1083 struct winbindd_methods cache_methods = {