ldap_id.c revision 206329d3901738036352f2ac1e8d7804f728861d
/*
SSSD
LDAP Identity Backend Module
Authors:
Simo Sorce <ssorce@redhat.com>
Copyright (C) 2008 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 <errno.h>
#include <time.h>
#include "util/strtonum.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async.h"
#include "providers/ldap/sdap_idmap.h"
#include "providers/ldap/sdap_users.h"
/* =Users-Related-Functions-(by-name,by-uid)============================== */
struct users_get_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
struct sss_domain_info *domain;
const char *name;
int filter_type;
char *filter;
const char **attrs;
int dp_error;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
const char *name,
int filter_type,
int attrs_type)
{
struct tevent_req *req;
struct users_get_state *state;
const char *attr_name;
char *clean_name;
char *endptr;
int ret;
enum idmap_error_code err;
char *sid;
goto fail;
}
switch (filter_type) {
case BE_FILTER_NAME:
goto fail;
}
break;
case BE_FILTER_IDNUM:
/* If we're ID-mapping, we need to use the objectSID
* in the search filter.
*/
goto fail;
}
/* Convert the UID to its objectSID */
if (err != IDMAP_SUCCESS) {
("Mapping ID [%s] to SID failed: [%s]\n",
goto fail;
}
goto fail;
}
} else {
goto fail;
}
}
break;
default:
goto fail;
}
goto fail;
}
/* TODO: handle attrs_type */
goto fail;
}
return req;
fail:
return req;
}
{
struct users_get_state);
struct tevent_req *subreq;
if (!subreq) {
return ret;
}
return EOK;
}
{
struct tevent_req);
struct users_get_state);
int dp_error = DP_ERR_FATAL;
int ret;
return;
}
false);
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct users_get_state);
char *endptr;
int dp_error = DP_ERR_FATAL;
int ret;
/* retry */
return;
}
return;
}
SDAP_RFC2307_FALLBACK_TO_LOCAL_USERS) == true)) {
struct sysdb_attrs **usr_attrs;
bool fallback;
switch (state->filter_type) {
case BE_FILTER_NAME:
uid = -1;
fallback = true;
break;
case BE_FILTER_IDNUM:
return;
}
fallback = true;
break;
default:
fallback = false;
break;
}
if (fallback) {
}
}
}
return;
}
switch (state->filter_type) {
case BE_FILTER_ENUM:
return;
case BE_FILTER_NAME:
return;
}
break;
case BE_FILTER_IDNUM:
return;
}
return;
}
break;
default:
return;
}
}
}
{
struct users_get_state);
if (dp_error_out) {
}
return EOK;
}
/* =Groups-Related-Functions-(by-name,by-uid)============================= */
struct groups_get_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
struct sss_domain_info *domain;
const char *name;
int filter_type;
char *filter;
const char **attrs;
int dp_error;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
const char *name,
int filter_type,
int attrs_type)
{
struct tevent_req *req;
struct groups_get_state *state;
const char *attr_name;
char *clean_name;
char *endptr;
int ret;
enum idmap_error_code err;
char *sid;
const char *member_filter[2];
goto fail;
}
switch(filter_type) {
case BE_FILTER_NAME:
goto fail;
}
break;
case BE_FILTER_IDNUM:
/* If we're ID-mapping, we need to use the objectSID
* in the search filter.
*/
goto fail;
}
/* Convert the UID to its objectSID */
if (err != IDMAP_SUCCESS) {
("Mapping ID [%s] to SID failed: [%s]\n",
goto fail;
}
goto fail;
}
} else {
goto fail;
}
}
break;
default:
goto fail;
}
if (use_id_mapping) {
/* When mapping IDs, we don't want to limit ourselves
* to groups with a GID value
*/
"(&(%s=%s)(objectclass=%s)(%s=*))",
} else {
"(&(%s=%s)(objectclass=%s)(%s=*)(&(%s=*)(!(%s=0))))",
}
goto fail;
}
/* TODO: handle attrs_type */
(const char **)member_filter : NULL,
goto fail;
}
return req;
fail:
return req;
}
{
struct groups_get_state);
struct tevent_req *subreq;
if (!subreq) {
return ret;
}
return EOK;
}
{
struct tevent_req);
struct groups_get_state);
int dp_error = DP_ERR_FATAL;
int ret;
return;
}
false);
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct groups_get_state);
char *endptr;
int dp_error = DP_ERR_FATAL;
int ret;
/* retry */
return;
}
return;
}
return;
}
switch (state->filter_type) {
case BE_FILTER_ENUM:
return;
case BE_FILTER_NAME:
return;
}
break;
case BE_FILTER_IDNUM:
return;
}
return;
}
break;
default:
return;
}
}
}
{
struct groups_get_state);
if (dp_error_out) {
}
return EOK;
}
/* =Get-Groups-for-User================================================== */
struct groups_by_user_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
const char *name;
const char **attrs;
int dp_error;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
const char *name)
{
struct tevent_req *req;
struct groups_by_user_state *state;
int ret;
goto fail;
}
goto fail;
}
return req;
fail:
return req;
}
{
struct groups_by_user_state);
struct tevent_req *subreq;
if (!subreq) {
return ret;
}
return EOK;
}
{
struct tevent_req);
struct groups_by_user_state);
int dp_error = DP_ERR_FATAL;
int ret;
return;
}
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct groups_by_user_state);
int dp_error = DP_ERR_FATAL;
int ret;
/* retry */
return;
}
return;
}
return;
}
return;
}
}
}
{
struct groups_by_user_state);
if (dp_error_out) {
}
return EOK;
}
{
struct sdap_id_ctx *ctx;
struct sdap_id_ctx);
}
struct sdap_online_check_ctx {
struct sdap_id_ctx *id_ctx;
};
{
struct tevent_req *req;
struct sdap_online_check_ctx *check_ctx;
if (!check_ctx) {
goto fail;
}
CON_TLS_DFL, false);
goto fail;
}
return;
fail:
}
{
struct sdap_online_check_ctx);
int ret;
int dp_err = DP_ERR_FATAL;
bool can_retry;
struct sdap_server_opts *srv_opts;
struct sdap_id_ctx *id_ctx;
bool reinit = false;
if (!can_retry) {
}
} else {
srv_opts->max_user_value = 0;
srv_opts->max_group_value = 0;
srv_opts->max_service_value = 0;
srv_opts->max_sudo_value = 0;
&& srv_opts->supports_usn
reinit = true;
}
}
if (reinit) {
"Cleaning cache.\n"));
if (reinit_req == NULL) {
"clean up.\n"));
/* not fatal */
goto done;
}
be_req);
return;
}
done:
}
{
/* not fatal */
} else {
}
}
/* =Get-Account-Info-Call================================================= */
/* FIXME: embed this function in sssd_be and only call out
* specific functions from modules ? */
{
struct sdap_id_ctx *ctx;
if (!ctx) {
EINVAL, "Invalid request data\n");
}
}
{
struct be_acct_req *ar;
struct tevent_req *req;
const char *err = "Unknown Error";
}
case BE_REQ_USER: /* user */
/* skip enumerations on demand */
}
if (!req) {
}
break;
case BE_REQ_GROUP: /* group */
/* skip enumerations on demand */
}
if (!req) {
}
break;
case BE_REQ_INITGROUPS: /* init groups for user */
err = "Invalid filter type";
break;
}
err = "Invalid attr type";
break;
}
ar->filter_value);
/* tevent_req_set_callback(req, groups_by_user_done, breq); */
break;
case BE_REQ_NETGROUP:
err = "Invalid filter type";
break;
}
if (!req) {
}
break;
case BE_REQ_SERVICES:
/* skip enumerations on demand */
}
err = "Invalid filter type";
break;
}
ar->filter_type);
if (!req) {
ENOMEM, "Out of memory");
}
break;
default: /*fail*/
err = "Invalid request type";
}
}
int ret, const char *default_error_text)
{
const char* error_text;
error_text = NULL;
} else {
}
} else if (dp_error == DP_ERR_OFFLINE) {
error_text = "Offline";
error_text = "Out of memory";
} else {
}
}
{
}
{
}
{
}
{
}
{
}