diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 4b3c85a91..647a3766e 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -913,7 +913,29 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses { allValues = [[ldapEntry attributeWithName: currentFieldName] allStringValues]; - [emails addObjectsFromArray: allValues]; + + // Special case handling for Microsoft Active Directory. proxyAddresses + // is generally prefixed with smtp: - if we find this (or any value preceeding + // the semi-colon), we strip it. See https://msdn.microsoft.com/en-us/library/ms679424(v=vs.85).aspx + if ([currentFieldName caseInsensitiveCompare: @"proxyAddresses"] == NSOrderedSame) + { + NSRange r; + int i; + + for (i = 0; i < [allValues count]; i++) + { + ldapValue = [allValues objectAtIndex: i]; + r = [ldapValue rangeOfString: @":"]; + if (r.length) + { + [emails addObject: [ldapValue substringFromIndex: r.location+1]]; + } + else + [emails addObject: ldapValue]; + } + } + else + [emails addObjectsFromArray: allValues]; } [ldifRecord setObject: emails forKey: @"c_emails"]; [emails release]; @@ -1702,25 +1724,25 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, ab = [LDAPSource new]; [ab setSourceID: [sourceRec objectForKey: @"ou"]]; [ab setDisplayName: [sourceRec objectForKey: @"description"]]; - [ab setBindDN: bindDN - password: password - hostname: hostname - port: [NSString stringWithFormat: @"%d", port] - encryption: encryption - bindAsCurrentUser: [NSString stringWithFormat: @"%d", NO]]; - [ab setBaseDN: [entry dn] - IDField: @"cn" - CNField: @"displayName" - UIDField: @"cn" - mailFields: nil - searchFields: nil - groupObjectClasses: nil - IMAPHostField: nil - IMAPLoginField: nil - SieveHostField: nil - bindFields: nil - kindField: nil - andMultipleBookingsField: nil]; + [ab setBindDN: bindDN + password: password + hostname: hostname + port: [NSString stringWithFormat: @"%d", port] + encryption: encryption + bindAsCurrentUser: [NSString stringWithFormat: @"%d", NO]]; + [ab setBaseDN: [entry dn] + IDField: @"cn" + CNField: @"displayName" + UIDField: @"cn" + mailFields: nil + searchFields: nil + groupObjectClasses: nil + IMAPHostField: nil + IMAPLoginField: nil + SieveHostField: nil + bindFields: nil + kindField: nil + andMultipleBookingsField: nil]; [ab setListRequiresDot: NO]; [ab setModifiers: modifier]; [sources addObject: ab];