View | Details | Raw Unified | Return to bug 3333
Collapse All | Expand All

(-)src/addrindex.c (-1 / +15 lines)
Lines 107-112 Link Here
107
#define ATTAG_LDAP_MATCH_OPT  "match-opt"
107
#define ATTAG_LDAP_MATCH_OPT  "match-opt"
108
#define ATTAG_LDAP_ENABLE_TLS "enable-tls"
108
#define ATTAG_LDAP_ENABLE_TLS "enable-tls"
109
#define ATTAG_LDAP_ENABLE_SSL "enable-ssl"
109
#define ATTAG_LDAP_ENABLE_SSL "enable-ssl"
110
#define ATTAG_LDAP_REFERRALS  "referrals"
110
111
111
#define ELTAG_LDAP_ATTR_SRCH  "attribute"
112
#define ELTAG_LDAP_ATTR_SRCH  "attribute"
112
#define ATTAG_LDAP_ATTR_NAME  "name"
113
#define ATTAG_LDAP_ATTR_NAME  "name"
Lines 1352-1358 static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) { Link Here
1352
	gchar *serverName = NULL;
1353
	gchar *serverName = NULL;
1353
	gchar *criteria = NULL;
1354
	gchar *criteria = NULL;
1354
	gboolean bDynSearch;
1355
	gboolean bDynSearch;
1355
	gboolean bTLS, bSSL;
1356
	gboolean bTLS, bSSL, bReferrals;
1356
	gint iMatch;
1357
	gint iMatch;
1357
1358
1358
	/* g_print( "addrindex_parse_ldap\n" ); */
1359
	/* g_print( "addrindex_parse_ldap\n" ); */
Lines 1360-1365 static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) { Link Here
1360
	bDynSearch = FALSE;
1361
	bDynSearch = FALSE;
1361
	bTLS = FALSE;
1362
	bTLS = FALSE;
1362
	bSSL = FALSE;
1363
	bSSL = FALSE;
1364
	bReferrals = FALSE;
1363
	iMatch = LDAPCTL_MATCH_BEGINWITH;
1365
	iMatch = LDAPCTL_MATCH_BEGINWITH;
1364
1366
1365
	ds = addrindex_create_datasource( ADDR_IF_LDAP );
1367
	ds = addrindex_create_datasource( ADDR_IF_LDAP );
Lines 1427-1432 static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) { Link Here
1427
				bSSL = TRUE;
1429
				bSSL = TRUE;
1428
			}
1430
			}
1429
		}
1431
		}
1432
		else if( strcmp( name, ATTAG_LDAP_REFERRALS ) == 0 ) {
1433
			bReferrals = FALSE;
1434
			if( strcmp( value, ATVAL_BOOLEAN_YES ) == 0 ) {
1435
				bReferrals = TRUE;
1436
			}
1437
		}
1430
		attr = g_list_next( attr );
1438
		attr = g_list_next( attr );
1431
	}
1439
	}
