Skip to content

Commit

Permalink
(fix) strip protocol value from proxyAddresses (fixes #3182)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Aug 18, 2016
1 parent 0d02172 commit 372158a
Showing 1 changed file with 42 additions and 20 deletions.
62 changes: 42 additions & 20 deletions SoObjects/SOGo/LDAPSource.m
Expand Up @@ -906,7 +906,29 @@ - (void) _fillEmailsOfEntry: (NGLdapEntry *) ldapEntry
{
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];
Expand Down Expand Up @@ -1695,25 +1717,25 @@ - (NSArray *) addressBookSourcesForUser: (NSString *) user
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];
Expand Down

0 comments on commit 372158a

Please sign in to comment.