Skip to content

Commit 7bff1ab

Browse files
committed
Merge 20.7.8 to 20.11
2 parents 5579edf + e4d778c commit 7bff1ab

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

OpenLdapSync/resources/web/OpenLdapSync/panel/LdapSettingsPanel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ Ext4.define('OpenLdapSync.panel.LdapSettingsPanel', {
644644
helpPopup: 'This should hold the value that uniquely identifies this record on the LDAP server. Usually this would be the login, but it could also be the distinguishing name or objectId',
645645
itemId: 'uidFieldMapping',
646646
name: 'uidFieldMapping'
647+
},{
648+
displayName: 'IM',
649+
itemId: 'imFieldMapping',
650+
name: 'imFieldMapping'
647651
}];
648652

649653

OpenLdapSync/src/org/labkey/openldapsync/OpenLdapSyncController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public static class LdapForm {
166166
private String _uidFieldMapping;
167167
private String _firstNameFieldMapping;
168168
private String _lastNameFieldMapping;
169+
private String _imFieldMapping;
169170

170171
private String _userDeleteBehavior;
171172
private String _groupDeleteBehavior;
@@ -400,6 +401,16 @@ public void setLastNameFieldMapping(String lastNameFieldMapping)
400401
_lastNameFieldMapping = lastNameFieldMapping;
401402
}
402403

404+
public String getImFieldMapping()
405+
{
406+
return _imFieldMapping;
407+
}
408+
409+
public void setImFieldMapping(String imFieldMapping)
410+
{
411+
_imFieldMapping = imFieldMapping;
412+
}
413+
403414
public String getUserInfoChangedBehavior()
404415
{
405416
return _userInfoChangedBehavior;
@@ -630,6 +641,9 @@ public ApiResponse execute(LdapForm form, BindException errors)
630641
if (form.getLastNameFieldMapping() != null)
631642
props.put(LdapSettings.LASTNAME_FIELD_PROP, form.getLastNameFieldMapping());
632643

644+
if (form.getImFieldMapping() != null)
645+
props.put(LdapSettings.IM_FIELD_PROP, form.getImFieldMapping());
646+
633647
if (form.getEmailFieldMapping() != null)
634648
props.put(LdapSettings.EMAIL_FIELD_PROP, form.getEmailFieldMapping());
635649

OpenLdapSync/src/org/labkey/openldapsync/ldap/LdapEntry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ public String getUID()
114114
return getAttribute(_settings.getUIDMapping());
115115
}
116116

117+
public String getIM() throws LdapInvalidAttributeValueException
118+
{
119+
try
120+
{
121+
Attribute a = _entry.get(_settings.getIMMapping());
122+
return a == null ? null : a.getString();
123+
}
124+
catch (LdapInvalidAttributeValueException e)
125+
{
126+
//not sure what's best here
127+
}
128+
return null;
129+
}
130+
117131
protected String getAttribute(String alias)
118132
{
119133
try

OpenLdapSync/src/org/labkey/openldapsync/ldap/LdapSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class LdapSettings
3838
public static final String PHONE_FIELD_PROP = "phoneNumberFieldMapping";
3939
public static final String FIRSTNAME_FIELD_PROP = "firstNameFieldMapping";
4040
public static final String LASTNAME_FIELD_PROP = "lastNameFieldMapping";
41+
public static final String IM_FIELD_PROP = "imFieldMapping";
42+
4143

4244
public static final String LABKEY_EMAIL_PROP = "labkeyAdminEmail";
4345

@@ -70,6 +72,7 @@ public class LdapSettings
7072
public static final String DEFAULT_LAST_NAME_VAL = "sn";
7173
public static final String DEFAULT_FIRST_NAME_VAL = "givenName";
7274
public static final String DEFAULT_PHONE_VAL = "telephoneNumber";
75+
public static final String DEFAULT_IM_VAL = "im";
7376
public static final String DEFAULT_UID_VAL = "userPrincipalName";
7477
public static final String DEFAULT_USERCLASS_VAL = "user";
7578
public static final String DEFAULT_GROUPCLASS_VAL = "group";
@@ -183,6 +186,9 @@ else if (key.equals(USE_SSL_PROP) && StringUtils.trimToNull(map.get(key)) != nul
183186
if (isMissingOrEmpty(ret, FIRSTNAME_FIELD_PROP))
184187
ret.put(FIRSTNAME_FIELD_PROP, DEFAULT_FIRST_NAME_VAL);
185188

189+
if (!ret.containsKey(IM_FIELD_PROP))
190+
ret.put(IM_FIELD_PROP, DEFAULT_IM_VAL);
191+
186192
if (isMissingOrEmpty(ret, PHONE_FIELD_PROP))
187193
ret.put(PHONE_FIELD_PROP, DEFAULT_PHONE_VAL);
188194

@@ -417,6 +423,11 @@ public String getPhoneMapping()
417423
return (String)_settings.get(PHONE_FIELD_PROP);
418424
}
419425

426+
public String getIMMapping()
427+
{
428+
return (String)_settings.get(IM_FIELD_PROP);
429+
}
430+
420431
public String getUIDMapping()
421432
{
422433
return (String)_settings.get(UID_FIELD_PROP);

OpenLdapSync/src/org/labkey/openldapsync/ldap/LdapSyncRunner.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ private User createUser(LdapEntry ldapEntry) throws LdapException
613613
if (phone != null)
614614
newUser.setPhone(phone);
615615

616+
String im = ldapEntry.getIM();
617+
if (im != null)
618+
newUser.setIM(im);
619+
616620
UserManager.updateUser(_settings.getLabKeyAdminUser(), newUser);
617621

618622
return newUser;
@@ -665,6 +669,13 @@ private void syncUserAttributes(LdapEntry ldapEntry, User existing) throws LdapE
665669
existing.setEmail(email);
666670
}
667671

672+
String im = ldapEntry.getIM();
673+
if (im != null && !im.equals(existing.getIM()))
674+
{
675+
changed = true;
676+
existing.setIM(im);
677+
}
678+
668679
if (changed)
669680
{
670681
log("Updating user settings: " + existing.getEmail());

0 commit comments

Comments
 (0)