(fix) strip protocol value from proxyAddresses (fixes #3182)

This commit is contained in:
Ludovic Marcotte 2016-08-18 15:34:13 -04:00
parent 2fbe6e8429
commit ec11b8abb4

View file

@ -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];