Monotone-Parent: 7df1edc5e4fb86c8fe01354ff89b73239e5a4e37
Monotone-Revision: 4ac298b0202fa194faaffcdf551137eb8bdd429b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-29T21:48:00 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
43dfb25589
commit
bdb9169442
|
@ -1,5 +1,11 @@
|
|||
2009-11-29 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoUserManager.m
|
||||
(-authenticationSourceIDsInDomain:): now takes a domain argument.
|
||||
Contrarily to contact sources, specifying a domain will cause the
|
||||
generic sources to be ignored.
|
||||
(-fetchUsersMatching:inDomain:): now takes a domain argument.
|
||||
|
||||
* SoObjects/SOGo/LDAPSource.m (-initFromUDSource:inDomain):
|
||||
removed handing of "domain attribute", since the underlying
|
||||
mechanism causes complex code for an unrealistic case.
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
|
||||
NSString *domain;
|
||||
NSString *contactInfoAttribute;
|
||||
NSString *domainAttribute;
|
||||
|
||||
NSDictionary *modulesConstraints;
|
||||
|
||||
|
|
|
@ -207,21 +207,24 @@
|
|||
- (NSDictionary *) foldersOfType: (NSString *) type
|
||||
matchingUID: (NSString *) uid
|
||||
{
|
||||
NSArray *contacts, *folders;
|
||||
NSArray *users, *folders;
|
||||
NSString *domain;
|
||||
NSEnumerator *enumerator;
|
||||
NSDictionary *contact;
|
||||
NSDictionary *user;
|
||||
NSMutableDictionary *results;
|
||||
|
||||
results = [NSMutableDictionary dictionary];
|
||||
|
||||
contacts = [[SOGoUserManager sharedUserManager] fetchUsersMatching: uid];
|
||||
enumerator = [contacts objectEnumerator];
|
||||
while ((contact = [enumerator nextObject]))
|
||||
domain = [[SOGoUser userWithLogin: owner] domain];
|
||||
users = [[SOGoUserManager sharedUserManager] fetchUsersMatching: uid
|
||||
inDomain: domain];
|
||||
enumerator = [users objectEnumerator];
|
||||
while ((user = [enumerator nextObject]))
|
||||
{
|
||||
uid = [contact objectForKey: @"c_uid"];
|
||||
uid = [user objectForKey: @"c_uid"];
|
||||
folders = [self foldersOfType: type
|
||||
forUID: [contact objectForKey: @"c_uid"]];
|
||||
[results setObject: folders forKey: contact];
|
||||
forUID: [user objectForKey: @"c_uid"]];
|
||||
[results setObject: folders forKey: user];
|
||||
}
|
||||
|
||||
return results;
|
||||
|
@ -312,15 +315,16 @@
|
|||
- (NSArray *) _searchDavOwners: (NSString *) davOwnerMatch
|
||||
{
|
||||
NSArray *users, *owners;
|
||||
NSString *ownerMatch;
|
||||
NSString *ownerMatch, *domain;
|
||||
SOGoUserManager *um;
|
||||
|
||||
owners = [NSMutableArray array];
|
||||
if (davOwnerMatch)
|
||||
{
|
||||
ownerMatch = [self _userFromDAVuser: davOwnerMatch];
|
||||
domain = [[SOGoUser userWithLogin: owner] domain];
|
||||
um = [SOGoUserManager sharedUserManager];
|
||||
users = [[um fetchUsersMatching: ownerMatch]
|
||||
users = [[um fetchUsersMatching: ownerMatch inDomain: domain]
|
||||
sortedArrayUsingSelector: @selector (caseInsensitiveDisplayNameCompare:)];
|
||||
owners = [users objectsForKey: @"c_uid" notFoundMarker: nil];
|
||||
}
|
||||
|
@ -379,7 +383,7 @@
|
|||
SOGoUserManager *um;
|
||||
NSMutableString *fetch;
|
||||
NSDictionary *currentUser;
|
||||
NSString *field, *login;
|
||||
NSString *field, *login, *domain;
|
||||
NSArray *users;
|
||||
int i;
|
||||
|
||||
|
@ -389,9 +393,10 @@
|
|||
login = [[context activeUser] login];
|
||||
um = [SOGoUserManager sharedUserManager];
|
||||
|
||||
domain = [[context activeUser] domain];
|
||||
// We sort our array - this is pretty useful for the
|
||||
// SOGo Integrator extension, among other things.
|
||||
users = [[um fetchUsersMatching: user]
|
||||
users = [[um fetchUsersMatching: user inDomain: domain]
|
||||
sortedArrayUsingSelector: @selector (caseInsensitiveDisplayNameCompare:)];
|
||||
for (i = 0; i < [users count]; i++)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
+ (id) sharedUserManager;
|
||||
|
||||
- (NSArray *) sourceIDsInDomain: (NSString *) domain;
|
||||
- (NSArray *) authenticationSourceIDs;
|
||||
- (NSArray *) authenticationSourceIDsInDomain: (NSString *) domain;
|
||||
- (NSArray *) addressBookSourceIDsInDomain: (NSString *) domain;
|
||||
|
||||
- (NSObject <SOGoSource> *) sourceWithID: (NSString *) sourceID;
|
||||
|
@ -54,7 +54,8 @@
|
|||
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid;
|
||||
- (NSArray *) fetchContactsMatching: (NSString *) match
|
||||
inDomain: (NSString *) domain;
|
||||
- (NSArray *) fetchUsersMatching: (NSString *) filter;
|
||||
- (NSArray *) fetchUsersMatching: (NSString *) filter
|
||||
inDomain: (NSString *) domain;
|
||||
|
||||
- (NSString *) getCNForUID: (NSString *) uid;
|
||||
- (NSString *) getEmailForUID: (NSString *) uid;
|
||||
|
|
|
@ -184,39 +184,13 @@
|
|||
currentID = [keys objectAtIndex: count];
|
||||
currentSource = [_sources objectForKey: currentID];
|
||||
sourceDomain = [currentSource domain];
|
||||
if (!domain || [sourceDomain isEqualToString: domain])
|
||||
if (![sourceDomain length] || [sourceDomain isEqualToString: domain])
|
||||
[sourceIDs addObject: currentID];
|
||||
}
|
||||
|
||||
return sourceIDs;
|
||||
}
|
||||
|
||||
- (NSArray *) _sourcesOfType: (NSString *) sourceType
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSMutableArray *sourceIDs;
|
||||
NSEnumerator *allIDs;
|
||||
NSString *currentID;
|
||||
NSNumber *typeValue;
|
||||
NSDictionary *metadata;
|
||||
|
||||
sourceIDs = [NSMutableArray array];
|
||||
allIDs = [[_sources allKeys] objectEnumerator];
|
||||
while ((currentID = [allIDs nextObject]))
|
||||
{
|
||||
metadata = [_sourcesMetadata objectForKey: currentID];
|
||||
if (!domain
|
||||
|| [[metadata objectForKey: @"domain"] isEqualToString: domain])
|
||||
{
|
||||
typeValue = [metadata objectForKey: sourceType];
|
||||
if ([typeValue boolValue])
|
||||
[sourceIDs addObject: currentID];
|
||||
}
|
||||
}
|
||||
|
||||
return sourceIDs;
|
||||
}
|
||||
|
||||
- (NSObject <SOGoSource> *) sourceWithID: (NSString *) sourceID
|
||||
{
|
||||
return [_sources objectForKey: sourceID];
|
||||
|
@ -227,14 +201,46 @@
|
|||
return [_sourcesMetadata objectForKey: sourceID];
|
||||
}
|
||||
|
||||
- (NSArray *) authenticationSourceIDs
|
||||
- (NSArray *) authenticationSourceIDsInDomain: (NSString *) domain
|
||||
{
|
||||
return [self _sourcesOfType: @"canAuthenticate" inDomain: nil];
|
||||
NSMutableArray *sourceIDs;
|
||||
NSEnumerator *allIDs;
|
||||
NSString *currentID, *sourceDomain;
|
||||
NSDictionary *metadata;
|
||||
|
||||
sourceIDs = [NSMutableArray array];
|
||||
allIDs = [[_sources allKeys] objectEnumerator];
|
||||
while ((currentID = [allIDs nextObject]))
|
||||
{
|
||||
sourceDomain = [[_sources objectForKey: currentID] domain];
|
||||
if (![domain length] || [domain isEqualToString: sourceDomain])
|
||||
{
|
||||
metadata = [_sourcesMetadata objectForKey: currentID];
|
||||
if ([[metadata objectForKey: @"canAuthenticate"] boolValue])
|
||||
[sourceIDs addObject: currentID];
|
||||
}
|
||||
}
|
||||
|
||||
return sourceIDs;
|
||||
}
|
||||
|
||||
- (NSArray *) addressBookSourceIDsInDomain: (NSString *) domain
|
||||
{
|
||||
return [self _sourcesOfType: @"isAddressBook" inDomain: domain];
|
||||
NSMutableArray *sourceIDs;
|
||||
NSEnumerator *allIDs;
|
||||
NSString *currentID;
|
||||
NSDictionary *metadata;
|
||||
|
||||
sourceIDs = [NSMutableArray array];
|
||||
allIDs = [[self sourceIDsInDomain: domain] objectEnumerator];
|
||||
while ((currentID = [allIDs nextObject]))
|
||||
{
|
||||
metadata = [_sourcesMetadata objectForKey: currentID];
|
||||
if ([[metadata objectForKey: @"isAddressBook"] boolValue])
|
||||
[sourceIDs addObject: currentID];
|
||||
}
|
||||
|
||||
return sourceIDs;
|
||||
}
|
||||
|
||||
- (NSString *) displayNameForSourceWithID: (NSString *) sourceID
|
||||
|
@ -310,10 +316,10 @@
|
|||
NSEnumerator *authIDs;
|
||||
NSString *currentID;
|
||||
BOOL checkOK;
|
||||
|
||||
|
||||
checkOK = NO;
|
||||
|
||||
authIDs = [[self authenticationSourceIDs] objectEnumerator];
|
||||
authIDs = [[self authenticationSourceIDsInDomain: nil] objectEnumerator];
|
||||
while (!checkOK && (currentID = [authIDs nextObject]))
|
||||
{
|
||||
ldapSource = [_sources objectForKey: currentID];
|
||||
|
@ -388,13 +394,14 @@
|
|||
NSDictionary *userEntry;
|
||||
NSEnumerator *ldapSources;
|
||||
LDAPSource *currentSource;
|
||||
NSString *sourceID, *cn, *c_uid, *c_imaphostname;
|
||||
NSString *sourceID, *cn, *c_domain, *c_uid, *c_imaphostname;
|
||||
NSArray *c_emails;
|
||||
BOOL access;
|
||||
|
||||
emails = [NSMutableArray array];
|
||||
cn = nil;
|
||||
c_uid = nil;
|
||||
c_domain = nil;
|
||||
c_imaphostname = nil;
|
||||
|
||||
[currentUser setObject: [NSNumber numberWithBool: YES]
|
||||
|
@ -402,7 +409,7 @@
|
|||
[currentUser setObject: [NSNumber numberWithBool: YES]
|
||||
forKey: @"MailAccess"];
|
||||
|
||||
ldapSources = [[self authenticationSourceIDs]
|
||||
ldapSources = [[self authenticationSourceIDsInDomain: nil]
|
||||
objectEnumerator];
|
||||
while ((sourceID = [ldapSources nextObject]))
|
||||
{
|
||||
|
@ -414,6 +421,8 @@
|
|||
cn = [userEntry objectForKey: @"c_cn"];
|
||||
if (!c_uid)
|
||||
c_uid = [userEntry objectForKey: @"c_uid"];
|
||||
if (!c_domain)
|
||||
c_domain = [userEntry objectForKey: @"c_domain"];
|
||||
c_emails = [userEntry objectForKey: @"c_emails"];
|
||||
if ([c_emails count])
|
||||
[emails addObjectsFromArray: c_emails];
|
||||
|
@ -434,12 +443,15 @@
|
|||
cn = @"";
|
||||
if (!c_uid)
|
||||
c_uid = @"";
|
||||
if (!c_domain)
|
||||
c_domain = @"";
|
||||
|
||||
if (c_imaphostname)
|
||||
[currentUser setObject: c_imaphostname forKey: @"c_imaphostname"];
|
||||
[currentUser setObject: emails forKey: @"emails"];
|
||||
[currentUser setObject: cn forKey: @"cn"];
|
||||
[currentUser setObject: c_uid forKey: @"c_uid"];
|
||||
[currentUser setObject: c_domain forKey: @"c_domain"];
|
||||
|
||||
// If our LDAP queries gave us nothing, we add at least one default
|
||||
// email address based on the default domain.
|
||||
|
@ -598,8 +610,10 @@
|
|||
}
|
||||
|
||||
- (NSArray *) fetchUsersMatching: (NSString *) filter
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
return [self _fetchEntriesInSources: [self authenticationSourceIDs]
|
||||
return [self _fetchEntriesInSources:
|
||||
[self authenticationSourceIDsInDomain: domain]
|
||||
matching: filter];
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
{
|
||||
NSString *_sourceID;
|
||||
NSString *_domain;
|
||||
NSString *_domainAttribute;
|
||||
NSArray *_mailFields;
|
||||
NSString *_userPasswordAlgorithm;
|
||||
NSURL *_viewURL;
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
max = [users count];
|
||||
user = [users objectAtIndex: 0];
|
||||
if (max == 1 && [user isEqualToString: @"ALL"])
|
||||
allUsers = [lm fetchUsersMatching: @"."];
|
||||
allUsers = [lm fetchUsersMatching: @"." inDomain: nil];
|
||||
else
|
||||
{
|
||||
allUsers = [NSMutableArray array];
|
||||
|
@ -309,7 +309,7 @@
|
|||
lm = [SOGoUserManager sharedUserManager];
|
||||
|
||||
done = NO;
|
||||
ldapSources = [[lm authenticationSourceIDs] objectEnumerator];
|
||||
ldapSources = [[lm authenticationSourceIDsInDomain: nil] objectEnumerator];
|
||||
while (!done && (sourceID = [ldapSources nextObject]))
|
||||
{
|
||||
currentSource = [lm sourceWithID: sourceID];
|
||||
|
|
|
@ -36,7 +36,9 @@
|
|||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import "SOGoToolRestore.h"
|
||||
|
||||
|
|
|
@ -332,7 +332,8 @@
|
|||
{
|
||||
domain = [[context activeUser] domain];
|
||||
result
|
||||
= [self _usersResponseForResults: [um fetchUsersMatching: contact]];
|
||||
= [self _usersResponseForResults: [um fetchUsersMatching: contact
|
||||
inDomain: domain]];
|
||||
}
|
||||
else
|
||||
result = [NSException exceptionWithHTTPStatus: 400
|
||||
|
|
Loading…
Reference in New Issue