Correct user modification detection.

Previous commit did not recognized users modification reliably and
synchronization was skipped. This commit fix this situation and make
sure that users modification in Wallix are reliably detected.
This commit is contained in:
2025-11-05 16:39:43 +01:00
parent d1aa764994
commit 6b9c8a4c92
2 changed files with 6 additions and 5 deletions

View File

@@ -37,7 +37,7 @@ public class WallixConfigSynchronizer implements Runnable {
}
private void synchronizeUsers() throws Exception {
System.out.println("Synchronizing groups");
System.out.println("Synchronizing users");
System.out.println("Getting Wallix groups");
Set<User> wallixUsers = Wallix.getInstance().getUsers();
DB db = DB.getInstance();
@@ -48,8 +48,7 @@ public class WallixConfigSynchronizer implements Runnable {
System.out.println("Adding user " + wallixUser.getName());
db.addUser(wallixUser);
} else if (userNeedUpdate(dbUser, wallixUser)) {
System.out.println("Updating user " + wallixUser.getName() + " - " + dbUser + " - " + dbUser.getName() + " - "
+ dbUser.getId());
System.out.println("Updating user " + wallixUser);
db.updateUser(wallixUser);
}
} catch (SQLException | GuacamoleException e) {
@@ -70,6 +69,8 @@ public class WallixConfigSynchronizer implements Runnable {
if (fullName != null && ! fullName.isEmpty()) {
return true;
}
} else {
return ! dbUser.getFullName().equals(wallixUser.getFullName());
}
return dbUser.isDisabled() != wallixUser.isDisabled();
}

View File

@@ -340,10 +340,10 @@ public class DB {
DB db = DB.getInstance();
Connection connection = db.getMySQLConnection();
PreparedStatement stmt = connection
.prepareStatement("update guacamole_user set full_name=?, disabled=? where user_id=? and organization=?");
.prepareStatement("update guacamole_user set full_name=?, disabled=? where user_id=(select user_id from guacamole_user where entity_id=(select entity_id from guacamole_entity where name=?)) and organization=?");
stmt.setString(1, wallixUser.getFullName());
stmt.setBoolean(2, wallixUser.isDisabled());
stmt.setInt(3, wallixUser.getUserId());
stmt.setString(3, wallixUser.getName());
stmt.setString(4, DB_ORGANIZATION);
stmt.executeUpdate();
}