View Issue Details

IDProjectCategoryView StatusLast Update
0001197SOGoBackend Generalpublic2011-03-24 14:13
Reportermra Assigned Tofrancis  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version1.3.5 
Fixed in Version1.3.6 
Summary0001197: [1.3.6] Patch for feature "password change" with SQLSource
Description

Attached a little patch file for applying to SoObjects/SOGo/SQLSource.m, which enables the change password function in SQL sources.
Hope it's good enough for SOGo ...

TagsNo tags attached.

Activities

2011-03-20 21:15

 

SQLSource.m.patch (2,801 bytes)   
--- SOGo/SoObjects/SOGo/SQLSource.m	2011-03-20 21:31:59.000000000 +0100
+++ SOGo.orig/SoObjects/SOGo/SQLSource.m	2011-03-20 21:42:14.000000000 +0100
@@ -157,31 +157,6 @@
   return NO;
 }
 
-// Method for encrypt a password, based on _isPassword
-- (NSString *) _encryptPassword: (NSString *) plainPassword
-{
-  if ([_userPasswordAlgorithm caseInsensitiveCompare: @"none"] == NSOrderedSame)
-    {
-      return plainPassword;
-    }
-  else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"crypt"] == NSOrderedSame)
-    {
-      return [plainPassword asCryptStringUsingSalt: [plainPassword asMD5String]];
-    }
-  else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"md5"] == NSOrderedSame)
-    {
-      return [plainPassword asMD5String];
-    }
-  else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"sha"] == NSOrderedSame)
-    {
-      return [plainPassword asSHA1String];
-    }
-
-  [self errorWithFormat: @"Unsupported user-password algorithm: %@", _userPasswordAlgorithm];
-
-  return plainPassword;
-}
-
 //
 // SQL sources don't support right now all the password policy
 // stuff supported by OpenLDAP (and others). If we want to support
@@ -237,60 +212,14 @@
   return rc;
 }
 
-
-// Method for changing passwords with SQL, code fragments from other methods in this code
 - (BOOL) changePasswordForLogin: (NSString *) login
 		    oldPassword: (NSString *) oldPassword
 		    newPassword: (NSString *) newPassword
 			   perr: (SOGoPasswordPolicyError *) perr
 {
-	EOAdaptorChannel *channel;
-	GCSChannelManager *cm;
-	NSException *ex;
-	NSString *sqlstr;
-	BOOL didChange;
-	BOOL isOldPwdOk;
-	
-	isOldPwdOk = NO;
-	didChange = NO;
-	
-	// Now set Password with configured password encryption
-	isOldPwdOk = [self checkLogin:login password:oldPassword perr:perr expire:0 grace:0];
-
-	if(isOldPwdOk)
-	{
-		// encrypt new password
-		NSString *encryptedPassword = [self _encryptPassword: newPassword];
-
-		// save new password
-		login = [login stringByReplacingString: @"'"  withString: @"''"];
-		cm = [GCSChannelManager defaultChannelManager];
-		channel = [cm acquireOpenChannelForURL: _viewURL];
-		if (channel)
-		{
-			// first, create sql-command
-			sqlstr = [NSString stringWithFormat: (@"UPDATE %@"
-							@" SET c_password = '%@'"
-							@" WHERE c_uid = '%@'"),
-				[_viewURL gcsTableName], encryptedPassword, login];
-	
-			ex = [channel evaluateExpressionX: sqlstr];
-			if (!ex)
-			{
-				didChange = YES;
-			}
-			else
-			{
-				[self errorWithFormat: @"could not run SQL '%@': %@", sqlstr, ex];
-			}
-			[cm releaseChannel: channel];
-		}
-	}
-
-	return didChange;
+  return NO;
 }
 
-
 - (NSString *) _whereClauseFromArray: (NSArray *) theArray
                                value: (NSString *) theValue
 			       exact: (BOOL) theBOOL
SQLSource.m.patch (2,801 bytes)   
francis

francis

2011-03-24 14:13

administrator   ~0002293

Committed in revision 380b86e5c0d4f7e3c452e904f2a11e814e95ee59.

Thanks!

Issue History

Date Modified Username Field Change
2011-03-20 21:15 mra New Issue
2011-03-20 21:15 mra File Added: SQLSource.m.patch
2011-03-24 14:13 francis Note Added: 0002293
2011-03-24 14:13 francis Status new => resolved
2011-03-24 14:13 francis Fixed in Version => 1.3.6
2011-03-24 14:13 francis Resolution open => fixed
2011-03-24 14:13 francis Assigned To => francis