diff options
-rw-r--r-- | src/providers/ldap/ldap_id.c | 9 | ||||
-rw-r--r-- | src/providers/ldap/ldap_id_enum.c | 15 | ||||
-rw-r--r-- | src/providers/ldap/sdap_id_op.c | 4 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index de618333..a3c9c0cd 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -726,9 +726,12 @@ static void sdap_check_online_done(struct tevent_req *req) } else { dp_err = DP_ERR_OK; - if (strcmp(srv_opts->server_id, ctx->srv_opts->server_id) == 0 && - srv_opts->supports_usn && - ctx->srv_opts->last_usn > srv_opts->last_usn) { + if (!ctx->srv_opts) { + srv_opts->max_user_value = 0; + srv_opts->max_group_value = 0; + } else if (strcmp(srv_opts->server_id, ctx->srv_opts->server_id) == 0 + && srv_opts->supports_usn + && ctx->srv_opts->last_usn > srv_opts->last_usn) { ctx->srv_opts->max_user_value = 0; ctx->srv_opts->max_group_value = 0; ctx->srv_opts->last_usn = srv_opts->last_usn; diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c index d7dd33e4..68d113bf 100644 --- a/src/providers/ldap/ldap_id_enum.c +++ b/src/providers/ldap/ldap_id_enum.c @@ -511,6 +511,8 @@ static void enum_users_op_done(struct tevent_req *subreq) struct enum_users_state *state = tevent_req_data(req, struct enum_users_state); char *usn_value; + char *endptr = NULL; + unsigned usn_number; int ret; ret = sdap_get_users_recv(subreq, state, &usn_value); @@ -523,6 +525,12 @@ static void enum_users_op_done(struct tevent_req *subreq) if (usn_value) { talloc_zfree(state->ctx->srv_opts->max_user_value); state->ctx->srv_opts->max_user_value = talloc_steal(state->ctx, usn_value); + + usn_number = strtoul(usn_value, &endptr, 10); + if ((endptr == NULL || (*endptr == '\0' && endptr != usn_value)) + && (usn_number > state->ctx->srv_opts->last_usn)) { + state->ctx->srv_opts->last_usn = usn_number; + } } DEBUG(4, ("Users higher USN value: [%s]\n", @@ -629,6 +637,8 @@ static void enum_groups_op_done(struct tevent_req *subreq) struct enum_groups_state *state = tevent_req_data(req, struct enum_groups_state); char *usn_value; + char *endptr = NULL; + unsigned usn_number; int ret; ret = sdap_get_groups_recv(subreq, state, &usn_value); @@ -642,6 +652,11 @@ static void enum_groups_op_done(struct tevent_req *subreq) talloc_zfree(state->ctx->srv_opts->max_group_value); state->ctx->srv_opts->max_group_value = talloc_steal(state->ctx, usn_value); + usn_number = strtoul(usn_value, &endptr, 10); + if ((endptr == NULL || (*endptr == '\0' && endptr != usn_value)) + && (usn_number > state->ctx->srv_opts->last_usn)) { + state->ctx->srv_opts->last_usn = usn_number; + } } DEBUG(4, ("Groups higher USN value: [%s]\n", diff --git a/src/providers/ldap/sdap_id_op.c b/src/providers/ldap/sdap_id_op.c index 1f692a15..11a379cc 100644 --- a/src/providers/ldap/sdap_id_op.c +++ b/src/providers/ldap/sdap_id_op.c @@ -537,9 +537,9 @@ static void sdap_id_op_connect_done(struct tevent_req *subreq) current_srv_opts->last_usn > srv_opts->last_usn) { DEBUG(5, ("Server was probably re-initialized\n")); - current_srv_opts->max_user_value= 0; + current_srv_opts->max_user_value = 0; current_srv_opts->max_group_value = 0; - current_srv_opts->last_usn = 0; + current_srv_opts->last_usn = srv_opts->last_usn; } } ret = sdap_id_conn_data_set_expire_timer(conn_data); |