Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/ldap): When creating a new contact, also write the "sn" field #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/SOGoInstallationGuide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ SOGoUserSources = (
{
type = ldap;
CNFieldName = cn;
SNFieldName = sn;
IDFieldName = uid;
UIDFieldName = uid;
IMAPHostFieldName = mailHost;
Expand Down Expand Up @@ -840,6 +841,7 @@ SOGoUserSources = (
{
type = ldap;
CNFieldName = cn;
SNFieldName = sn;
IDFieldName = cn;
UIDFieldName = sAMAccountName;
baseDN = "cn=Users,dc=acme,dc=com";
Expand Down
2 changes: 2 additions & 0 deletions Scripts/sogo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// {
// type = ldap;
// CNFieldName = cn;
// SNFieldName = sn;
// UIDFieldName = uid;
// IDFieldName = uid; // first field of the DN for direct binds
// bindFields = (uid, mail); // array of fields to use for indirect binds
Expand All @@ -66,6 +67,7 @@
// {
// type = ldap;
// CNFieldName = cn;
// SNFieldName = sn;
// UIDFieldName = sAMAccountName;
// baseDN = "CN=users,dc=domain,dc=tld";
// bindDN = "CN=sogo,CN=users,DC=domain,DC=tld";
Expand Down
2 changes: 2 additions & 0 deletions SoObjects/SOGo/LDAPSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
LDAPSourceSchema *_schema;
NSString *_IDField; // the first part of a user DN
NSString *_CNField;
NSString *_SNField;
NSString *_UIDField;
NSArray *_mailFields;
NSArray *_searchFields;
Expand Down Expand Up @@ -102,6 +103,7 @@
- (void) setBaseDN: (NSString *) newBaseDN
IDField: (NSString *) newIDField
CNField: (NSString *) newCNField
SNField: (NSString *) newSNField
UIDField: (NSString *) newUIDField
mailFields: (NSArray *) newMailFields
searchFields: (NSArray *) newSearchFields
Expand Down
12 changes: 12 additions & 0 deletions SoObjects/SOGo/LDAPSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ - (id) init
_schema = nil;
_IDField = @"cn"; /* the first part of a user DN */
_CNField = @"cn";
_SNField = @"sn";
_UIDField = @"uid";
_mailFields = [[NSArray arrayWithObject: @"mail"] retain];
_contactMapping = nil;
Expand Down Expand Up @@ -139,6 +140,7 @@ - (void) dealloc
[_pristineBaseDN release];
[_IDField release];
[_CNField release];
[_SNField release];
[_UIDField release];
[_contactMapping release];
[_mailFields release];
Expand Down Expand Up @@ -187,6 +189,7 @@ - (id) initFromUDSource: (NSDictionary *) udSource
[self setBaseDN: [udSource objectForKey: @"baseDN"]
IDField: [udSource objectForKey: @"IDFieldName"]
CNField: [udSource objectForKey: @"CNFieldName"]
SNField: [udSource objectForKey: @"SNFieldName"]
UIDField: [udSource objectForKey: @"UIDFieldName"]
mailFields: [udSource objectForKey: @"MailFieldNames"]
searchFields: [udSource objectForKey: @"SearchFieldNames"]
Expand Down Expand Up @@ -327,6 +330,7 @@ - (void) setBindDN: (NSString *) newBindDN
- (void) setBaseDN: (NSString *) newBaseDN
IDField: (NSString *) newIDField
CNField: (NSString *) newCNField
SNField: (NSString *) newSNField
UIDField: (NSString *) newUIDField
mailFields: (NSArray *) newMailFields
searchFields: (NSArray *) newSearchFields
Expand All @@ -345,6 +349,8 @@ - (void) setBaseDN: (NSString *) newBaseDN
ASSIGN(_IDField, [newIDField lowercaseString]);
if (newCNField)
ASSIGN(_CNField, [newCNField lowercaseString]);
if (newSNField)
ASSIGN(_SNField, [newSNField lowercaseString]);
if (newUIDField)
ASSIGN(_UIDField, [newUIDField lowercaseString]);
if (newIMAPHostField)
Expand Down Expand Up @@ -1216,6 +1222,11 @@ - (NSDictionary *) _convertLDAPEntryToContact: (NGLdapEntry *) ldapEntry
if (!value)
value = @"";
[ldifRecord setObject: value forKey: @"c_cn"];

value = [[ldapEntry attributeWithName: _SNField] stringValueAtIndex: 0];
if (!value)
value = @"";
[ldifRecord setObject: value forKey: @"c_sn"];
/* if "displayName" is not set, we use CNField because it must exist */
if (![ldifRecord objectForKey: @"displayname"])
[ldifRecord setObject: value forKey: @"displayname"];
Expand Down Expand Up @@ -1819,6 +1830,7 @@ - (NSArray *) addressBookSourcesForUser: (NSString *) theUser
[ab setBaseDN: [entry dn]
IDField: @"cn"
CNField: @"displayName"
SNField: @"sn"
UIDField: @"cn"
mailFields: nil
searchFields: nil
Expand Down