propagate from branch 'ca.inverse.sogo.1_3_12' (head 05f8b72feb6a6c81f20462457e2dbc6c47ae9edc)

to branch 'ca.inverse.sogo' (head dc4e3d958b052eb7529db6b61731e80df56ed412)

Monotone-Parent: 05f8b72feb6a6c81f20462457e2dbc6c47ae9edc
Monotone-Parent: dc4e3d958b052eb7529db6b61731e80df56ed412
Monotone-Revision: ba1ab7317c5e8c4b1e95d7e3f299bfd9ea38b10d

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2012-02-01T21:12:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2012-02-01 21:12:25 +00:00
134 changed files with 4671 additions and 3239 deletions
+2
View File
@@ -28,6 +28,7 @@ SOGo_HEADER_FILES = \
\
SOGoUserManager.h \
LDAPSource.h \
LDAPSourceSchema.h \
SQLSource.h \
SOGoUserProfile.h \
SOGoDateFormatter.h \
@@ -97,6 +98,7 @@ SOGo_OBJC_FILES = \
SOGoStartupLogger.m \
SOGoUserManager.m \
LDAPSource.m \
LDAPSourceSchema.m \
SQLSource.m \
SOGoUserProfile.m \
SOGoSQLUserProfile.m \
+25 -4
View File
@@ -30,10 +30,12 @@
#include "SOGoSource.h"
#include "SOGoConstants.h"
@class NSDictionary;
@class NSString;
@class NGLdapConnection;
@class LDAPSourceSchema;
@class NGLdapEntry;
@class NSException;
@class NSMutableArray;
@class NSMutableDictionary;
@class NSString;
@interface LDAPSource : NSObject <SOGoDNSource>
{
@@ -41,6 +43,8 @@
int queryTimeout;
NSString *sourceID;
NSString *displayName;
NSString *bindDN; // The bindDN/password could be either the source's one
NSString *password; // or the current user if _bindAsCurrentUser is set to YES
NSString *sourceBindDN; // while sourceBindDN/sourceBindPassword always belong to the source
@@ -49,21 +53,27 @@
unsigned int port;
NSString *encryption;
NSString *_filter;
BOOL _bindAsCurrentUser;
NSString *_scope;
NSString *_userPasswordAlgorithm;
NSString *baseDN;
LDAPSourceSchema *schema;
NSString *IDField; // the first part of a user DN
NSString *CNField;
NSString *UIDField;
NSArray *mailFields, *searchFields;
NSString *IMAPHostField, *IMAPLoginField;
NSArray *bindFields;
BOOL _bindAsCurrentUser;
BOOL listRequiresDot;
NSString *domain;
NSString *contactInfoAttribute;
NSDictionary *contactMapping;
NSArray *contactObjectClasses;
NSDictionary *modulesConstraints;
NSMutableArray *searchAttributes;
@@ -77,6 +87,12 @@
NSString *multipleBookingsField;
NSString *MSExchangeHostname;
/* user addressbooks */
NSString *abOU;
/* ACL */
NSArray *modifiers;
}
- (void) setBindDN: (NSString *) newBindDN
@@ -98,6 +114,11 @@
kindField: (NSString *) newKindField
andMultipleBookingsField: (NSString *) newMultipleBookingsField;
/* This enable the convertion of a contact entry with inetOrgPerson and mozillaAbPerson
to and from an LDAP record */
- (void) setContactMapping: (NSDictionary *) newMapping
andObjectClasses: (NSArray *) newObjectClasses;
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID;
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail;
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
File diff suppressed because it is too large Load Diff
+45
View File
@@ -0,0 +1,45 @@
/* LDAPSourceSchema.h - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef LDAPSOURCESCHEMA_H
#define LDAPSOURCESCHEMA_H
#import <Foundation/NSObject.h>
@class NSMutableDictionary;
@class NGLdapConnection;
@interface LDAPSourceSchema : NSObject
{
NSMutableDictionary *schema;
}
- (void) readSchemaFromConnection: (NGLdapConnection *) conn;
- (NSArray *) fieldsForClass: (NSString *) className;
/* merged list of attributes with unique names */
- (NSArray *) fieldsForClasses: (NSArray *) className;
@end
#endif /* LDAPSOURCESCHEMA_H */
+295
View File
@@ -0,0 +1,295 @@
/* LDAPSourceSchema.m - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <EOControl/EOQualifier.h>
#import <NGLdap/NGLdapConnection.h>
#import <NGLdap/NGLdapAttribute.h>
#import <NGLdap/NGLdapEntry.h>
#import "LDAPSourceSchema.h"
#import "NSDictionary+Utilities.h"
static EOQualifier *allOCQualifier = nil;
@implementation LDAPSourceSchema
+ (void) initialize
{
allOCQualifier = [[EOKeyValueQualifier alloc]
initWithKey: @"objectClass"
operatorSelector: EOQualifierOperatorEqual
value: @"*"];
}
- (id) init
{
if ((self = [super init]))
{
schema = nil;
}
return self;
}
- (void) dealloc
{
[schema release];
[super dealloc];
}
static NSArray *
schemaTokens (NSString *schema)
{
unichar *characters;
NSUInteger count, max, parenLevel = 0, firstChar = (NSUInteger) -1;
NSMutableArray *arrayString, *parentArray, *currentArray = nil;
NSArray *topArray = nil;
NSString *token;
arrayString = [NSMutableArray array];
max = [schema length];
characters = malloc ((max + 1) * sizeof (unichar));
characters[max] = 0;
[schema getCharacters: characters];
for (count = 0; count < max; count++)
{
switch (characters[count])
{
case '(':
// NSLog (@"increase");
parenLevel++;
parentArray = currentArray;
currentArray = [NSMutableArray array];
if (parentArray == nil)
topArray = currentArray;
[parentArray addObject: currentArray];
[arrayString addObject: currentArray];
break;
case ')':
// NSLog (@"decrease");
parenLevel--;
[arrayString removeLastObject];
currentArray = [arrayString lastObject];
break;
case ' ':
if (firstChar != (NSUInteger) -1)
{
token = [NSString stringWithCharacters: characters + firstChar
length: (count - firstChar)];
if (![token isEqualToString: @"$"])
[currentArray addObject: token];
// NSLog (@"added token: %@", token);
firstChar = (NSUInteger) -1;
}
break;
default:
if (currentArray && (firstChar == (NSUInteger) -1))
firstChar = count;
}
}
free (characters);
return topArray;
}
static inline id
schemaValue (NSArray *tokens, NSString *key)
{
NSUInteger idx;
id value;
idx = [tokens indexOfObject: key];
if (idx != NSNotFound)
value = [tokens objectAtIndex: (idx + 1)];
else
value = nil;
return value;
}
static NSMutableDictionary *
parseSchema (NSString *schema)
{
NSArray *tokens;
NSMutableDictionary *schemaDict;
NSMutableArray *fields;
id value;
schemaDict = [NSMutableDictionary dictionaryWithCapacity: 6];
tokens = schemaTokens (schema);
// [schemaDict setObject: [tokens objectAtIndex: 0]
// forKey: @"oid"];
value = schemaValue (tokens, @"NAME");
if (value)
{
/* sometimes, objectClasses can have two names */
if ([value isKindOfClass: [NSString class]])
value = [NSArray arrayWithObject: value];
[schemaDict setObject: value forKey: @"names"];
}
value = schemaValue (tokens, @"SUP");
if (value)
[schemaDict setObject: value forKey: @"sup"];
fields = [NSMutableArray new];
[schemaDict setObject: fields forKey: @"fields"];
[fields release];
value = schemaValue (tokens, @"MUST");
if (value)
{
if ([value isKindOfClass: [NSArray class]])
[fields addObjectsFromArray: value];
else
[fields addObject: value];
}
value = schemaValue (tokens, @"MAY");
if (value)
{
if ([value isKindOfClass: [NSArray class]])
[fields addObjectsFromArray: value];
else
[fields addObject: value];
}
return schemaDict;
}
static void
fillSchemaFromEntry (NSMutableDictionary *schema, NGLdapEntry *entry)
{
NSEnumerator *strings;
NGLdapAttribute *attr;
NSMutableDictionary *schemaDict;
NSArray *names;
NSString *string, *name;
NSUInteger count, max;
attr = [entry attributeWithName: @"objectclasses"];
strings = [attr stringValueEnumerator];
while ((string = [strings nextObject]))
{
schemaDict = parseSchema (string);
names = [schemaDict objectForKey: @"names"];
max = [names count];
for (count = 0; count < max; count++)
{
name = [[names objectAtIndex: count] lowercaseString];
if ([name hasPrefix: @"'"] && [name hasSuffix: @"'"])
name
= [name substringWithRange: NSMakeRange (1, [name length] - 2)];
[schema setObject: schemaDict forKey: name];
}
/* the list of names is no longer required from the schema itself */
[schemaDict removeObjectForKey: @"names"];
}
}
- (void) readSchemaFromConnection: (NGLdapConnection *) conn
{
NSEnumerator *entries;
NGLdapEntry *entry;
NSString *dn;
ASSIGN (schema, [NSMutableDictionary new]);
[schema release];
entries = [conn baseSearchAtBaseDN: @""
qualifier: allOCQualifier
attributes: [NSArray arrayWithObject: @"subschemaSubentry"]];
entry = [entries nextObject];
if (entry)
{
dn = [[entry attributeWithName: @"subschemaSubentry"]
stringValueAtIndex: 0];
if (dn)
{
entries = [conn baseSearchAtBaseDN: dn
qualifier: allOCQualifier
attributes: [NSArray arrayWithObject: @"objectclasses"]];
entry = [entries nextObject];
if (entry)
fillSchemaFromEntry (schema, entry);
}
}
}
static void
fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName,
NSMutableArray *fields)
{
NSDictionary *schemaDict;
NSString *sup;
NSArray *schemaFields;
schemaDict = [schema objectForKey: [schemaName lowercaseString]];
if (schemaDict)
{
schemaFields = [schemaDict objectForKey: @"fields"];
if ([schemaFields count] > 0)
[fields addObjectsFromArray: schemaFields];
sup = [schemaDict objectForKey: @"sup"];
if ([sup length] > 0)
fillFieldsForClass (schema, sup, fields);
}
}
- (NSArray *) fieldsForClass: (NSString *) className
{
NSMutableArray *fields;
fields = [NSMutableArray arrayWithCapacity: 128];
fillFieldsForClass (schema, className, fields);
return fields;
}
- (NSArray *) fieldsForClasses: (NSArray *) classNames
{
NSMutableDictionary *fieldHash;
NSNumber *yesValue;
NSString *name;
NSUInteger count, max;
yesValue = [NSNumber numberWithBool: YES];
fieldHash = [NSMutableDictionary dictionary];
max = [classNames count];
for (count = 0; count < max; count++)
{
name = [classNames objectAtIndex: count];
[fieldHash setObject: yesValue forKeys: [self fieldsForClass: name]];
}
return [fieldHash allKeys];
}
@end
+1 -2
View File
@@ -35,8 +35,7 @@
- (NSString *) jsonRepresentation;
- (NSString *) keysWithFormat: (NSString *) keyFormat;
// LDIF methods
- (NSString *) userRecordAsLDIFEntry;
- (NSComparisonResult) caseInsensitiveDisplayNameCompare: (NSDictionary *) theDictionary;
@end
-82
View File
@@ -26,12 +26,8 @@
#import <Foundation/NSException.h>
#import <Foundation/NSNull.h>
#import <Foundation/NSString.h>
#import <Foundation/NSCharacterSet.h>
#import <NGExtensions/NGBase64Coding.h>
#import "NSArray+Utilities.h"
#import "NSObject+Utilities.h"
#import "NSString+Utilities.h"
#import "NSDictionary+Utilities.h"
@@ -109,84 +105,6 @@
return [[self objectForKey: @"cn"] caseInsensitiveCompare: [theDictionary objectForKey: @"cn"]];
}
// LDIF Methods
#warning We might want to support more than just strings here
- (void) _appendLDIFKey: (NSString *) key
value: (NSString *) value
toString: (NSMutableString *) ldifString
{
if ([value isKindOfClass: [NSString class]])
{
if ([value _isLDIFSafe])
[ldifString appendFormat: @"%@: %@\n", key, value];
else
[ldifString appendFormat: @"%@:: %@\n",
key, [value stringByEncodingBase64]];
}
}
- (void) _appendLDIFKey: (NSString *) key
toString: (NSMutableString *) ldifString
{
id value;
int count, max;
value = [self objectForKey: key];
if ([value isKindOfClass: [NSArray class]])
{
max = [value count];
for (count = 0; count < max; count++)
[self _appendLDIFKey: key value: [value objectAtIndex: count]
toString: ldifString];
}
else
[self _appendLDIFKey: key value: [self objectForKey: key]
toString: ldifString];
}
- (void) _appendObjectClassesToString: (NSMutableString *) ldifString
{
NSEnumerator *classes;
NSString *currentClass;
classes = [[self objectForKey: @"objectClasses"] objectEnumerator];
while ((currentClass = [classes nextObject]))
[self _appendLDIFKey: @"objectClass" value: currentClass
toString: ldifString];
}
- (NSString *) userRecordAsLDIFEntry
{
NSMutableString *ldifString;
NSEnumerator *keys;
NSString *currentKey;
// {CalendarAccess = YES; MailAccess = YES; c_cn = "Wolfgang Sourdeau"; c_emails = ("wolfgang@test.com"); c_name = "wolfgang@test.com"; c_uid = "wolfgang@test.com"; cn = "wolfgang@test.com"; displayName = "Wolfgang Sourdeau"; dn = "cn=wolfgang@test.com,ou=evariste,o=inverse.ca"; givenName = Wolfgang; mail = "wolfgang@test.com"; objectClass = organizationalPerson; sn = Sourdeau; }
ldifString = [NSMutableString string];
[self _appendLDIFKey: @"dn" toString: ldifString];
[self _appendObjectClassesToString: ldifString];
keys = [[self allKeys] objectEnumerator];
while ((currentKey = [keys nextObject]))
{
if (!([currentKey isEqualToString: @"CalendarAccess"]
|| [currentKey isEqualToString: @"MailAccess"]
|| [currentKey isEqualToString: @"ContactAccess"]
|| [currentKey hasPrefix: @"objectClass"]
|| [currentKey hasPrefix: @"c_"]
|| [currentKey isEqualToString: @"dn"]
|| [currentKey isEqualToString: @"isGroup"]
|| [currentKey isEqualToString: @"isResource"]
|| [currentKey isEqualToString: @"numberOfSimultaneousBookings"]
|| [currentKey isEqualToString: @"canAuthenticate"]))
[self _appendLDIFKey: currentKey toString: ldifString];
}
return ldifString;
}
@end
@implementation NSMutableDictionary (SOGoDictionaryUtilities)
-2
View File
@@ -62,8 +62,6 @@
- (int) timeValue;
- (BOOL) _isLDIFSafe;
- (BOOL) isJSONString;
- (id) objectFromJSONString;
-38
View File
@@ -486,44 +486,6 @@ static int cssEscapingCount;
return time;
}
static NSMutableCharacterSet *safeLDIFChars = nil;
static NSMutableCharacterSet *safeLDIFStartChars = nil;
- (void) _initSafeLDIFChars
{
safeLDIFChars = [NSMutableCharacterSet new];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x01, 9)];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0b, 2)];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0e, 114)];
safeLDIFStartChars = [safeLDIFChars mutableCopy];
[safeLDIFStartChars removeCharactersInString: @" :<"];
}
- (BOOL) _isLDIFSafe
{
int count, max;
BOOL rc;
if (!safeLDIFChars)
[self _initSafeLDIFChars];
rc = YES;
max = [self length];
if (max > 0)
{
if ([safeLDIFStartChars characterIsMember: [self characterAtIndex: 0]])
for (count = 1; rc && count < max; count++)
rc = [safeLDIFChars
characterIsMember: [self characterAtIndex: count]];
else
rc = NO;
}
return rc;
}
- (BOOL) isJSONString
{
NSDictionary *jsonData;
+4 -2
View File
@@ -25,6 +25,8 @@
#import "SOGoObject.h"
@class NSString;
@interface SOGoFolder : SOGoObject
{
NSMutableString *displayName;
@@ -52,8 +54,8 @@
/* dav */
- (NSArray *) davResourceType;
/* outlook */
- (NSString *) outlookFolderClass;
/* email advisories */
- (void) sendFolderAdvisoryTemplate: (NSString *) template;
@end
+29 -7
View File
@@ -27,6 +27,7 @@
#import <Foundation/NSURL.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/WOApplication.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/SoWebDAVValue.h>
@@ -37,12 +38,16 @@
#import <SaxObjC/XMLNamespaces.h>
#import <SOGoUI/SOGoFolderAdvisory.h>
#import "DOMNode+SOGo.h"
#import "NSArray+Utilities.h"
#import "NSObject+DAV.h"
#import "NSString+DAV.h"
#import "NSString+Utilities.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
#import "SOGoDomainDefaults.h"
#import "SOGoWebDAVAclManager.h"
#import "WORequest+SOGo.h"
#import "WOResponse+SOGo.h"
@@ -248,6 +253,30 @@
return comparison;
}
/* email advisories */
- (void) sendFolderAdvisoryTemplate: (NSString *) template
{
NSString *pageName;
SOGoUser *user;
SOGoFolderAdvisory *page;
NSString *language;
user = [SOGoUser userWithLogin: [self ownerInContext: context]];
if ([[user domainDefaults] foldersSendEMailNotifications])
{
language = [[user userDefaults] language];
pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory",
language, template];
page = [[WOApplication application] pageWithName: pageName
inContext: context];
[page setFolderObject: self];
[page setRecipientUID: [user login]];
[page send];
}
}
/* WebDAV */
- (NSString *) davEntityTag
@@ -534,13 +563,6 @@
isEqualToString: [otherFolder nameInContainer]]);
}
- (NSString *) outlookFolderClass
{
[self subclassResponsibility: _cmd];
return nil;
}
/* acls */
- (NSString *) defaultUserID
-3
View File
@@ -118,9 +118,6 @@
- (void) removeAclsForUsers: (NSArray *) users
forObjectAtPath: (NSArray *) objectPathArray;
/* advisories */
- (void) sendFolderAdvisoryTemplate: (NSString *) template;
/* DAV */
- (NSURL *) publicDavURL;
- (NSURL *) realDavURL;
-23
View File
@@ -52,7 +52,6 @@
#import <GDLContentStore/GCSFolder.h>
#import <GDLContentStore/NSURL+GCS.h>
#import <SaxObjC/XMLNamespaces.h>
#import <SOGoUI/SOGoFolderAdvisory.h>
#import "NSDictionary+Utilities.h"
#import "NSArray+Utilities.h"
@@ -500,28 +499,6 @@ static NSArray *childRecordFields = nil;
return folder;
}
- (void) sendFolderAdvisoryTemplate: (NSString *) template
{
NSString *pageName;
SOGoUser *user;
SOGoFolderAdvisory *page;
NSString *language;
user = [SOGoUser userWithLogin: [self ownerInContext: context]];
if ([[user domainDefaults] foldersSendEMailNotifications])
{
language = [[user userDefaults] language];
pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory",
language, template];
page = [[WOApplication application] pageWithName: pageName
inContext: context];
[page setFolderObject: self];
[page setRecipientUID: [user login]];
[page send];
}
}
- (BOOL) create
{
NSException *result;
+2
View File
@@ -42,6 +42,8 @@
- (NSString *) defaultFolderName;
- (NSException *) appendPersonalSources;
- (void) setBaseOCSPath: (NSString *) newOCSPath;
- (NSArray *) toManyRelationshipKeys;
-3
View File
@@ -183,7 +183,6 @@ static SoSecurityManager *sm = nil;
SOGoGCSFolder *folder;
NSString *key;
NSException *error;
SOGoUser *currentUser;
if (!subFolderClass)
subFolderClass = [[self class] subFolderClass];
@@ -191,8 +190,6 @@ static SoSecurityManager *sm = nil;
error = [fc evaluateExpressionX: sql];
if (!error)
{
currentUser = [context activeUser];
attrs = [fc describeResults: NO];
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
{
+34 -1
View File
@@ -28,9 +28,10 @@
#import "SOGoConstants.h"
@class NSDictionary;
@class NSException;
@class NSString;
@protocol SOGoSource
@protocol SOGoSource <NSObject>
+ (id) sourceFromUDSource: (NSDictionary *) udSource
inDomain: (NSString *) domain;
@@ -40,6 +41,10 @@
- (NSString *) domain;
/* requires a "." to obtain the full list of contacts */
- (void) setListRequiresDot: (BOOL) aBool;
- (BOOL) listRequiresDot;
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
@@ -56,8 +61,36 @@
- (NSArray *) allEntryIDs;
- (NSArray *) fetchContactsMatching: (NSString *) filter;
- (void) setSourceID: (NSString *) newSourceID;
- (NSString *) sourceID;
- (void) setDisplayName: (NSString *) newDisplayName;
- (NSString *) displayName;
- (void) setModifiers: (NSArray *) newModifiers;
- (NSArray *) modifiers;
- (BOOL) hasUserAddressBooks;
- (NSArray *) addressBookSourcesForUser: (NSString *) user;
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
withID: (NSString *) aId;
- (NSException *) updateContactEntry: (NSDictionary *) ldifRecord;
- (NSException *) removeContactEntryWithID: (NSString *) aId;
/* user address books */
- (NSArray *) addressBookSourcesForUser: (NSString *) user;
- (NSException *) addAddressBookSource: (NSString *) newId
withDisplayName: (NSString *) newDisplayName
forUser: (NSString *) user;
- (NSException *) renameAddressBookSource: (NSString *) newId
withDisplayName: (NSString *) newDisplayName
forUser: (NSString *) user;
- (NSException *) removeAddressBookSource: (NSString *) newId
forUser: (NSString *) user;
@end
@protocol SOGoDNSource <SOGoSource>
+3
View File
@@ -52,6 +52,8 @@
@class SOGoUserProfile;
@class SOGoUserSettings;
@protocol SOGoSource;
@interface SOGoUser : SoUser
{
SOGoUserDefaults *_defaults;
@@ -88,6 +90,7 @@
/* properties */
- (NSString *) domain;
- (id <SOGoSource>) authenticationSource;
- (NSArray *) allEmails;
- (BOOL) hasEmail: (NSString *) email;
+11
View File
@@ -287,6 +287,17 @@
return [self _fetchFieldForUser: @"c_domain"];
}
- (id <SOGoSource>) authenticationSource
{
NSString *sourceID;
SOGoUserManager *um;
sourceID = [self _fetchFieldForUser: @"SOGoSource"];
um = [SOGoUserManager sharedUserManager];
return [um sourceWithID: sourceID];
}
- (NSArray *) allEmails
{
if (!allEmails)
+4 -2
View File
@@ -586,7 +586,7 @@
NSMutableArray *emails;
NSDictionary *userEntry;
NSEnumerator *sogoSources;
NSObject <SOGoDNSource> *currentSource;
NSObject <SOGoSource> *currentSource;
NSString *sourceID, *cn, *c_domain, *c_uid, *c_imaphostname, *c_imaplogin;
NSArray *c_emails;
BOOL access;
@@ -605,12 +605,14 @@
sogoSources = [[self authenticationSourceIDsInDomain: domain]
objectEnumerator];
while ((sourceID = [sogoSources nextObject]))
userEntry = nil;
while (!userEntry && (sourceID = [sogoSources nextObject]))
{
currentSource = [_sources objectForKey: sourceID];
userEntry = [currentSource lookupContactEntryWithUIDorEmail: uid];
if (userEntry)
{
[currentUser setObject: sourceID forKey: @"SOGoSource"];
if (!cn)
cn = [userEntry objectForKey: @"c_cn"];
if (!c_uid)
+154 -2
View File
@@ -22,8 +22,9 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSURL.h>
@@ -379,6 +380,7 @@
{
NSMutableDictionary *response;
NSMutableArray *qualifiers;
NSArray *fieldNames;
EOAdaptorChannel *channel;
EOQualifier *loginQualifier, *qualifier;
GCSChannelManager *cm;
@@ -463,6 +465,16 @@
[response autorelease];
[channel cancelFetch];
/* Convert all c_ fields to obtain their ldif equivalent */
fieldNames = [response allKeys];
for (i = 0; i < [fieldNames count]; i++)
{
field = [fieldNames objectAtIndex: i];
if ([field hasPrefix: @"c_"])
[response setObject: [response objectForKey: field]
forKey: [field substringFromIndex: 2]];
}
// We have to do this here since we do not manage modules
// constraints right now over a SQL backend.
[response setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
@@ -560,6 +572,8 @@
forKey: @"numberOfSimultaneousBookings"];
}
}
[response setObject: self forKey: @"source"];
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
@@ -666,7 +680,12 @@
attrs = [channel describeResults: NO];
while ((row = [channel fetchAttributes: attrs withZone: NULL]))
[results addObject: row];
{
row = [row mutableCopy];
[(NSMutableDictionary *) row setObject: self forKey: @"source"];
[results addObject: row];
[row release];
}
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
@@ -679,9 +698,142 @@
return results;
}
- (void) setSourceID: (NSString *) newSourceID
{
}
- (NSString *) sourceID
{
return _sourceID;
}
- (void) setDisplayName: (NSString *) newDisplayName
{
}
- (NSString *) displayName
{
/* This method is only used when supporting user "source" addressbooks,
which is only supported by the LDAP backend for now. */
return _sourceID;
}
- (void) setListRequiresDot: (BOOL) newListRequiresDot
{
}
- (BOOL) listRequiresDot
{
/* This method is not implemented for SQLSource. It must enable a mechanism
where using "." is not required to list the content of addressbooks. */
return YES;
}
/* card editing */
- (void) setModifiers: (NSArray *) newModifiers
{
}
- (NSArray *) modifiers
{
/* This method is only used when supporting card editing,
which is only supported by the LDAP backend for now. */
return nil;
}
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
withID: (NSString *) aId
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) updateContactEntry: (NSDictionary *) roLdifRecord
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) removeContactEntryWithID: (NSString *) aId
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
/* user addressbooks */
- (BOOL) hasUserAddressBooks
{
return NO;
}
- (NSArray *) addressBookSourcesForUser: (NSString *) user
{
return nil;
}
- (NSException *) addAddressBookSource: (NSString *) newId
withDisplayName: (NSString *) newDisplayName
forUser: (NSString *) user
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) renameAddressBookSource: (NSString *) newId
withDisplayName: (NSString *) newDisplayName
forUser: (NSString *) user
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) removeAddressBookSource: (NSString *) newId
forUser: (NSString *) user
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
@end