[keycloak-user] How to store "UserPassword" in LDAP through Keycloak Admin Client?

Marek Posolda mposolda at redhat.com
Mon Jun 5 03:43:25 EDT 2017


Hi,

once you create user, you need to use separate REST endpoint for update 
user credentials. The best is to look at our testsuite and how it uses 
REST endpoints (eg. see UserTest class from keycloak codebase) or 
eventually explore admin console with some tool like firebug, which will 
show you what REST endpoints is our admin console calling (KC admin 
console is just an angular application calling admin REST endpoints 
under the covers)

Marek

On 02/06/17 22:47, Celso Agra wrote:
> Hi all,
>
> Please, need some help! I'm trying to create an user through Keycloak Admin
> Client.
> So, When I add an user from Keycloak register page my LDAP stores a tag
> called "userPassword" with the password stored.
> But When I add an user from Keycloak Admin Client, all informations are
> stored in LDAP, except "userPassword". Am I doing something wrong?
>
> Here is my code below:
>
> public Response createUserKeycloak(UserKeycloak userKeycloak) {
>> CredentialRepresentation credential = new CredentialRepresentation();
>> credential.setType(CredentialRepresentation.PASSWORD);
>> credential.setValue(userKeycloak.getPassword());
>> credential.setTemporary(false);
>
>
>> UserRepresentation user = new UserRepresentation();
>> user.setUsername(userKeycloak.getUsername());
>> user.setFirstName(userKeycloak.getFirstName());
>> user.setLastName(userKeycloak.getLastName());
>> user.setEnabled(true);
>> if (userKeycloak.getEmail() != null)
>> user.setEmail(userKeycloak.getEmail());
>> user.setCredentials(Arrays.asList(credential));
>>
>
>> RealmResource realmResource = keycloak.realm(realmProperties.getRealm());
>> UsersResource userRessource = realmResource.users();
>> return userRessource.create(user);
>> }
>
>
> Best Regards,
>



More information about the keycloak-user mailing list