<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
        {font-family:inherit;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE-AT" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-CA">Thanks Sascha works like a charm,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">In case it helps someone else this is a simple version of working code (using this as temporary code to set up an initial user, normally would suggest a cleaner way to get the userId from keycloak but search works fine
 for now):<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">UserRepresentation user = new UserRepresentation();</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">user.setUsername(&quot;testuser&quot;);</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">user.setFirstName(&quot;Test&quot;);</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">user.setLastName(&quot;User&quot;);</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">kc.realm(&quot;master&quot;).users().create(user);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">kc.realm(&quot;master&quot;).users().search(&#8220;testUser&#8221;, 0, 1).forEach(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp;&nbsp; UserResource userResource = kc.realm(&quot;master&quot;).users().get(user.getId());<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp;&nbsp;CredentialRepresentation credential = new CredentialRepresentation();</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp; &nbsp;credential.setType(CredentialRepresentation.PASSWORD);</span><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp; &nbsp;credential.setValue(&quot;test123&quot;);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp;&nbsp; credential.setTemporary(true);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">&nbsp;&nbsp; userResource.resetPassword(credential);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height:11.25pt"><span lang="EN-CA" style="font-size:9.0pt;font-family:&quot;inherit&quot;,serif;color:black">Will<o:p></o:p></span></p>
</div>
</body>
</html>