summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/ldap_id_netgroup.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-06-04 15:15:24 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-07 00:14:13 +0200
commitca344fdecdf127c80ad1074047aeba21e1165313 (patch)
tree635f018041a1efca22dd16c5b5cf7c86c5002b70 /src/providers/ldap/ldap_id_netgroup.c
parent749cfb5d3270b5daf389d51a0dbd3fd2aec6e05d (diff)
downloadsssd-ca344fdecdf127c80ad1074047aeba21e1165313.tar.gz
sssd-ca344fdecdf127c80ad1074047aeba21e1165313.tar.xz
sssd-ca344fdecdf127c80ad1074047aeba21e1165313.zip
LDAP: return sdap search return code to ID
By default, the LDAP searches delete the entry from cache if it wasn't found during a search. But if a search wants to try both Global Catalog and LDAP, for example, it might be beneficial to have an option to only delete the entry from cache after the last operation fails to prevent unnecessary memberof operations for example.
Diffstat (limited to 'src/providers/ldap/ldap_id_netgroup.c')
-rw-r--r--src/providers/ldap/ldap_id_netgroup.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/providers/ldap/ldap_id_netgroup.c b/src/providers/ldap/ldap_id_netgroup.c
index 759a9353b..e48a7da6c 100644
--- a/src/providers/ldap/ldap_id_netgroup.c
+++ b/src/providers/ldap/ldap_id_netgroup.c
@@ -49,6 +49,8 @@ struct ldap_netgroup_get_state {
struct sysdb_attrs **netgroups;
int dp_error;
+ int sdap_ret;
+ bool noexist_delete;
};
static int ldap_netgroup_get_retry(struct tevent_req *req);
@@ -60,7 +62,8 @@ struct tevent_req *ldap_netgroup_get_send(TALLOC_CTX *memctx,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_conn_ctx *conn,
- const char *name)
+ const char *name,
+ bool noexist_delete)
{
struct tevent_req *req;
struct ldap_netgroup_get_state *state;
@@ -75,6 +78,7 @@ struct tevent_req *ldap_netgroup_get_send(TALLOC_CTX *memctx,
state->sdom = sdom;
state->conn = conn;
state->dp_error = DP_ERR_FATAL;
+ state->noexist_delete = noexist_delete;
state->op = sdap_id_op_create(state, state->conn->conn_cache);
if (!state->op) {
@@ -195,6 +199,7 @@ static void ldap_netgroup_get_done(struct tevent_req *subreq)
return;
}
+ state->sdap_ret = ret;
if (ret && ret != ENOENT) {
state->dp_error = dp_error;
@@ -209,7 +214,7 @@ static void ldap_netgroup_get_done(struct tevent_req *subreq)
return;
}
- if (ret == ENOENT) {
+ if (ret == ENOENT && state->noexist_delete == true) {
ret = sysdb_delete_netgroup(state->sysdb, state->domain, state->name);
if (ret != EOK && ret != ENOENT) {
tevent_req_error(req, ret);
@@ -222,7 +227,7 @@ static void ldap_netgroup_get_done(struct tevent_req *subreq)
return;
}
-int ldap_netgroup_get_recv(struct tevent_req *req, int *dp_error_out)
+int ldap_netgroup_get_recv(struct tevent_req *req, int *dp_error_out, int *sdap_ret)
{
struct ldap_netgroup_get_state *state = tevent_req_data(req,
struct ldap_netgroup_get_state);
@@ -231,6 +236,10 @@ int ldap_netgroup_get_recv(struct tevent_req *req, int *dp_error_out)
*dp_error_out = state->dp_error;
}
+ if (sdap_ret) {
+ *sdap_ret = state->sdap_ret;
+ }
+
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;