From 1360ed940550a21082ca8540ff0256d3c88be746 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 9 May 2007 20:59:44 +0000 Subject: [PATCH 1/4] Monotone-Parent: d31a045aea36312935ee1173ab031b085b099751 Monotone-Revision: f0287a95426d09a97daa0041135b4177737819c6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-09T20:59:44 Monotone-Branch: ca.inverse.sogo --- SoObjects/Contacts/SOGoContactLDIFEntry.h | 1 - 1 file changed, 1 deletion(-) diff --git a/SoObjects/Contacts/SOGoContactLDIFEntry.h b/SoObjects/Contacts/SOGoContactLDIFEntry.h index 4ae5607d8..0fe338288 100644 --- a/SoObjects/Contacts/SOGoContactLDIFEntry.h +++ b/SoObjects/Contacts/SOGoContactLDIFEntry.h @@ -34,7 +34,6 @@ NSString *name; NSDictionary *ldifEntry; NGVCard *vcard; - id container; } + (SOGoContactLDIFEntry *) contactEntryWithName: (NSString *) newName From 6112384842791b8d2a1c587d47e1854b6583b844 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 10 May 2007 14:56:47 +0000 Subject: [PATCH 2/4] Monotone-Parent: f0287a95426d09a97daa0041135b4177737819c6 Monotone-Revision: 9c8fadcccf096acb0cb35206831736703fec1558 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-10T14:56:47 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 12 +++++ SoObjects/SOGo/LDAPSource.m | 100 ++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad7219dc2..9c77061b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-05-10 Wolfgang Sourdeau + + * SoObjects/SOGo/LDAPSource.m ([LDAPSource + -checkLogin:loginToCheckandPassword:passwordToCheck]): check that + loginToCheck is not empty. + ([LDAPSource -fetchContactsMatching:match]): check that match is + not empty. + ([LDAPSource -lookupContactEntry:entryID]): check that entryID is + not empty. + ([LDAPSource -lookupContactEntryWithUIDorEmail:uid]): check that + uid is not empty. + 2007-05-09 Wolfgang Sourdeau * SoObjects/SOGo/SOGoUser.m ([SOGoUser -primaryEmail]): new name diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 9b9390662..51fdadaf7 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -215,18 +215,23 @@ static NSArray *commonSearchFields; NSString *userDN; NGLdapConnection *bindConnection; - bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname - port: port]; - userDN = [NSString stringWithFormat: @"%@=%@,%@", - IDField, loginToCheck, baseDN]; - NS_DURING - didBind = [bindConnection bindWithMethod: @"simple" binddn: userDN - credentials: passwordToCheck]; - NS_HANDLER - didBind = NO; - NS_ENDHANDLER + if ([loginToCheck length] > 0) + { + bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname + port: port]; + userDN = [NSString stringWithFormat: @"%@=%@,%@", + IDField, loginToCheck, baseDN]; + NS_DURING + didBind = [bindConnection bindWithMethod: @"simple" binddn: userDN + credentials: passwordToCheck]; + NS_HANDLER + didBind = NO; + NS_ENDHANDLER - [bindConnection release]; + [bindConnection release]; + } + else + didBind = NO; return didBind; } @@ -237,7 +242,7 @@ static NSArray *commonSearchFields; NSString *qs; EOQualifier *qualifier; - if (filter && [filter length] > 0) + if ([filter length] > 0) { if ([filter isEqualToString: @"."]) qs = @"(cn='*')"; @@ -355,19 +360,22 @@ static NSArray *commonSearchFields; contacts = [NSMutableArray array]; - if (!ldapConnection) - [self _initLDAPConnection]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: [self _qualifierForFilter: match] - attributes: [self _searchAttributes]]; - if (entries) + if ([match length] > 0) { - currentEntry = [entries nextObject]; - while (currentEntry) + if (!ldapConnection) + [self _initLDAPConnection]; + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: [self _qualifierForFilter: match] + attributes: [self _searchAttributes]]; + if (entries) { - [contacts addObject: - [self _convertLDAPEntryToContact: currentEntry]]; currentEntry = [entries nextObject]; + while (currentEntry) + { + [contacts addObject: + [self _convertLDAPEntryToContact: currentEntry]]; + currentEntry = [entries nextObject]; + } } } @@ -379,16 +387,19 @@ static NSArray *commonSearchFields; NSDictionary *contactEntry; NGLdapEntry *ldapEntry; - if (!ldapConnection) - [self _initLDAPConnection]; - ldapEntry - = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@", - IDField, entryID, baseDN] - attributes: [self _searchAttributes]]; - if (ldapEntry) - contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; - else - contactEntry = nil; + contactEntry = nil; + + if ([entryID length] > 0) + { + if (!ldapConnection) + [self _initLDAPConnection]; + ldapEntry + = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@", + IDField, entryID, baseDN] + attributes: [self _searchAttributes]]; + if (ldapEntry) + contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; + } return contactEntry; } @@ -400,17 +411,20 @@ static NSArray *commonSearchFields; NSEnumerator *entries; EOQualifier *qualifier; - if (!ldapConnection) - [self _initLDAPConnection]; - qualifier = [self _qualifierForUIDFilter: uid]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: qualifier - attributes: [self _searchAttributes]]; - ldapEntry = [entries nextObject]; - if (ldapEntry) - contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; - else - contactEntry = nil; + contactEntry = nil; + + if ([uid length] > 0) + { + if (!ldapConnection) + [self _initLDAPConnection]; + qualifier = [self _qualifierForUIDFilter: uid]; + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: [self _searchAttributes]]; + ldapEntry = [entries nextObject]; + if (ldapEntry) + contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; + } return contactEntry; } From aade431284f3c79ac46bf90e1d7d4993206caaea Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 10 May 2007 14:59:13 +0000 Subject: [PATCH 3/4] Monotone-Parent: 9c8fadcccf096acb0cb35206831736703fec1558 Monotone-Revision: 7115767efc793f96f9d75e98d9e930968538bb9b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-10T14:59:13 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 ++ SoObjects/SOGo/LDAPUserManager.m | 50 ++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c77061b9..ad92d7c78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-05-10 Wolfgang Sourdeau + * SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager + -contactInfosForUserWithUIDorEmail:uid]): check that uid is not empty. + * SoObjects/SOGo/LDAPSource.m ([LDAPSource -checkLogin:loginToCheckandPassword:passwordToCheck]): check that loginToCheck is not empty. diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index 6cfe52c07..66b193564 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -179,6 +179,7 @@ static NSString *defaultMailDomain = nil; { NSDictionary *contactInfos; +// NSLog (@"getCNForUID: %@", uid); contactInfos = [self contactInfosForUserWithUIDorEmail: uid]; return [contactInfos objectForKey: @"cn"]; @@ -188,6 +189,7 @@ static NSString *defaultMailDomain = nil; { NSDictionary *contactInfos; +// NSLog (@"getEmailForUID: %@", uid); contactInfos = [self contactInfosForUserWithUIDorEmail: uid]; return [contactInfos objectForKey: @"c_email"]; @@ -197,6 +199,7 @@ static NSString *defaultMailDomain = nil; { NSDictionary *contactInfos; +// NSLog (@"getUIDForEmail: %@", email); contactInfos = [self contactInfosForUserWithUIDorEmail: email]; return [contactInfos objectForKey: @"c_uid"]; @@ -342,29 +345,39 @@ static NSString *defaultMailDomain = nil; NSDate *cleanupDate; BOOL newUser; - contactInfos = [NSMutableDictionary dictionary]; - currentUser = [users objectForKey: uid]; - if (!([currentUser objectForKey: @"emails"] - && [currentUser objectForKey: @"cn"])) + if ([uid length] > 0) { - if (!currentUser) + contactInfos = [NSMutableDictionary dictionary]; + currentUser = [users objectForKey: uid]; + if (!([currentUser objectForKey: @"emails"] + && [currentUser objectForKey: @"cn"])) { - newUser = YES; - currentUser = [NSMutableDictionary dictionary]; + if (!currentUser) + { + newUser = YES; + currentUser = [NSMutableDictionary dictionary]; + } + else + newUser = NO; + [self _fillContactInfosForUser: currentUser + withUIDorEmail: uid]; + if (newUser) + { + if ([[currentUser objectForKey: @"c_uid"] length] > 0) + [self _retainUser: currentUser]; + else + currentUser = nil; + } } - else - newUser = NO; - [self _fillContactInfosForUser: currentUser - withUIDorEmail: uid]; - if (newUser) - [self _retainUser: currentUser]; - } - if (cleanupInterval) - { - cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval]; - [currentUser setObject: cleanupDate forKey: @"cleanupDate"]; + if (cleanupInterval && currentUser) + { + cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval]; + [currentUser setObject: cleanupDate forKey: @"cleanupDate"]; + } } + else + currentUser = nil; return currentUser; } @@ -438,7 +451,6 @@ static NSString *defaultMailDomain = nil; LDAPSource *currentSource; contacts = [NSMutableArray array]; - ldapSources = [sources objectEnumerator]; currentSource = [ldapSources nextObject]; while (currentSource) From 1b42d71b1d5db383a667f5ad08cf0329a0ddca05 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 10 May 2007 14:59:17 +0000 Subject: [PATCH 4/4] Monotone-Parent: 7115767efc793f96f9d75e98d9e930968538bb9b Monotone-Revision: 8fac7610f102d5ac190598b120634569a69ec344 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-10T14:59:17 Monotone-Branch: ca.inverse.sogo --- UI/Contacts/UIxContactEditor.m | 1 + UI/MainUI/SOGoUserHomePage.m | 1 + 2 files changed, 2 insertions(+) diff --git a/UI/Contacts/UIxContactEditor.m b/UI/Contacts/UIxContactEditor.m index 67d2d6b22..4341f4ede 100644 --- a/UI/Contacts/UIxContactEditor.m +++ b/UI/Contacts/UIxContactEditor.m @@ -19,6 +19,7 @@ 02111-1307, USA. */ +#import #import #import diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index cbab37612..65833f887 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -22,6 +22,7 @@ #import #import +#import #import #import #import