Addressbook now uses password store for LDAP passwords.
[claws.git] / src / addrindex.c
index 307527faa04d4e9a705c68af389c3d0d6037dccc..f102e96c8d8307853d70022be670ecae361dc2ed 100644 (file)
@@ -42,6 +42,7 @@
 #include "addr_compl.h"
 #include "utils.h"
 #include "alertpanel.h"
+#include "passwordstore.h"
 
 #ifndef DEV_STANDALONE
 #include "prefs_gtk.h"
@@ -1354,6 +1355,7 @@ static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) {
        gboolean bDynSearch;
        gboolean bTLS, bSSL;
        gint iMatch;
+       gchar *password = NULL;
 
        /* g_print( "addrindex_parse_ldap\n" ); */
        /* Set up some defaults */
@@ -1387,7 +1389,7 @@ static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) {
                        ldapctl_set_bind_dn( ctl, value );
                }
                else if( strcmp( name, ATTAG_LDAP_BIND_PASS ) == 0 ) {
-                       ldapctl_set_bind_password( ctl, value, FALSE, FALSE );
+                       password = value;
                }
                else if( strcmp( name, ATTAG_LDAP_CRITERIA ) == 0 ) {
                        g_free( criteria );
@@ -1430,6 +1432,9 @@ static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) {
                attr = g_list_next( attr );
        }
 
+       if (password != NULL)
+               passwd_store_set(PWS_CORE, "LDAP", ctl->hostName, password, TRUE);
+
        server = ldapsvr_create_noctl();
        ldapsvr_set_name( server, serverName );
        ldapsvr_set_search_flag( server, bDynSearch );
@@ -1484,8 +1489,6 @@ static int addrindex_write_ldap( FILE *fp, AddressDataSource *ds, gint lvl ) {
                return -1;
        if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_DN, ctl->bindDN ) < 0)
                return -1;
-       if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_PASS, ctl->bindPass ) < 0)
-               return -1;
 
        sprintf( value, "%d", ctl->maxEntries );
        if (addrindex_write_attr( fp, ATTAG_LDAP_MAX_ENTRY, value ) < 0)