1432
1440
Lines 1436-1441 static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) { Link Here
1436
	ldapctl_set_matching_option( ctl, iMatch );
1444
	ldapctl_set_matching_option( ctl, iMatch );
1437
	ldapctl_set_tls( ctl, bTLS );
1445
	ldapctl_set_tls( ctl, bTLS );
1438
	ldapctl_set_ssl( ctl, bSSL );
1446
	ldapctl_set_ssl( ctl, bSSL );
1447
	ldapctl_set_referrals( ctl, bReferrals );
1439
	g_free( serverName );
1448
	g_free( serverName );
1440
	ldapsvr_set_control( server, ctl );
1449
	ldapsvr_set_control( server, ctl );
1441
	ds->rawDataSource = server;
1450
	ds->rawDataSource = server;
Lines 1516-1521 static int addrindex_write_ldap( FILE *fp, AddressDataSource *ds, gint lvl ) { Link Here
1516
			ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
1525
			ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
1517
		return -1;
1526
		return -1;
1518
1527
1528
	if (addrindex_write_attr( fp, ATTAG_LDAP_REFERRALS,
1529
			ctl->enableReferrals ?
1530
			ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
1531
		return -1;
1532
1519
	if (fputs(" >\n", fp) == EOF)
1533
	if (fputs(" >\n", fp) == EOF)
1520
		return -1;
1534
		return -1;
1521
1535
(-)src/editldap.c (-1 / +21 lines)
Lines 76-81 static struct _LDAPEdit { Link Here
76
	GtkWidget *spinbtn_queryage;
76
	GtkWidget *spinbtn_queryage;
77
	GtkWidget *check_dynsearch;
77
	GtkWidget *check_dynsearch;
78
	GtkWidget *check_matchoption;
78
	GtkWidget *check_matchoption;
79
	GtkWidget *check_referrals;
79
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
80
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
80
	GtkWidget *enable_ssl;
81
	GtkWidget *enable_ssl;
81
	GtkWidget *enable_tls;
82
	GtkWidget *enable_tls;
Lines 556-561 static void addressbook_edit_ldap_page_search( gint pageNum, gchar *pageLbl ) { Link Here
556
	GtkWidget *spinbtn_queryage;
557
	GtkWidget *spinbtn_queryage;
557
	GtkWidget *check_dynsearch;
558
	GtkWidget *check_dynsearch;
558
	GtkWidget *check_matchoption;
559
	GtkWidget *check_matchoption;
560
	GtkWidget *check_referrals;
559
	GtkWidget *reset_btn;
561
	GtkWidget *reset_btn;
560
	gint top;
562
	gint top;
561
563
Lines 656-661 static void addressbook_edit_ldap_page_search( gint pageNum, gchar *pageLbl ) { Link Here
656
		"interfaces." \
658
		"interfaces." \
657
		));
659
		));
658
660
661
	/* Next row */
662
	++top;
663
	check_referrals = gtk_check_button_new_with_label(
664
				_("Follow referrals") );
665
	gtk_table_attach(GTK_TABLE(table), check_referrals, 1, 3, top, (top + 1),
666
		GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
667
668
	CLAWS_SET_TIP(check_referrals, _( 
669
		"Automatically follow referrals returned by LDAP servers"));
670
659
	/* Signal handlers */
671
	/* Signal handlers */
660
	g_signal_connect(G_OBJECT(reset_btn), "clicked",
672
	g_signal_connect(G_OBJECT(reset_btn), "clicked",
661
			 G_CALLBACK(edit_ldap_search_reset), NULL);
673
			 G_CALLBACK(edit_ldap_search_reset), NULL);
Lines 667-672 static void addressbook_edit_ldap_page_search( gint pageNum, gchar *pageLbl ) { Link Here
667
	ldapedit.spinbtn_queryage  = spinbtn_queryage;
679
	ldapedit.spinbtn_queryage  = spinbtn_queryage;
668
	ldapedit.check_dynsearch   = check_dynsearch;
680
	ldapedit.check_dynsearch   = check_dynsearch;
669
	ldapedit.check_matchoption = check_matchoption;
681
	ldapedit.check_matchoption = check_matchoption;
682
	ldapedit.check_referrals   = check_referrals;
670
}
683
}
671
684
672
static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) {
685
static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) {
Lines 872-877 static void edit_ldap_clear_fields(void) { Link Here
872
	gtk_toggle_button_set_active(
885
	gtk_toggle_button_set_active(
873
		GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch), TRUE );
886
		GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch), TRUE );
874
	gtk_toggle_button_set_active(
887
	gtk_toggle_button_set_active(
888
		GTK_TOGGLE_BUTTON( ldapedit.check_referrals), TRUE );
889
	gtk_toggle_button_set_active(
875
		GTK_TOGGLE_BUTTON( ldapedit.check_matchoption), FALSE );
890
		GTK_TOGGLE_BUTTON( ldapedit.check_matchoption), FALSE );
876
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
891
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
877
	gtk_toggle_button_set_active(
892
	gtk_toggle_button_set_active(
Lines 935-940 static void edit_ldap_set_fields( LdapServer *server ) { Link Here
935
	gtk_toggle_button_set_active(
950
	gtk_toggle_button_set_active(
936
		GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch), server->searchFlag );
951
		GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch), server->searchFlag );
937
	gtk_toggle_button_set_active(
952
	gtk_toggle_button_set_active(
953
		GTK_TOGGLE_BUTTON( ldapedit.check_referrals), ctl->enableReferrals );
954
	gtk_toggle_button_set_active(
938
		GTK_TOGGLE_BUTTON( ldapedit.check_matchoption),
955
		GTK_TOGGLE_BUTTON( ldapedit.check_matchoption),
939
		( ctl->matchingOption == LDAPCTL_MATCH_CONTAINS ) );
956
		( ctl->matchingOption == LDAPCTL_MATCH_CONTAINS ) );
940
}
957
}
Lines 952-958 AdapterDSource *addressbook_edit_ldap( Link Here
952
	static gboolean cancelled;
969
	static gboolean cancelled;
953
	gchar *sName, *sHost, *sBase, *sBind, *sPass, *sCrit;
970
	gchar *sName, *sHost, *sBase, *sBind, *sPass, *sCrit;
954
	gint iPort, iMaxE, iTime, iAge;
971
	gint iPort, iMaxE, iTime, iAge;
955
	gboolean bSrch, bMatch;
972
	gboolean bSrch, bMatch, bReferrals;
956
	AddressDataSource *ds = NULL;
973
	AddressDataSource *ds = NULL;
957
	LdapServer *server = NULL;
974
	LdapServer *server = NULL;
958
	LdapControl *ctl = NULL;
975
	LdapControl *ctl = NULL;
Lines 1010-1015 AdapterDSource *addressbook_edit_ldap( Link Here
1010
			GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch ) );
1027
			GTK_TOGGLE_BUTTON( ldapedit.check_dynsearch ) );
