|
|
|
@ -64,7 +64,7 @@ public class LDAPSync implements Runnable {
|
|
|
|
|
DirContext ctx = new InitialDirContext(env);
|
|
|
|
|
_log.debug("Initiating LDAP Sync ...");
|
|
|
|
|
for (User user : users) {
|
|
|
|
|
updateUserInLDAP(user.getScreenName(), user.getFirstName(), user.getLastName(), user.getEmailAddress(), "{SHA}"+user.getPassword(), ctx, filter);
|
|
|
|
|
updateUserInLDAP(user.getScreenName(), user.getFirstName(), user.getLastName(), user.getFullName(), user.getEmailAddress(), "{SHA}"+user.getPassword(), ctx, filter);
|
|
|
|
|
//_log.debug("Updated " + user.getScreenName());
|
|
|
|
|
}
|
|
|
|
|
_log.debug("LDAP Sync cycle done");
|
|
|
|
@ -104,19 +104,22 @@ public class LDAPSync implements Runnable {
|
|
|
|
|
* @param ctx
|
|
|
|
|
* @throws NamingException
|
|
|
|
|
*/
|
|
|
|
|
private void updateUserInLDAP(String username, String name, String lastName, String email, String passwd, DirContext ctx, String filter) throws NamingException {
|
|
|
|
|
private void updateUserInLDAP(String username, String name, String lastName, String fullName, String email, String passwd, DirContext ctx, String filter) throws NamingException {
|
|
|
|
|
Attributes attributes=new BasicAttributes();
|
|
|
|
|
Attribute objectClass=new BasicAttribute("objectClass");
|
|
|
|
|
objectClass.add("inetOrgPerson");
|
|
|
|
|
attributes.put(objectClass);
|
|
|
|
|
|
|
|
|
|
Attribute sn = new BasicAttribute("sn");
|
|
|
|
|
//the main ldap server uses 'givenName' for the First name, 'cn' for "first name last name', 'sn' for the last name
|
|
|
|
|
Attribute givenName = new BasicAttribute("givenName");
|
|
|
|
|
Attribute cn = new BasicAttribute("cn");
|
|
|
|
|
Attribute sn = new BasicAttribute("sn");
|
|
|
|
|
Attribute mail = new BasicAttribute("mail");
|
|
|
|
|
Attribute userPassword = new BasicAttribute("userPassword");
|
|
|
|
|
|
|
|
|
|
sn.add(name);
|
|
|
|
|
cn.add(lastName);
|
|
|
|
|
|
|
|
|
|
givenName.add(name);
|
|
|
|
|
cn.add(fullName);
|
|
|
|
|
sn.add(lastName);
|
|
|
|
|
mail.add(email);
|
|
|
|
|
userPassword.add(passwd);
|
|
|
|
|
|
|
|
|
|