ad_srv.c revision edf96099f719e591e98be20af416a32cb4aeea73
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2013 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 <string.h>
#include <talloc.h>
#include <tevent.h>
#include <ndr.h>
#include "util/sss_ldap.h"
#include "resolv/async_resolv.h"
#include "providers/dp_backend.h"
#include "providers/ad/ad_common.h"
#include "providers/fail_over.h"
#include "providers/fail_over_srv.h"
#include "providers/ldap/sdap_async.h"
#define AD_SITE_DOMAIN_FMT "%s._sites.%s"
const char *domain,
struct fo_server_info **_srv,
{
size_t i, j;
return EINVAL;
}
if (num <= 1) {
return EOK;
}
return ENOMEM;
}
/* When several servers share priority, we will prefer the one that
* is located in the same domain as client (e.g. child domain instead
* of forest root) but obey their weight. We will use the fact that
* the servers are already sorted by priority. */
for (i = 0; i < num; i++) {
/* this is a preferred server, push it to the in domain list */
in_index++;
} else {
/* this is a normal server, push it to the out domain list */
out_index++;
}
/* priority has changed or we have reached the end of the srv list,
* we will merge the list into final list and start over with
* next priority */
for (j = 0; j < in_index; j++) {
srv_index++;
}
for (j = 0; j < out_index; j++) {
srv_index++;
}
in_index = 0;
out_index = 0;
}
}
talloc_free(*_srv);
return EOK;
}
struct ad_get_dc_servers_state {
struct fo_server_info *servers;
};
struct tevent_context *ev,
struct resolv_ctx *resolv_ctx,
const char *domain)
{
struct ad_get_dc_servers_state);
return NULL;
}
goto immediately;
}
goto immediately;
}
domain);
goto immediately;
}
return req;
return req;
}
{
goto done;
}
done:
return;
}
}
struct tevent_req *req,
struct fo_server_info **_dcs,
{
return EOK;
}
struct ad_get_client_site_state {
struct tevent_context *ev;
struct be_resolv_ctx *be_res;
enum host_database *host_db;
struct sdap_options *opts;
const char *ad_domain;
struct fo_server_info *dcs;
struct fo_server_info dc;
struct sdap_handle *sh;
char *site;
char *forest;
};
struct tevent_context *ev,
struct be_resolv_ctx *be_res,
enum host_database *host_db,
struct sdap_options *opts,
const char *ad_domain,
struct fo_server_info *dcs,
{
struct ad_get_client_site_state);
return NULL;
}
goto immediately;
}
goto immediately;
goto immediately;
}
return req;
} else {
}
return req;
}
{
goto done;
}
goto done;
}
done:
return ret;
}
{
}
goto done;
}
goto done;
}
goto done;
}
false);
goto done;
}
done:
}
return;
}
char **_site_name,
char **_forest_name)
{
struct netlogon_samlogon_response response;
enum ndr_err_code ndr_err;
return ENOMEM;
}
goto done;
}
&response);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
"failed [%d]\n", ndr_err);
goto done;
}
goto done;
}
} else {
goto done;
}
} else {
goto done;
}
goto done;
}
done:
return ret;
}
{
/* we're done with this LDAP, close connection */
}
goto done;
}
if (reply_count == 0) {
goto done;
}
goto done;
}
if (el->num_values == 0) {
goto done;
goto done;
}
goto done;
}
done:
return;
}
}
struct tevent_req *req,
char **_site,
char **_forest)
{
return EOK;
}
struct ad_srv_plugin_ctx {
struct be_resolv_ctx *be_res;
enum host_database *host_dbs;
struct sdap_options *opts;
const char *hostname;
const char *ad_domain;
};
struct ad_srv_plugin_ctx *
struct be_resolv_ctx *be_res,
enum host_database *host_dbs,
struct sdap_options *opts,
const char *hostname,
const char *ad_domain)
{
return NULL;
}
goto fail;
}
goto fail;
}
return ctx;
fail:
return NULL;
}
struct ad_srv_plugin_state {
struct tevent_context *ev;
struct ad_srv_plugin_ctx *ctx;
const char *service;
const char *protocol;
const char *discovery_domain;
char *site;
char *dns_domain;
char *forest;
struct fo_server_info *primary_servers;
struct fo_server_info *backup_servers;
};
/* 1. Do a DNS lookup to find any DC in domain
* _ldap._tcp.domain.name
* 2. Send a CLDAP ping to the found DC to get the desirable site
* 3. Do a DNS lookup to find SRV in the site (a)
* _service._protocol.site-name._sites.domain.name
* 4. Do a DNS lookup to find global SRV records (b)
* _service._protocol.domain.name
* 5. If the site is found, use (a) as primary and (b) as backup servers,
* otherwise use (b) as primary servers
*/
struct tevent_context *ev,
const char *service,
const char *protocol,
const char *discovery_domain,
void *pvt)
{
struct ad_srv_plugin_state);
return NULL;
}
goto immediately;
}
goto immediately;
}
goto immediately;
}
if (discovery_domain != NULL) {
} else {
}
goto immediately;
}
goto immediately;
}
return req;
return req;
}
{
goto done;
}
goto done;
}
done:
}
return;
}
{
const char *primary_domain = NULL;
const char *backup_domain = NULL;
if (primary_domain == NULL) {
goto done;
}
} else {
if (primary_domain == NULL) {
goto done;
}
}
} else {
goto done;
}
"backup servers\n");
goto done;
}
done:
}
return;
}
{
return;
}
/* continue */
}
/* continue */
}
}
struct tevent_req *req,
char **_dns_domain,
struct fo_server_info **_primary_servers,
struct fo_server_info **_backup_servers,
{
if (_primary_servers) {
}
if (_num_primary_servers) {
}
if (_backup_servers) {
}
if (_num_backup_servers) {
}
if (_dns_domain) {
}
return EOK;
}