Skip to content

Commit a68649d

Browse files
committed
Merge 20.11 to develop
2 parents 4b8f131 + 7bff1ab commit a68649d

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
@@ -612,6 +612,10 @@ private User createUser(LdapEntry ldapEntry) throws LdapException
612612
if (phone != null)
613613
newUser.setPhone(phone);
614614

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

617621
return newUser;
@@ -664,6 +668,13 @@ private void syncUserAttributes(LdapEntry ldapEntry, User existing) throws LdapE
664668
existing.setEmail(email);
665669
}
666670

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

0 commit comments

Comments
 (0)