Change mention of "mydomain.com" to "example.org".
[claws.git] / src / editldap.c
index f9ebb5b09382da21465f5426e3984d709b43c832..c2ee14d2df7186f1c03aacf18d743ed6ba2e0bb2 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2013 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2015 Match Grun and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 /*
@@ -46,6 +45,7 @@
 #include "manage_window.h"
 #include "gtkutils.h"
 #include "prefs_gtk.h"
+#include "passwordstore.h"
 
 #define PAGE_BASIC      0
 #define PAGE_SEARCH     1
@@ -236,9 +236,9 @@ static void edit_ldap_server_check( void ) {
        ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ldapedit.enable_ssl));
 #endif
 
-       g_strchomp( sHost ); g_strchug( sHost );
-       g_strchomp( sBind ); g_strchug( sBind );
-       g_strchomp( sPass ); g_strchug( sPass );
+       g_strstrip( sHost );
+       g_strstrip( sBind );
+       g_strstrip( sPass );
        if( *sHost != '\0' ) {
                /* Test connection to server */
                debug_print("ldap server: %s\nport: %d\nssl: %d\ntls: %d\nbindDN: %s\n", sHost, iPort, ssl, tls, sBind);
@@ -299,9 +299,9 @@ static void edit_ldap_basedn_select( void ) {
        ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ldapedit.enable_ssl));
 #endif
 
-       g_strchomp( sHost ); g_strchug( sHost );
-       g_strchomp( sBind ); g_strchug( sBind );
-       g_strchomp( sPass ); g_strchug( sPass );
+       g_strstrip( sHost );
+       g_strstrip( sBind );
+       g_strstrip( sPass );
        debug_print("ldap server: %s\nport: %d\nssl: %d\ntls: %d\nbindDN: %s\n", sHost, iPort, ssl, tls, sBind);
        selectDN = edit_ldap_basedn_selection( sHost, iPort, sBase, iTime, sBind, sPass, ssl, tls );
        if( selectDN ) {
@@ -448,8 +448,8 @@ static void addressbook_edit_ldap_page_basic( gint pageNum, gchar *pageLbl ) {
 
        CLAWS_SET_TIP(entry_server, _( 
                "This is the hostname of the server. For example, " \
-               "\"ldap.mydomain.com\" may be appropriate for the " \
-               "\"mydomain.com\" organization. An IP address may also be " \
+               "\"ldap.example.org\" may be appropriate for the " \
+               "\"exmaple.org\" organization. An IP address may also be " \
                "used. You may specify \"localhost\" if running an LDAP " \
                "server on the same computer as Claws Mail." ));
 
@@ -480,9 +480,7 @@ static void addressbook_edit_ldap_page_basic( gint pageNum, gchar *pageLbl ) {
                "If connection fails, be sure to check the correct "
                "configuration in ldap.conf (TLS_CACERTDIR and TLS_REQCERT fields)." ));
 
-#ifdef G_OS_UNIX /* Win32's ldap_start_tls_s() does not work, for some reason. */
        gtk_box_pack_start (GTK_BOX (hbox_spin), enable_tls_checkbtn, TRUE, FALSE, 0);
-#endif
        gtk_box_pack_start (GTK_BOX (hbox_spin), enable_ssl_checkbtn, TRUE, FALSE, 0);
 #endif
 
@@ -888,7 +886,6 @@ static void edit_ldap_clear_fields(void) {
 static void edit_ldap_set_fields( LdapServer *server ) {
        LdapControl *ctl;
        gchar *crit;
-       gchar *pwd;
 
        if( ldapsvr_get_name( server ) )
                gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_name),
@@ -904,11 +901,8 @@ static void edit_ldap_set_fields( LdapServer *server ) {
        if( ctl->bindDN )
                gtk_entry_set_text(
                        GTK_ENTRY(ldapedit.entry_bindDN), ctl->bindDN );
-       if( ctl->bindPass ) {
-               pwd = ldapctl_get_bind_password( ctl );
-               gtk_entry_set_text(     GTK_ENTRY(ldapedit.entry_bindPW),  pwd );
-               g_free(pwd);
-       }
+       gtk_entry_set_text(     GTK_ENTRY(ldapedit.entry_bindPW),
+                       passwd_store_get(PWS_CORE, "LDAP", ctl->hostName));
        gtk_spin_button_set_value(
                GTK_SPIN_BUTTON(ldapedit.spinbtn_timeout), ctl->timeOut );
        gtk_spin_button_set_value(
@@ -1039,7 +1033,6 @@ AdapterDSource *addressbook_edit_ldap(
                ldapctl_set_host( ctl, sHost );
                ldapctl_set_base_dn( ctl, sBase );
                ldapctl_set_bind_dn( ctl, sBind );
-               ldapctl_set_bind_password( ctl, sPass, TRUE, TRUE );
                ldapctl_set_port( ctl, iPort );
                ldapctl_set_max_entries( ctl, iMaxE );
                ldapctl_set_timeout( ctl, iTime );
@@ -1052,6 +1045,9 @@ AdapterDSource *addressbook_edit_ldap(
 
                addrindex_save_data(addrIndex);
 
+               passwd_store_set(PWS_CORE, "LDAP", sHost, sPass, FALSE);
+               passwd_store_write_config();
+
                /* Save attributes */
                editldap_parse_criteria( sCrit, ctl );
 
@@ -1060,9 +1056,12 @@ AdapterDSource *addressbook_edit_ldap(
        g_free( sHost );
        g_free( sBase );
        g_free( sBind );
-       g_free( sPass );
        g_free( sCrit );
 
+       if (sPass != NULL && strlen(sPass) > 0)
+               memset(sPass, 0, strlen(sPass));
+       g_free( sPass );
+
        return ads;
 }