summaryrefslogtreecommitdiff
path: root/source3/nsswitch/idmap_ad.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-04-18 21:10:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:27 -0500
commit01be4914b37f7e5887f3ecd4ecc53fbd846fc22e (patch)
tree3a5c3f59ddb48c4c2a369c9999b98801615c6c0d /source3/nsswitch/idmap_ad.c
parent256f506c5b060c37ee22ee9ff0c371154721252a (diff)
downloadsamba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.tar.gz
samba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.tar.bz2
samba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.zip
r22343: Commit to 3_0 as well after adapting the patch.
(tdb_delete_bystring instead of tdb_delete is used here) (This used to be commit ee40cead097ed2c005f5f80b24c9f681e054849a)
Diffstat (limited to 'source3/nsswitch/idmap_ad.c')
-rw-r--r--source3/nsswitch/idmap_ad.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/source3/nsswitch/idmap_ad.c b/source3/nsswitch/idmap_ad.c
index 87f73f99f0..9daa0024ea 100644
--- a/source3/nsswitch/idmap_ad.c
+++ b/source3/nsswitch/idmap_ad.c
@@ -160,7 +160,7 @@ static ADS_STRUCT *ad_idmap_cached_connection(void)
/************************************************************************
***********************************************************************/
-static NTSTATUS idmap_ad_initialize(struct idmap_domain *dom, const char *params)
+static NTSTATUS idmap_ad_initialize(struct idmap_domain *dom)
{
struct idmap_ad_context *ctx;
char *config_option;
@@ -204,6 +204,7 @@ static NTSTATUS idmap_ad_initialize(struct idmap_domain *dom, const char *params
}
dom->private_data = ctx;
+ dom->initialized = True;
talloc_free(config_option);
@@ -269,6 +270,19 @@ static NTSTATUS idmap_ad_unixids_to_sids(struct idmap_domain *dom, struct id_map
char *u_filter = NULL;
char *g_filter = NULL;
+ /* Only do query if we are online */
+ if (idmap_is_offline()) {
+ return NT_STATUS_FILE_IS_OFFLINE;
+ }
+
+ /* Initilization my have been deferred because we were offline */
+ if ( ! dom->initialized) {
+ ret = idmap_ad_initialize(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_ad_context);
if ( (memctx = talloc_new(ctx)) == NULL ) {
@@ -320,7 +334,7 @@ again:
break;
default:
- DEBUG(3, ("Unknown ID type\n"));
+ DEBUG(3, ("Error: mapping requested but Unknown ID type\n"));
ids[idx]->status = ID_UNKNOWN;
continue;
}
@@ -441,9 +455,9 @@ again:
ret = NT_STATUS_OK;
- /* mark all unknown ones as unmapped */
+ /* mark all unknown/expired ones as unmapped */
for (i = 0; ids[i]; i++) {
- if (ids[i]->status == ID_UNKNOWN)
+ if (ids[i]->status != ID_MAPPED)
ids[i]->status = ID_UNMAPPED;
}
@@ -476,6 +490,19 @@ static NTSTATUS idmap_ad_sids_to_unixids(struct idmap_domain *dom, struct id_map
int i;
char *sidstr;
+ /* Only do query if we are online */
+ if (idmap_is_offline()) {
+ return NT_STATUS_FILE_IS_OFFLINE;
+ }
+
+ /* Initilization my have been deferred because we were offline */
+ if ( ! dom->initialized) {
+ ret = idmap_ad_initialize(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_ad_context);
if ( (memctx = talloc_new(ctx)) == NULL ) {
@@ -615,9 +642,9 @@ again:
ret = NT_STATUS_OK;
- /* mark all unknwon ones as unmapped */
+ /* mark all unknwoni/expired ones as unmapped */
for (i = 0; ids[i]; i++) {
- if (ids[i]->status == ID_UNKNOWN)
+ if (ids[i]->status != ID_MAPPED)
ids[i]->status = ID_UNMAPPED;
}
@@ -669,7 +696,7 @@ static NTSTATUS nss_sfu_init( struct nss_domain_entry *e )
ad_map_type = WB_POSIX_MAP_SFU;
if ( !ad_idmap_ads )
- return idmap_ad_initialize( NULL, NULL );
+ return idmap_ad_initialize(NULL);
return NT_STATUS_OK;
}
@@ -690,7 +717,7 @@ static NTSTATUS nss_rfc2307_init( struct nss_domain_entry *e )
ad_map_type = WB_POSIX_MAP_RFC2307;
if ( !ad_idmap_ads )
- return idmap_ad_initialize( NULL, NULL );
+ return idmap_ad_initialize(NULL);
return NT_STATUS_OK;
}