>From 3494b743018ccf52d76391fd5ccb7031fc19c362 Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzeleny@redhat.com>
Date: Tue, 17 Jul 2012 08:08:20 -0400
Subject: [PATCH 12/12] Primary server support: new option in AD provider

This patch adds support for new config option ad_backup_server. The
description of this option's functionality is included in man page in
one of previous patches.
---
 src/config/SSSDConfig/__init__.py.in   |    1 +
 src/config/etc/sssd.api.d/sssd-ad.conf |    1 +
 src/man/sssd-ad.5.xml                  |    2 +-
 src/providers/ad/ad_common.h           |    1 +
 src/providers/ad/ad_init.c             |    4 +++-
 src/providers/ad/ad_opts.h             |    1 +
 6 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index 5c01f133f8af8cc13a4e53d1a7a16b283d658034..3c7b61031009b0e203bd3d2d68513dbf88684d48 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -140,6 +140,7 @@ option_strings = {
     # [provider/ad]
     'ad_domain' : _('Active Directory domain'),
     'ad_server' : _('Active Directory server address'),
+    'ad_backup_server' : _('Active Directory backup server address'),
     'ad_hostname' : _('Active Directory client hostname'),
 
     # [provider/krb5]
diff --git a/src/config/etc/sssd.api.d/sssd-ad.conf b/src/config/etc/sssd.api.d/sssd-ad.conf
index 763ea0d460c73d35e6fdfed3cf149a9ec7231641..0154e6aa927d7222c6638e33c0ef799f87522250 100644
--- a/src/config/etc/sssd.api.d/sssd-ad.conf
+++ b/src/config/etc/sssd.api.d/sssd-ad.conf
@@ -1,6 +1,7 @@
 [provider/ad]
 ad_domain = str, None, false
 ad_server = str, None, false
+ad_backup_server = str, None, false
 ad_hostname = str, None, false
 ldap_uri = str, None, false
 ldap_backup_uri = str, None, false
diff --git a/src/man/sssd-ad.5.xml b/src/man/sssd-ad.5.xml
index 46660b306250ace449d16fd40cab373875eb64a6..1efecd18a0bd27eda64a4340f69b7ea46fd7097a 100644
--- a/src/man/sssd-ad.5.xml
+++ b/src/man/sssd-ad.5.xml
@@ -86,7 +86,7 @@
                 </varlistentry>
 
                 <varlistentry>
-                    <term>ad_server (string)</term>
+                    <term>ad_server, ad_backup_server (string)</term>
                     <listitem>
                         <para>
                             The comma-separated list of IP addresses or
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
index f2ed680d2991bdd13a2a3dfe0f8999158a1820a0..320bf1c9de7b5abacb270eb0cd09cb10227211cb 100644
--- a/src/providers/ad/ad_common.h
+++ b/src/providers/ad/ad_common.h
@@ -33,6 +33,7 @@ struct ad_options;
 enum ad_basic_opt {
     AD_DOMAIN = 0,
     AD_SERVER,
+    AD_BACKUP_SERVER,
     AD_HOSTNAME,
     AD_KEYTAB,
     AD_KRB5_REALM,
diff --git a/src/providers/ad/ad_init.c b/src/providers/ad/ad_init.c
index 0c0a8ef63cbd4ed1003452594221c3262ac5c971..d08312526ac5f6525a548f9f7e5eb334bb3f03c2 100644
--- a/src/providers/ad/ad_init.c
+++ b/src/providers/ad/ad_init.c
@@ -67,6 +67,7 @@ common_ad_init(struct be_ctx *bectx)
 {
     errno_t ret;
     char *ad_servers = NULL;
+    char *ad_backup_servers = NULL;
 
     /* Get AD-specific options */
     ret = ad_get_common_options(bectx, bectx->cdb,
@@ -81,9 +82,10 @@ common_ad_init(struct be_ctx *bectx)
     }
 
     ad_servers = dp_opt_get_string(ad_options->basic, AD_SERVER);
+    ad_backup_servers = dp_opt_get_string(ad_options->basic, AD_BACKUP_SERVER);
 
     /* Set up the failover service */
-    ret = ad_failover_init(ad_options, bectx, ad_servers, NULL, ad_options,
+    ret = ad_failover_init(ad_options, bectx, ad_servers, ad_backup_servers, ad_options,
                            &ad_options->service);
     if (ret != EOK) {
         DEBUG(SSSDBG_FATAL_FAILURE,
diff --git a/src/providers/ad/ad_opts.h b/src/providers/ad/ad_opts.h
index 458e7ea4d717d300e8f407d514100e43974d40e3..eba5a099981d0c9be65257500b38cef88c9474bf 100644
--- a/src/providers/ad/ad_opts.h
+++ b/src/providers/ad/ad_opts.h
@@ -30,6 +30,7 @@
 struct dp_option ad_basic_opts[] = {
     { "ad_domain", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ad_server", DP_OPT_STRING, NULL_STRING, NULL_STRING },
+    { "ad_backup_server", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ad_hostname", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "krb5_keytab", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "krb5_realm", DP_OPT_STRING, NULL_STRING, NULL_STRING},
-- 
1.7.7.6

