>From 6b319c66f08a4458c7de1bc152cc4646f047c0a3 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Wed, 7 Jan 2015 09:40:45 +0000
Subject: [PATCH 1/2] AD: add new option ad_site

This option overrides a result of the automatic site discovery.

Resolves:
https://fedorahosted.org/sssd/ticket/2486
---
 src/config/SSSDConfig/__init__.py.in   |  2 ++
 src/config/etc/sssd.api.d/sssd-ad.conf |  1 +
 src/man/sssd-ad.5.xml                  | 14 ++++++++++++++
 src/providers/ad/ad_common.h           |  1 +
 src/providers/ad/ad_opts.h             |  1 +
 5 files changed, 19 insertions(+)

diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index 500bd717fec7abcaafd5153ccca7847b91e208ad..ae00a2b7f9130725a6a766a4cbbba0a53f86dd7a 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -188,6 +188,8 @@ option_strings = {
     'ad_gpo_map_permit' : _('PAM service names for which GPO-based access is always granted'),
     'ad_gpo_map_deny' : _('PAM service names for which GPO-based access is always denied'),
     'ad_gpo_default_right' : _('Default logon right (or permit/deny) to use for unmapped PAM service names'),
+    'ad_site' : _('a particular site to be used by the client'),
+
     # [provider/krb5]
     'krb5_kdcip' : _('Kerberos server address'),
     'krb5_server' : _('Kerberos server address'),
diff --git a/src/config/etc/sssd.api.d/sssd-ad.conf b/src/config/etc/sssd.api.d/sssd-ad.conf
index 3496fb4006697d380f7c9729ed9997272cbce2ea..5a5ea0c36b07d7497c1caa4208c7270d6de6dcc9 100644
--- a/src/config/etc/sssd.api.d/sssd-ad.conf
+++ b/src/config/etc/sssd.api.d/sssd-ad.conf
@@ -16,6 +16,7 @@ ad_gpo_map_service = str, None, false
 ad_gpo_map_permit = str, None, false
 ad_gpo_map_deny = str, None, false
 ad_gpo_default_right = str, None, false
+ad_site = str, None, false
 ldap_uri = str, None, false
 ldap_backup_uri = str, None, false
 ldap_search_base = str, None, false
diff --git a/src/man/sssd-ad.5.xml b/src/man/sssd-ad.5.xml
index 1b33f28ab601871fbd52c47a6a829a24b9b67302..461390fe3a82ed7744da3c8d375b6a01079368fe 100644
--- a/src/man/sssd-ad.5.xml
+++ b/src/man/sssd-ad.5.xml
@@ -228,6 +228,20 @@ FOREST:EXAMPLE.COM:(memberOf=cn=admins,ou=groups,dc=example,dc=com)
                 </varlistentry>
 
                 <varlistentry>
+                    <term>ad_site (string)</term>
+                    <listitem>
+                        <para>
+                          Specify AD site to which client should try to
+                          connect to. If this option is not set, the AD site
+                          will be auto-discovered.
+                        </para>
+                        <para>
+                            Default: Not set
+                        </para>
+                    </listitem>
+                </varlistentry>
+
+                <varlistentry>
                     <term>ad_enable_gc (boolean)</term>
                     <listitem>
                         <para>
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
index b39ade40cd00ad5fccdb5d4bf4df8790eb634a51..dcd70bf94c682fde8b7d17a323ccc3947c659d73 100644
--- a/src/providers/ad/ad_common.h
+++ b/src/providers/ad/ad_common.h
@@ -60,6 +60,7 @@ enum ad_basic_opt {
     AD_GPO_MAP_PERMIT,
     AD_GPO_MAP_DENY,
     AD_GPO_DEFAULT_RIGHT,
+    AD_SITE,
     AD_KRB5_CONFD_PATH,
 
     AD_OPTS_BASIC /* opts counter */
diff --git a/src/providers/ad/ad_opts.h b/src/providers/ad/ad_opts.h
index d9405e5020ca724a0f7caa752ac10fb07d8aa397..f4c1c523bdc57a824105dfd781eb90a88e068908 100644
--- a/src/providers/ad/ad_opts.h
+++ b/src/providers/ad/ad_opts.h
@@ -48,6 +48,7 @@ struct dp_option ad_basic_opts[] = {
     { "ad_gpo_map_permit", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ad_gpo_map_deny", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ad_gpo_default_right", DP_OPT_STRING, NULL_STRING, NULL_STRING },
+    { "ad_site", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "krb5_confd_path", DP_OPT_STRING, { KRB5_MAPPING_DIR }, NULL_STRING },
     DP_OPTION_TERMINATOR
 };
-- 
2.1.0