1011
	bMatch = gtk_toggle_button_get_active(
1028
	bMatch = gtk_toggle_button_get_active(
1012
			GTK_TOGGLE_BUTTON( ldapedit.check_matchoption ) );
1029
			GTK_TOGGLE_BUTTON( ldapedit.check_matchoption ) );
1030
	bReferrals = gtk_toggle_button_get_active(
1031
			GTK_TOGGLE_BUTTON( ldapedit.check_referrals ) );
1013
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
1032
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
1014
	ssl = gtk_toggle_button_get_active(
1033
	ssl = gtk_toggle_button_get_active(
1015
			GTK_TOGGLE_BUTTON( ldapedit.enable_ssl ) );
1034
			GTK_TOGGLE_BUTTON( ldapedit.enable_ssl ) );
Lines 1046-1051 AdapterDSource *addressbook_edit_ldap( Link Here
1046
		ldapctl_set_max_query_age( ctl, iAge );
1065
		ldapctl_set_max_query_age( ctl, iAge );
1047
		ldapctl_set_tls( ctl, tls );
1066
		ldapctl_set_tls( ctl, tls );
1048
		ldapctl_set_ssl( ctl, ssl );
1067
		ldapctl_set_ssl( ctl, ssl );
1068
		ldapctl_set_referrals( ctl, bReferrals );
1049
		ldapctl_set_matching_option(
1069
		ldapctl_set_matching_option(
1050
			ctl, bMatch ?
1070
			ctl, bMatch ?
1051
			LDAPCTL_MATCH_CONTAINS : LDAPCTL_MATCH_BEGINWITH );
1071
			LDAPCTL_MATCH_CONTAINS : LDAPCTL_MATCH_BEGINWITH );
(-)src/ldapctrl.c (+13 lines)
Lines 65-70 LdapControl *ldapctl_create( void ) { Link Here
65
	ctl->version = 0;
65
	ctl->version = 0;
66
	ctl->enableTLS = FALSE;
66
	ctl->enableTLS = FALSE;
67
	ctl->enableSSL = FALSE;
67
	ctl->enableSSL = FALSE;
68
	ctl->enableReferrals = FALSE;
68
69
69
	/* Mutex to protect control block */
70
	/* Mutex to protect control block */
70
	ctl->mutexCtl = g_malloc0( sizeof( pthread_mutex_t ) );
71
	ctl->mutexCtl = g_malloc0( sizeof( pthread_mutex_t ) );
Lines 309-314 void ldapctl_set_ssl( LdapControl* ctl, const gboolean value ) { Link Here
309
}
310
}
310
311
311
/**
312
/**
313
 * Specify referrals option.
314
 * \param ctl   Control object to process.
315
 * \param value <i>TRUE</i> to enable referrals.
316
 */
317
void ldapctl_set_referrals( LdapControl* ctl, const gboolean value ) {
318
	ctl->enableReferrals = value;
319
	debug_print("setting referrals: %d\n", ctl->enableReferrals);
320
}
321
322
/**
312
 * Return search criteria list.
323
 * Return search criteria list.
313
 * \param  ctl  Control data object.
324
 * \param  ctl  Control data object.
314
 * \return Linked list of character strings containing LDAP attribute names to
325
 * \return Linked list of character strings containing LDAP attribute names to
Lines 440-445 void ldapctl_print( const LdapControl *ctl, FILE *stream ) { Link Here
440
	fprintf( stream, "  version: %d\n",   ctl->version );
451
	fprintf( stream, "  version: %d\n",   ctl->version );
441
	fprintf( stream, "      TLS: %s\n",   ctl->enableTLS ? "yes" : "no" );
452
	fprintf( stream, "      TLS: %s\n",   ctl->enableTLS ? "yes" : "no" );
442
	fprintf( stream, "      SSL: %s\n",   ctl->enableSSL ? "yes" : "no" );
453
	fprintf( stream, "      SSL: %s\n",   ctl->enableSSL ? "yes" : "no" );
454
	fprintf( stream, "referrals: %s\n",   ctl->enableReferrals ? "yes" : "no" );
443
	fprintf( stream, "crit list:\n" );
455
	fprintf( stream, "crit list:\n" );
444
	if( ctl->listCriteria ) {
456
	if( ctl->listCriteria ) {
445
		mgu_print_dlist( ctl->listCriteria, stream );
457
		mgu_print_dlist( ctl->listCriteria, stream );
Lines 498-503 void ldapctl_copy( const LdapControl *ctlFrom, LdapControl *ctlTo ) { Link Here
498
	ctlTo->version = ctlFrom->version;
510
	ctlTo->version = ctlFrom->version;
499
	ctlTo->enableTLS = ctlFrom->enableTLS;
511
	ctlTo->enableTLS = ctlFrom->enableTLS;
500
	ctlTo->enableSSL = ctlFrom->enableSSL;
512
	ctlTo->enableSSL = ctlFrom->enableSSL;
513
	ctlTo->enableReferrals = ctlFrom->enableReferrals;
501
514
502
	/* Unlock */
515
	/* Unlock */
503
	pthread_mutex_unlock( ctlTo->mutexCtl );
516
	pthread_mutex_unlock( ctlTo->mutexCtl );
(-)src/ldapctrl.h (+2 lines)
Lines 72-77 struct _LdapControl { Link Here
72
	gint      version;
72
	gint      version;
73
	gboolean  enableTLS;
73
	gboolean  enableTLS;
74
	gboolean  enableSSL;
74
	gboolean  enableSSL;
75
	gboolean  enableReferrals;
75
	gchar     *attribEMail;
76
	gchar     *attribEMail;
76
	gchar     *attribCName;
77
	gchar     *attribCName;
77
	gchar     *attribFName;
78
	gchar     *attribFName;
Lines 96-101 void ldapctl_set_max_query_age ( LdapControl* ctl, const gint value ); Link Here
96
void ldapctl_set_matching_option( LdapControl* ctl, const gint value );
97
void ldapctl_set_matching_option( LdapControl* ctl, const gint value );
97
void ldapctl_set_tls		( LdapControl* ctl, const gboolean value );
98
void ldapctl_set_tls		( LdapControl* ctl, const gboolean value );
98
void ldapctl_set_ssl		( LdapControl* ctl, const gboolean value );
99
void ldapctl_set_ssl		( LdapControl* ctl, const gboolean value );
100
void ldapctl_set_referrals	( LdapControl* ctl, const gboolean value );
99
GList *ldapctl_get_criteria_list( const LdapControl* ctl );
101
GList *ldapctl_get_criteria_list( const LdapControl* ctl );
100
void ldapctl_criteria_list_clear( LdapControl *ctl );
102
void ldapctl_criteria_list_clear( LdapControl *ctl );
101
void ldapctl_criteria_list_add	( LdapControl *ctl, gchar *attr );
103
void ldapctl_criteria_list_add	( LdapControl *ctl, gchar *attr );
(-)src/ldapserver.c (+11 lines)
Lines 758-763 LDAP *ldapsvr_connect(LdapControl *ctl) { Link Here
758
	LDAP *ld = NULL;
758
	LDAP *ld = NULL;
759
	gint rc;
759
	gint rc;
760
	gint version;
760
	gint version;
761
	gint *referrals;
761
	gchar *uri = NULL;
762
	gchar *uri = NULL;
762
	gchar *pwd;
763
	gchar *pwd;
763
764
Lines 814-819 LDAP *ldapsvr_connect(LdapControl *ctl) { Link Here
814
		g_printerr("LDAP: Error %d (%s)\n",
815
		g_printerr("LDAP: Error %d (%s)\n",
815
			rc, ldaputil_get_error(ld));
816
			rc, ldaputil_get_error(ld));
816
817
818
	/* Handle referrals */
819
	referrals = ctl->enableReferrals ? LDAP_OPT_ON : LDAP_OPT_OFF;
820
	debug_print("Setting LDAP_OPT_REFERRALS to %d\n", ctl->enableReferrals);
821
	rc = ldap_set_option(ld, LDAP_OPT_REFERRALS, referrals);
822
	if (rc != LDAP_SUCCESS) {
823
		g_printerr("LDAP Error: ldap_set_option: %d %s\n",
824
			rc, ldaputil_get_error(ld));
825
		return NULL;
826
	}
827
817
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
828
#if (defined USE_LDAP_TLS || defined G_OS_WIN32)
818
	/* Handle TLS */
829
	/* Handle TLS */
819
	if (ctl->version == LDAP_VERSION3) {
830
	if (ctl->version == LDAP_VERSION3) {

Return to bug 3333