sdap_async_initgroups_ad.c revision d42d371c00c83ae44b9d1c3e88ecbe0e01b112e6
/*
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 "providers/ldap/sdap_async.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async_private.h"
struct sdap_ad_match_rule_initgr_state {
struct tevent_context *ev;
struct sdap_options *opts;
struct sdap_handle *sh;
const char *name;
const char *orig_dn;
const char **attrs;
int timeout;
const char *base_filter;
char *filter;
struct sysdb_attrs **groups;
struct sdap_search_base **search_bases;
};
static errno_t
static void
struct tevent_req *
struct tevent_context *ev,
struct sdap_options *opts,
struct sdap_handle *sh,
const char *name,
const char *orig_dn,
int timeout)
{
struct tevent_req *req;
struct sdap_ad_match_rule_initgr_state *state;
const char **filter_members;
char *sanitized_user_dn;
struct sdap_ad_match_rule_initgr_state);
/* Request all of the group attributes that we know
* about, except for 'member' because that wastes a
* lot of bandwidth here and we only really
* care about a single member (the one we already
* have).
*/
if (!filter_members) {
goto immediate;
}
("Could not build attribute map: [%s]\n",
goto immediate;
}
/* Sanitize the user DN in case we have special characters in DN */
("Could not sanitize user DN: %s\n",
goto immediate;
}
/* Craft a special filter according to
*/
state->base_filter =
"(&(%s:%s:=%s)(objectClass=%s))",
if (!state->base_filter) {
goto immediate;
}
/* Start the loop through the search bases to get all of the
* groups to which this user belongs.
*/
("sdap_get_ad_match_rule_members_next_base failed: [%s]\n",
goto immediate;
}
return req;
return req;
}
static errno_t
{
struct tevent_req *subreq;
struct sdap_ad_match_rule_initgr_state *state;
return ENOMEM;
}
("Searching for groups with base [%s]\n",
if (!subreq) {
return ENOMEM;
}
req);
return EOK;
}
static void
{
struct tevent_req *req =
struct sdap_ad_match_rule_initgr_state *state =
struct sysdb_attrs **groups;
char **sysdb_grouplist;
goto error;
}
("Search for users returned %d results\n", count));
/* Add this batch of groups to the list */
if (count > 0) {
struct sysdb_attrs *,
return;
}
/* Copy the new groups into the list */
for (i = 0; i < count; i++) {
}
}
/* Continue checking other search bases */
/* There are more search bases to try */
goto error;
}
return;
}
/* No more search bases. Save the groups. */
("User is not a member of any group in the search bases\n"));
}
/* Get the current sysdb group list for this user
* so we can update it.
*/
("Could not get the list of groups for [%s] in the sysdb: "
"[%s]\n",
goto error;
}
/* The extensibleMatch search rule eliminates the need for
* nested group searches, so we can just update the
* memberships now.
*/
("Could not store groups for user [%s]: [%s]\n",
goto error;
}
return;
}
{
return EOK;
}