ad_id.c revision 4537e95f6741ae05ec620e5b46ca1d4a3a1ceae5
/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2012 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "util/strtonum.h"
#include "providers/ad/ad_common.h"
#include "providers/ad/ad_domain_info.h"
#include "providers/ldap/sdap_async_enum.h"
#include "providers/ldap/sdap_idmap.h"
struct ad_handle_acct_info_state {
struct be_acct_req *ar;
struct sdap_id_ctx *ctx;
struct sdap_id_conn_ctx **conn;
struct sdap_domain *sdom;
int dp_error;
const char *err;
};
struct tevent_req *
struct be_acct_req *ar,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_conn_ctx **conn)
{
struct tevent_req *req;
struct ad_handle_acct_info_state *state;
return NULL;
}
}
/* Lookup in progress */
return req;
}
static errno_t
{
struct tevent_req *subreq;
struct ad_handle_acct_info_state);
bool noexist_delete = false;
return EOK;
}
noexist_delete = true;
}
return ENOMEM;
}
return EAGAIN;
}
static void
{
int dp_error;
int sdap_err;
const char *err;
struct tevent_req);
struct ad_handle_acct_info_state);
if (dp_error == DP_ERR_OFFLINE
/* This is a special case: GC does not work.
* We need to Fall back to ldap
*/
}
return;
}
return;
return;
}
/* Ret is only ENOENT now. Try the next connection */
/* No additional search in progress. Save the last
* error status, we'll be returning it.
*/
/* No more connections */
} else {
}
return;
}
/* Another lookup in progress */
}
{
struct ad_handle_acct_info_state);
if (_dp_error) {
}
if (_err) {
}
return EOK;
}
struct sdap_id_conn_ctx **
{
struct sdap_id_conn_ctx **clist;
/* LDAP, GC, sentinel */
case BE_REQ_USER: /* user */
case BE_REQ_BY_SECID: /* by SID */
case BE_REQ_USER_AND_GROUP: /* get SID */
case BE_REQ_GROUP: /* group */
case BE_REQ_INITGROUPS: /* init groups for user */
/* Always try GC first */
if (IS_SUBDOMAIN(dom) == true) {
clist[0]->ignore_mark_offline = false;
/* Subdomain users are only present in GC. */
break;
}
/* fall back to ldap if gc is not available */
clist[0]->ignore_mark_offline = true;
/* With root domain users we have the option to
* fall back to LDAP in case ie POSIX attributes
* are used but not replicated to GC
*/
break;
default:
break;
}
return clist;
}
struct sdap_idmap_ctx *idmap_ctx,
int filter_type,
const char *filter_value,
const char *filter_domain,
bool *_shortcut)
{
enum idmap_error_code err;
bool shortcut = false;
shortcut = false;
goto done;
}
switch (filter_type) {
case BE_FILTER_IDNUM:
/* convert value to ID */
errno = 0;
if (errno != 0) {
goto done;
}
/* convert the ID to its SID equivalent */
if (err != IDMAP_SUCCESS) {
goto done;
}
/* fall through */
case BE_FILTER_SECID:
goto done;
}
shortcut = true;
} else {
shortcut = false;
}
break;
default:
shortcut = false;
break;
}
done:
}
}
return ret;
}
void
{
struct be_acct_req *ar;
struct sdap_id_ctx *sdap_id_ctx;
struct tevent_req *req;
struct sss_domain_info *dom;
struct sdap_domain *sdom;
struct sdap_id_conn_ctx **clist;
bool shortcut;
struct ad_id_ctx);
if (be_is_offline(be_ctx)) {
}
/* Try to shortcut if this is ID or SID search and it belongs to
* other domain range than is in ar->domain. */
goto fail;
}
if (shortcut) {
return;
}
/* Subdomain request, verify subdomain */
}
goto fail;
}
/* Determine whether to connect to GC, LDAP or try both */
goto fail;
}
goto fail;
}
goto fail;
}
return;
fail:
}
static void
{
int dp_error;
const char *error_text = "Internal error";
const char *req_error_text;
error_text = NULL;
} else {
("Bug: dp_error is OK on failed request"));
}
} else if (dp_error == DP_ERR_OFFLINE) {
error_text = "Offline";
error_text = "Out of memory";
} else {
}
}
void
{
struct ad_id_ctx);
}
struct ad_enumeration_state {
struct ldap_enum_ctx *ectx;
struct sdap_id_op *sdap_op;
struct tevent_context *ev;
struct sdap_domain *sdom;
};
struct tevent_req *
struct tevent_context *ev,
void *pvt)
{
struct tevent_req *req;
struct tevent_req *subreq;
struct ad_enumeration_state *state;
struct ldap_enum_ctx *ectx;
goto fail;
}
goto fail;
}
goto fail;
}
return req;
fail:
return req;
}
static void
{
struct tevent_req);
struct ad_enumeration_state);
if (dp_error == DP_ERR_OFFLINE) {
("Backend is marked offline, retry later!\n"));
} else {
("Domain enumeration failed to connect to " \
}
return;
}
return;
}
}
static void
{
struct tevent_req);
struct ad_enumeration_state);
char *flat_name;
char *master_sid;
&flat_name, &master_sid);
return;
}
return;
}
/* The ptask API will reschedule the enumeration on its own on
* failure */
("Failed to schedule enumeration, retrying later!\n"));
return;
}
}
static void
{
struct tevent_req);
struct ad_enumeration_state);
return;
}
/* Ok, we've completed an enumeration. Save this to the
* sysdb so we can postpone starting up the enumeration
* process on the next SSSD service restart (to avoid
* slowing down system boot-up
*/
("Could not mark domain as having enumerated.\n"));
/* This error is non-fatal, so continue */
}
}
{
return EOK;
}