diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 722ffd4e7..72640141d 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1429,11 +1429,22 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses NSMutableArray *contacts; EOQualifier *qualifier; unsigned int i; + NSMutableString *s; NSString *sortAttribute; BOOL sortReverse; contacts = [NSMutableArray array]; + if(theDomain != nil && [theDomain length] > 0) + { + if ([_baseDN rangeOfString: @"%d"].location != NSNotFound) + { + s = [NSMutableString stringWithString: _baseDN]; + [s replaceOccurrencesOfString: @"%d" withString: theDomain options: 0 range: NSMakeRange(0, [s length])]; + ASSIGN(_baseDN, s); + } + } + if ([match length] > 0 || !_listRequiresDot) { ldapConnection = [self _ldapConnection]; @@ -2290,8 +2301,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, NSRange r; r = [theLogin rangeOfString: @"@"]; - if (r.location != NSNotFound && - [_pristineBaseDN rangeOfString: @"%d"].location != NSNotFound) + if (r.location != NSNotFound && [_pristineBaseDN rangeOfString: @"%d"].location != NSNotFound) { s = [NSMutableString stringWithString: _pristineBaseDN]; [s replaceOccurrencesOfString: @"%d" withString: [theLogin substringFromIndex: r.location+1] options: 0 range: NSMakeRange(0, [s length])]; diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index c265f29ad..be9916bf7 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -1093,30 +1093,37 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail domain = nil; infos = nil; + //Try to get the domain from the uid + r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + // The domain is probably appended to the username; + // make sure it is a defined domain in the configuration. + domain = [uid substringFromIndex: (r.location + r.length)]; + if ([self isDomainDefined: domain]) + username = [uid substringToIndex: r.location]; + else + domain = nil; + } + sd = [SOGoSystemDefaults sharedSystemDefaults]; - if ([sd enableDomainBasedUID]) - { - r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; - if (r.location != NSNotFound) - { - // The domain is probably appended to the username; - // make sure it is a defined domain in the configuration. - domain = [uid substringFromIndex: (r.location + r.length)]; - if ([self isDomainDefined: domain]) - username = [uid substringToIndex: r.location]; - else - domain = nil; - } - if (domain != nil) - infos = [self contactInfosForUserWithUIDorEmail: username + if (domain != nil) + { + if ([sd enableDomainBasedUID]) + infos = [self contactInfosForUserWithUIDorEmail: username inDomain: domain]; - } + else + infos = [self contactInfosForUserWithUIDorEmail: uid + inDomain: domain]; + } if (infos == nil) + { // If the user was not found using the domain or if no domain was detected, // search using the original uid. infos = [self contactInfosForUserWithUIDorEmail: uid inDomain: nil]; + } return infos; } @@ -1145,8 +1152,7 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail if ([currentUser isKindOfClass: NSNullK]) currentUser = nil; - else if (!([currentUser objectForKey: @"emails"] - && [currentUser objectForKey: @"cn"])) + else if (!([currentUser objectForKey: @"emails"] && [currentUser objectForKey: @"cn"])) { // We make sure that we either have no occurence of a cache entry or // that we have an occurence with only a cached password. In the @@ -1163,6 +1169,19 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail } else newUser = NO; + + if(!domain) + { + //No domain provided is there one? + NSRange r; + r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + domain = [uid substringFromIndex: (r.location + r.length)]; + if (![self isDomainDefined: domain]) + domain = nil; + } + } [self _fillContactInfosForUser: currentUser withUIDorEmail: aUID inDomain: domain];