{"record":{"id":"6664318d90206fe6","repo":"apolloconfig/apollo","slug":"change-user-enabled-is-unsupported-666431","errorCode":null,"errorMessage":"change user enabled is unsupported","messagePattern":"change user enabled is unsupported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":500,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java","lineNumber":103,"sourceCode":"\n    if (userService instanceof SpringSecurityUserService) {\n      if (isCreate) {\n        ((SpringSecurityUserService) userService).create(user);\n      } else {\n        ((SpringSecurityUserService) userService).update(user);\n      }\n    } else {\n      throw new UnsupportedOperationException(\"Create or update user operation is unsupported\");\n    }\n  }\n\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isSuperAdmin()\")\n  @PutMapping(\"/users/enabled\")\n  public void changeUserEnabled(@RequestBody UserPO user) {\n    if (userService instanceof SpringSecurityUserService) {\n      ((SpringSecurityUserService) userService).changeEnabled(user);\n    } else {\n      throw new UnsupportedOperationException(\"change user enabled is unsupported\");\n    }\n  }\n\n  @GetMapping(\"/user\")\n  public UserInfo getCurrentUserName() {\n    return userInfoHolder.getUser();\n  }\n\n  @GetMapping(\"/user/logout\")\n  public void logout(HttpServletRequest request, HttpServletResponse response) {\n    logoutHandler.logout(request, response);\n  }\n\n  @GetMapping(\"/users\")\n  public List<UserInfo> searchUsersByKeyword(@RequestParam(value = \"keyword\") String keyword,\n      @RequestParam(value = \"includeInactiveUsers\",\n          defaultValue = \"false\") boolean includeInactiveUsers,\n      @RequestParam(value = \"offset\", defaultValue = \"0\") int offset,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java#L85-L121","documentation":"Thrown by UserInfoController.changeUserEnabled (PUT /users/enabled) when userService is NOT a SpringSecurityUserService. The endpoint (super-admin only via @PreAuthorize) has no implementation to toggle the enabled flag for other UserService impls. UnsupportedOperationException → typically HTTP 500.","triggerScenarios":"PUT /users/enabled on a portal using a non-DB UserService (LDAP/SSO/custom), where the bean is not SpringSecurityUserService.","commonSituations":"LDAP-backed deployment where an admin tries to enable/disable a portal user through this endpoint; custom UserService SPI that does not implement changeEnabled.","solutions":["Enable/disable users in the upstream identity provider (LDAP/SSO) when not using the DB user store.","If portal-local enable/disable is required, configure SpringSecurityUserService via the appropriate auth profile.","Confirm the active UserService bean class before invoking the endpoint."],"exampleFix":"// before\nputUsersEnabled(user); // UnsupportedOperationException\n\n// after\nif (!(userService instanceof SpringSecurityUserService)) {\n  throw new IllegalStateException(\"enable/disable requires the DB user store; manage the account in your IdP\");\n}\nputUsersEnabled(user);","handlingStrategy":"type-guard","validationCode":"if (!(userService instanceof SpringSecurityUserService)) {\n  return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body(\"enable/disable requires the DB-backed user store\");\n}","typeGuard":"boolean supportsEnableDisable(UserService svc) { return svc instanceof SpringSecurityUserService; }","tryCatchPattern":null,"preventionTips":["Use PUT /users/enabled only with the DB user store.","Manage enable/disable in the upstream IdP for LDAP/SSO setups.","Verify the UserService impl before invoking."],"tags":["apollo-portal","user-management","configuration","spring-security","unsupported-operation"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}