--- source/lib/smbldap.c | 12 ++++++++++-- source/param/loadparm.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) Index: samba-3.2.7/source/lib/smbldap.c =================================================================== --- samba-3.2.7.orig/source/lib/smbldap.c +++ samba-3.2.7/source/lib/smbldap.c @@ -620,9 +620,18 @@ int smb_ldap_setup_conn(LDAP **ldap_stru rc = ldap_initialize(ldap_struct, uri); if (rc) { DEBUG(0, ("ldap_initialize: %s\n", ldap_err2string(rc))); + return rc; } - return rc; + if (lp_ldap_ref_follow() != Auto) { + rc = ldap_set_option(*ldap_struct, LDAP_OPT_REFERRALS, + lp_ldap_ref_follow() ? LDAP_OPT_ON : LDAP_OPT_OFF); + if (rc != LDAP_SUCCESS) + DEBUG(0, ("Failed to set LDAP_OPT_REFERRALS: %s\n", + ldap_err2string(rc))); + } + + return LDAP_SUCCESS; #else /* Parse the string manually */ @@ -673,7 +682,6 @@ int smb_ldap_setup_conn(LDAP **ldap_stru } #endif /* HAVE_LDAP_INITIALIZE */ - /* now set connection timeout */ #ifdef LDAP_X_OPT_CONNECT_TIMEOUT /* Netscape */ { Index: samba-3.2.7/source/param/loadparm.c =================================================================== --- samba-3.2.7.orig/source/param/loadparm.c +++ samba-3.2.7/source/param/loadparm.c @@ -250,6 +250,7 @@ struct global { char *szLdapIdmapSuffix; char *szLdapGroupSuffix; int ldap_ssl; + int ldap_ref_follow; char *szLdapSuffix; char *szLdapAdminDn; int ldap_debug_level; @@ -3554,6 +3555,14 @@ static struct parm_struct parm_table[] = .flags = FLAG_ADVANCED, }, { + .label = "ldap ref follow", + .type = P_ENUM, + .p_class = P_GLOBAL, + .ptr = &Globals.ldap_ref_follow, + .enum_list = enum_bool_auto, + .flags = FLAG_ADVANCED, + }, + { .label = "ldap timeout", .type = P_INTEGER, .p_class = P_GLOBAL, @@ -4765,6 +4774,7 @@ static void init_globals(bool first_time Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF; Globals.ldap_delete_dn = False; Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */ + Globals.ldap_ref_follow = Auto; Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT; Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT; Globals.ldap_page_size = LDAP_PAGE_SIZE; @@ -5080,6 +5090,7 @@ FN_GLOBAL_BOOL(lp_passdb_expand_explicit FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix) FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn) FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl) +FN_GLOBAL_INTEGER(lp_ldap_ref_follow, &Globals.ldap_ref_follow) FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync) FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn) FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)