See ChangeLog

Monotone-Parent: 024380d579a482e49866c36ef54561cf8b39ab02
Monotone-Revision: 2cbc46c16f9b3d45d868b15a968f614dbbaf9749

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2010-03-08T15:18:05
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Ludovic Marcotte
2010-03-08 15:18:05 +00:00
parent 13206f066d
commit 40c3cb74d0
26 changed files with 1059 additions and 98 deletions
+2
View File
@@ -19,6 +19,7 @@ SOGo_HEADER_FILES = \
SOGoProductLoader.h \
\
SOGoCache.h \
SOGoConstants.h \
SOGoObject.h \
SOGoContentObject.h \
SOGoFolder.h \
@@ -80,6 +81,7 @@ SOGo_OBJC_FILES = \
SOGoProductLoader.m \
\
SOGoCache.m \
SOGoConstants.m \
SOGoObject.m \
SOGoContentObject.m \
SOGoFolder.m \
+4 -1
View File
@@ -1,6 +1,6 @@
/* LDAPSource.h - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -26,6 +26,7 @@
#import <Foundation/NSObject.h>
#include "SOGoSource.h"
#include "SOGoConstants.h"
@class NSDictionary;
@class NSString;
@@ -60,6 +61,8 @@
NSDictionary *modulesConstraints;
NSMutableArray *searchAttributes;
BOOL passwordPolicy;
}
- (void) setBindDN: (NSString *) newBindDN
+96 -11
View File
@@ -29,6 +29,7 @@
#import <NGLdap/NGLdapConnection.h>
#import <NGLdap/NGLdapAttribute.h>
#import <NGLdap/NGLdapEntry.h>
#import <NGLdap/NGLdapModification.h>
#import "NSArray+Utilities.h"
#import "NSString+Utilities.h"
@@ -157,6 +158,7 @@ static NSArray *commonSearchFields;
_filter = nil;
searchAttributes = nil;
passwordPolicy = NO;
}
return self;
@@ -239,6 +241,9 @@ static NSArray *commonSearchFields;
ASSIGN (_scope, ([udSource objectForKey: @"scope"]
? [udSource objectForKey: @"scope"]
: (id)@"sub"));
if ([udSource objectForKey: @"passwordPolicy"])
passwordPolicy = [[udSource objectForKey: @"passwordPolicy"] boolValue];
}
return self;
@@ -414,16 +419,19 @@ static NSArray *commonSearchFields;
return userDN;
}
- (BOOL) checkLogin: (NSString *) loginToCheck
andPassword: (NSString *) passwordToCheck
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
{
BOOL didBind;
NSString *userDN;
NGLdapConnection *bindConnection;
NSString *userDN;
BOOL didBind;
didBind = NO;
if ([loginToCheck length] > 0)
if ([_login length] > 0)
{
bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname
port: port];
@@ -432,16 +440,24 @@ static NSArray *commonSearchFields;
if (queryTimeout > 0)
[bindConnection setQueryTimeLimit: queryTimeout];
if (bindFields)
userDN = [self _fetchUserDNForLogin: loginToCheck];
userDN = [self _fetchUserDNForLogin: _login];
else
userDN = [NSString stringWithFormat: @"%@=%@,%@",
IDField, loginToCheck, baseDN];
IDField, _login, baseDN];
if (userDN)
{
NS_DURING
didBind = [bindConnection bindWithMethod: @"simple"
binddn: userDN
credentials: passwordToCheck];
if (!passwordPolicy)
didBind = [bindConnection bindWithMethod: @"simple"
binddn: userDN
credentials: _pwd];
else
didBind = [bindConnection bindWithMethod: @"simple"
binddn: userDN
credentials: _pwd
perr: (void *)_perr
expire: _expire
grace: _grace];
NS_HANDLER
;
NS_ENDHANDLER
@@ -450,10 +466,79 @@ static NSArray *commonSearchFields;
}
[bindConnection release];
}
return didBind;
}
- (BOOL) changePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NGLdapConnection *bindConnection;
NSString *userDN;
BOOL didChange;
didChange = NO;
if ([login length] > 0)
{
bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname
port: port];
if (![encryption length] || [self _setupEncryption: bindConnection])
{
if (queryTimeout > 0)
[bindConnection setQueryTimeLimit: queryTimeout];
if (bindFields)
userDN = [self _fetchUserDNForLogin: login];
else
userDN = [NSString stringWithFormat: @"%@=%@,%@",
IDField, login, baseDN];
if (userDN)
{
NS_DURING
if (!passwordPolicy)
{
// We don't use a password policy - we simply use
// a modify-op to change the password
NGLdapModification *mod;
NGLdapAttribute *attr;
NSArray *changes;
attr = [[NGLdapAttribute alloc] initWithAttributeName: @"userPassword"];
[attr addStringValue: newPassword];
mod = [NGLdapModification replaceModification: attr];
changes = [NSArray arrayWithObject: mod];
perr = PolicyNoError;
if ([bindConnection bindWithMethod: @"simple"
binddn: userDN
credentials: oldPassword])
didChange = [bindConnection modifyEntryWithDN: userDN
changes: changes];
else
didChange = NO;
}
else
didChange = [bindConnection changePasswordAtDn: userDN
oldPassword: oldPassword
newPassword: newPassword
perr: (void *)perr];
NS_HANDLER
;
NS_ENDHANDLER
;
}
}
[bindConnection release];
}
return didChange;
}
/* contact management */
- (EOQualifier *) _qualifierForFilter: (NSString *) filter
{
+1 -1
View File
@@ -1,6 +1,6 @@
/* SOGoAuthenticator.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
+48
View File
@@ -0,0 +1,48 @@
/* SOGoConstants.h - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@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 _SOGOCONSTANTS_H_
#define _SOGOCONSTANTS_H_
// This is a perfect copy of the OpenLDAP's
// LDAPPasswordPolicyError enum. We redeclare it
// so that we always include the ppolicy code
// within SOGo.
typedef enum
{
PolicyPasswordExpired = 0,
PolicyAccountLocked = 1,
PolicyChangeAfterReset = 2,
PolicyPasswordModNotAllowed = 3,
PolicyMustSupplyOldPassword = 4,
PolicyInsufficientPasswordQuality = 5,
PolicyPasswordTooShort = 6,
PolicyPasswordTooYoung = 7,
PolicyPasswordInHistory = 8,
PolicyNoError = 65535,
} SOGoPasswordPolicyError;
// Domain defaults
extern NSString *SOGoPasswordChangeEnabled;
extern NSString *SOGoPasswordPolicyEnabled;
#endif /* _SOGOCONSTANTS_H_ */
+27
View File
@@ -0,0 +1,27 @@
/* SOGoConstants.m - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@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/NSString.h>
// LDAP Password Policy Constants
NSString* SOGoPasswordChangeEnabled = @"SOGoPasswordChangeEnabled";
NSString* SOGoPasswordPolicyEnabled = @"SOGoPasswordPolicyEnabled";
+17 -2
View File
@@ -27,6 +27,7 @@
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSObject+Logs.h>
#import "SOGoConstants.h"
#import "SOGoUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
@@ -48,8 +49,22 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
{
return [[SOGoUserManager sharedUserManager] checkLogin: _login
andPassword: _pwd];
SOGoPasswordPolicyError perr;
int expire, grace;
BOOL b;
perr = PolicyNoError;
b = [[SOGoUserManager sharedUserManager] checkLogin: _login
password: _pwd
perr: &perr
expire: &expire
grace: &grace];
if (b && perr == PolicyNoError)
return YES;
return NO;
}
- (NSString *) passwordInContext: (WOContext *) context
+3 -1
View File
@@ -1,6 +1,6 @@
/* SOGoDomainDefaults.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
* Copyright (C) 2009-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -46,6 +46,8 @@
- (BOOL) sieveScriptsEnabled;
- (BOOL) forwardEnabled;
- (BOOL) vacationEnabled;
- (BOOL) passwordChangeEnabled;
- (BOOL) passwordPolicyEnabled;
- (NSString *) mailingMechanism;
- (NSString *) smtpServer;
- (NSString *) mailSpoolPath;
+12 -1
View File
@@ -1,6 +1,6 @@
/* SOGoDomainDefaults.m - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
* Copyright (C) 2009-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -30,6 +30,7 @@
#import "SOGoSystemDefaults.h"
#import "SOGoDomainDefaults.h"
#import "SOGoConstants.h"
@implementation SOGoDomainDefaults
@@ -170,6 +171,16 @@
return [self boolForKey: @"SOGoVacationEnabled"];
}
- (BOOL) passwordChangeEnabled
{
return [self boolForKey: SOGoPasswordChangeEnabled];
}
- (BOOL) passwordPolicyEnabled
{
return [self boolForKey: SOGoPasswordPolicyEnabled];
}
- (NSString *) mailingMechanism
{
NSString *mailingMechanism;
+13 -3
View File
@@ -1,6 +1,6 @@
/* SOGoSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
* Copyright (C) 2009-2010 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
*
@@ -25,6 +25,8 @@
#import <Foundation/NSObject.h>
#import "SOGoConstants.h"
@class NSDictionary;
@class NSString;
@@ -38,8 +40,16 @@
- (NSString *) domain;
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password;
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace;
- (BOOL) changePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr;
- (NSDictionary *) lookupContactEntry: (NSString *) theID;
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID;
+1 -1
View File
@@ -1,6 +1,6 @@
/* SOGoSystemDefaults.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
* Copyright (C) 2009-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
+12 -3
View File
@@ -1,6 +1,6 @@
/* SOGoUserManager.h - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -25,6 +25,8 @@
#import <Foundation/NSObject.h>
#import "SOGoConstants.h"
@class NSDictionary;
@class NSMutableDictionary;
@class NSString;
@@ -75,9 +77,16 @@
- (NSString *) getUIDForEmail: (NSString *) email;
- (NSString *) getLoginForDN: (NSString *) theDN;
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password;
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace;
- (BOOL) changePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr;
@end
#endif /* SOGOUSERMANAGER_H */
+108 -27
View File
@@ -1,6 +1,6 @@
/* SOGoUserManager.m - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -36,6 +36,7 @@
#import "SOGoSystemDefaults.h"
#import "SOGoUserManager.h"
#import "SOGoCache.h"
#import "SOGoConstants.h"
#import "SOGoSource.h"
@implementation SOGoUserManagerRegistry
@@ -89,7 +90,7 @@
{
NSString *sourceID, *value, *type;
NSMutableDictionary *metadata;
NSObject <SOGoSource> *ldapSource;
NSObject <SOGoSource> *sogoSource;
BOOL isAddressBook;
Class c;
@@ -97,10 +98,10 @@
if ([sourceID length] > 0)
{
type = [[udSource objectForKey: @"type"] lowercaseString];
c = NSClassFromString ([_registry sourceClassForType: type]);
ldapSource = [c sourceFromUDSource: udSource inDomain: domain];
c = NSClassFromString([_registry sourceClassForType: type]);
sogoSource = [c sourceFromUDSource: udSource inDomain: domain];
if (sourceID)
[_sources setObject: ldapSource forKey: sourceID];
[_sources setObject: sogoSource forKey: sourceID];
else
[self errorWithFormat: @"id field missing in an user source,"
@" check the SOGoUserSources defaults"];
@@ -335,45 +336,84 @@
{
NSDictionary *contactInfos;
// NSLog (@"getUIDForEmail: %@", email);
contactInfos = [self contactInfosForUserWithUIDorEmail: email];
return [contactInfos objectForKey: @"c_uid"];
}
- (BOOL) _sourceChangePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NSObject <SOGoSource> *sogoSource;
NSEnumerator *authIDs;
NSString *currentID;
BOOL didChange;
didChange = NO;
authIDs = [[self authenticationSourceIDsInDomain: nil] objectEnumerator];
while (!didChange && (currentID = [authIDs nextObject]))
{
sogoSource = [_sources objectForKey: currentID];
didChange = [sogoSource changePasswordForLogin: login
oldPassword: oldPassword
newPassword: newPassword
perr: perr];
}
return didChange;
}
- (BOOL) _sourceCheckLogin: (NSString *) login
andPassword: (NSString *) password
{
NSObject <SOGoSource> *ldapSource;
perr: (SOGoPasswordPolicyError *) perr
expire: (int *) expire
grace: (int *) grace
{
NSObject <SOGoSource> *sogoSource;
NSEnumerator *authIDs;
NSString *currentID;
BOOL checkOK;
checkOK = NO;
authIDs = [[self authenticationSourceIDsInDomain: nil] objectEnumerator];
while (!checkOK && (currentID = [authIDs nextObject]))
{
ldapSource = [_sources objectForKey: currentID];
checkOK = [ldapSource checkLogin: login andPassword: password];
sogoSource = [_sources objectForKey: currentID];
checkOK = [sogoSource checkLogin: login
password: password
perr: perr
expire: expire
grace: grace];
}
return checkOK;
}
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
{
NSMutableDictionary *currentUser;
NSString *dictPassword, *jsonUser;
NSMutableDictionary *currentUser;
BOOL checkOK;
jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login];
jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: _login];
currentUser = [NSMutableDictionary dictionaryWithJSONString: jsonUser];
dictPassword = [currentUser objectForKey: @"password"];
if (currentUser && dictPassword)
checkOK = ([dictPassword isEqualToString: password]);
else if ([self _sourceCheckLogin: login andPassword: password])
checkOK = ([dictPassword isEqualToString: _pwd]);
else if ([self _sourceCheckLogin: _login
andPassword: _pwd
perr: _perr
expire: _expire
grace: _grace])
{
checkOK = YES;
if (!currentUser)
@@ -386,17 +426,58 @@
// set the password and recache the entry, the password would never be
// cached for the user unless its entry expires from memcached's
// internal cache.
[currentUser setObject: password forKey: @"password"];
[currentUser setObject: _pwd forKey: @"password"];
[[SOGoCache sharedCache]
setUserAttributes: [currentUser jsonStringValue]
forLogin: login];
forLogin: _login];
}
else
checkOK = NO;
else
checkOK = NO;
return checkOK;
}
- (BOOL) changePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NSString *dictPassword, *jsonUser;
NSMutableDictionary *currentUser;
BOOL didChange;
jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login];
currentUser = [NSMutableDictionary dictionaryWithJSONString: jsonUser];
dictPassword = [currentUser objectForKey: @"password"];
if ([self _sourceChangePasswordForLogin: login
oldPassword: oldPassword
newPassword: newPassword
perr: perr])
{
didChange = YES;
if (!currentUser)
{
currentUser = [NSMutableDictionary dictionary];
}
// It's important to cache the password here as we might have cached the
// user's entry in -contactInfosForUserWithUIDorEmail: and if we don't
// set the password and recache the entry, the password would never be
// cached for the user unless its entry expires from memcached's
// internal cache.
[currentUser setObject: newPassword forKey: @"password"];
[[SOGoCache sharedCache]
setUserAttributes: [currentUser jsonStringValue]
forLogin: login];
}
else
didChange = NO;
return didChange;
}
- (void) _fillContactMailRecords: (NSMutableDictionary *) contact
{
NSString *uid, *domain, *systemEmail;
@@ -424,8 +505,8 @@
{
NSMutableArray *emails;
NSDictionary *userEntry;
NSEnumerator *ldapSources;
LDAPSource *currentSource;
NSEnumerator *sogoSources;
NSObject <SOGoDNSource> *currentSource;
NSString *sourceID, *cn, *c_domain, *c_uid, *c_imaphostname;
NSArray *c_emails;
BOOL access;
@@ -441,9 +522,9 @@
[currentUser setObject: [NSNumber numberWithBool: YES]
forKey: @"MailAccess"];
ldapSources = [[self authenticationSourceIDsInDomain: nil]
sogoSources = [[self authenticationSourceIDsInDomain: nil]
objectEnumerator];
while ((sourceID = [ldapSources nextObject]))
while ((sourceID = [sogoSources nextObject]))
{
currentSource = [_sources objectForKey: sourceID];
userEntry = [currentSource lookupContactEntryWithUIDorEmail: uid];
+11 -2
View File
@@ -1,8 +1,9 @@
/* SOGoWebAuthenticator.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Ludovic Marcotte <lmarcotte@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
@@ -24,7 +25,9 @@
#define _SOGOWEBAUTHENTICATOR_H_
#import <NGObjWeb/SoCookieAuthenticator.h>
#import "SOGoAuthenticator.h"
#import "SOGoConstants.h"
@class NSString;
@@ -34,6 +37,12 @@
+ (id) sharedSOGoWebAuthenticator;
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace;
@end
#endif /* _SOGOWEBAUTHENTICATOR_H__ */
#endif /* _SOGOWEBAUTHENTICATOR_H_ */
+29 -4
View File
@@ -1,6 +1,6 @@
/* SOGoWebAuthenticator.m - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -37,6 +37,7 @@
#import <MainUI/SOGoRootPage.h>
#import "SOGoCASSession.h"
#import "SOGoConstants.h"
#import "SOGoPermissions.h"
#import "SOGoSystemDefaults.h"
#import "SOGoUser.h"
@@ -59,11 +60,28 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
{
SOGoPasswordPolicyError perr;
int expire, grace;
return [self checkLogin: _login
password: _pwd
perr: &perr
expire: &expire
grace: &grace];
}
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
{
SOGoCASSession *session;
SOGoSystemDefaults *sd;
BOOL rc;
SOGoCASSession *session;
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([[sd authenticationType] isEqualToString: @"cas"])
{
session = [SOGoCASSession CASSessionWithIdentifier: _pwd];
@@ -74,8 +92,15 @@
}
else
rc = [[SOGoUserManager sharedUserManager] checkLogin: _login
andPassword: _pwd];
password: _pwd
perr: _perr
expire: _expire
grace: _grace];
[self logWithFormat: @"Checked login with ppolicy enabled: %d %d %d", *_perr, *_expire, *_grace];
// It's important to return the real value here. The callee will handle
// the return code and check for the _perr value.
return rc;
}
+24 -5
View File
@@ -1,6 +1,6 @@
/* SQLSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
* Copyright (C) 2009-2010 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
*
@@ -40,6 +40,8 @@
#include "SQLSource.h"
#include "SOGoConstants.h"
/**
* The view MUST contain the following columns:
*
@@ -162,8 +164,17 @@
return NO;
}
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password
//
// SQL sources don't support right now all the password policy
// stuff supported by OpenLDAP (and others). If we want to support
// this for SQL sources, we'll have to implement the same
// kind of logic in this module.
//
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
{
EOAdaptorChannel *channel;
GCSChannelManager *cm;
@@ -180,7 +191,7 @@
sql = [NSString stringWithFormat: (@"SELECT c_password"
@" FROM %@"
@" WHERE c_uid = '%@'"),
[_viewURL gcsTableName], login];
[_viewURL gcsTableName], _login];
ex = [channel evaluateExpressionX: sql];
if (!ex)
@@ -193,7 +204,7 @@
row = [channel fetchAttributes: attrs withZone: NULL];
value = [row objectForKey: @"c_password"];
rc = [self _isPassword: password equalTo: value];
rc = [self _isPassword: _pwd equalTo: value];
[channel cancelFetch];
}
else
@@ -207,6 +218,14 @@
return rc;
}
- (BOOL) changePasswordForLogin: (NSString *) login
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
return NO;
}
- (NSDictionary *) _lookupContactEntry: (NSString *) theID
considerEmail: (BOOL) b
{