[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: LDAP with KAddressBook help (+PATCH)
From:       Michael Goffioul <goffioul () imec ! be>
Date:       2003-01-31 12:35:32
[Download RAW message or body]

> I'm trying to make kaddressbook aware of our ldap server at work.
> Evrrything works fine withint Netscape. I added a LDAP resource
> in KControl->Components->Address Book, but to make it run, I fixed
> 2 crashes (see patch attached).

Sorry, forgot the patch.

-- 
------------------------------------------------------------------
Michael Goffioul		IMEC-DESICS-MIRA
e-mail: goffioul@imec.be	(Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510		Kapeldreef, 75
Fax:    +32/16/28-1515		3001 HEVERLEE, BELGIUM
------------------------------------------------------------------
This e-mail and/or its attachments may contain confidential
information.  It is intended solely for the intended addressee(s). 
Any use of the information contained herein by other persons is
prohibited.  IMEC vzw does not accept any liability for the contents
of this e-mail and/or its attachments.
------------------------------------------------------------------
["ldap.diff" (text/plain)]

Index: resourceldap.cpp
===================================================================
RCS file: /home/kde/kdelibs/kabc/plugins/ldap/resourceldap.cpp,v
retrieving revision 1.18
diff -u -3 -p -r1.18 resourceldap.cpp
--- resourceldap.cpp	5 Jan 2003 17:33:40 -0000	1.18
+++ resourceldap.cpp	31 Jan 2003 12:35:09 -0000
@@ -50,6 +50,7 @@ ResourceLDAP::ResourceLDAP( const KConfi
 {
   mLdap = 0;
 
+  if ( config ) {
   mUser = config->readEntry( "LdapUser" );
   mPassword = decryptStr( config->readEntry( "LdapPassword" ) );
   mDn = config->readEntry( "LdapDn" );
@@ -57,6 +58,7 @@ ResourceLDAP::ResourceLDAP( const KConfi
   mPort = config->readNumEntry( "LdapPort", 389 );
   mFilter = config->readEntry( "LdapFilter" );
   mAnonymous = config->readBoolEntry( "LdapAnonymous" );
+  }
 }
 
 void ResourceLDAP::writeConfig( KConfig *config )
@@ -84,6 +86,8 @@ Ticket *ResourceLDAP::requestSaveTicket(
 
 bool ResourceLDAP::doOpen()
 {
+  kdDebug(5700) << "Connecting to LDAP server " << mHost << endl;
+
   if ( mLdap )
 	  return false;
 
@@ -131,6 +135,9 @@ void ResourceLDAP::doClose()
 
 bool ResourceLDAP::load()
 {
+  if (!open())
+	return false;
+
   LDAPMessage *res;
   LDAPMessage *msg;
   BerElement *track;
@@ -148,9 +155,10 @@ bool ResourceLDAP::load()
     "uid",
     0 };
 
-  if ( ldap_search_s( mLdap, mDn.local8Bit(), LDAP_SCOPE_SUBTREE, QString( "(%1)" \
                ).arg( mFilter ).local8Bit(),
-      (char **)LdapSearchAttr, 0, &res ) != LDAP_SUCCESS ) {
-    addressBook()->error( i18n( "Unable to search on server '%1'" ).arg( mHost ) );
+  int result;
+  if ( ( result = ldap_search_s( mLdap, mDn.local8Bit(), LDAP_SCOPE_SUBTREE, \
QString( "(%1)" ).arg( mFilter ).local8Bit(), +      (char **)LdapSearchAttr, 0, &res \
) != LDAP_SUCCESS ) ) { +    addressBook()->error( i18n( "Unable to search on server \
'%1': %2" ).arg( mHost ).arg( ldap_err2string( result ) ) );  return false;
   }
 


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic