Hi,
you need to follow similar logic as within ManagedClient, which Nick
already sent. In the onrequire instruction you receive list of required
arguments (e.g the whole instruction can look like
"8.required,8.username,6.domain,8.password;", which means you need to send
username, domain and password).

You then need to send each of the required instructions (I believe the
value can be empty, at least for domain that seems to work) and that is
achieved using ArgumentValueStream as used in the
"ManagedClient.sendArguments" method.

So if you receive only password in the required instruction, you just need
to do:

var stream = guacamoleclient.createArgumentValueStream("text/plain",
> "password");
> var writer = new Guacamole.StringWriter(stream);
> writer.sendText("the actual password for the connection");
> writer.sendEnd();


But if you receive username, domain and password in the
required instruction, you need to do the same for every argument separately
- the second argument in createArgumentValueStream is the actual argument
name as received in the required instruction.

And only once you send all the required arguments, the connection will
continue (so you just can't skip those you don't want to handle).


Lukas


st 2. 4. 2025 v 16:09 odesílatel Gal Sabas <gal...@checkpoint.com.invalid>
napsal:

> I’m using guacamole-common-js to create my Guacamole client and listen to
> different events like .onrequired but I don’t see a way to use my
> guacamole-common utils to implement this functionality.
>
>
>
> Any ideas?
>
>
>
> Get Outlook for Mac <https://aka.ms/GetOutlookForMac>
>
>
>
> *From: *Gal Sabas <gal...@checkpoint.com.INVALID>
> *Date: *Monday, 31 March 2025 at 13:28
> *To: *user@guacamole.apache.org <user@guacamole.apache.org>
> *Subject: *Re: Guacamole client .onrequired
>
> I see that guacamole-client uses ‘ManagedClient.sendArguments’ but
> sendArguments’ needs to receive ManagedClient so I’m not sure how to use it
> in my code.
>
>
>
> Get Outlook for Mac
> <https://protect.checkpoint.com/v2/r02/___https:/aka.ms/GetOutlookForMac___.YzJlOmNwYWxsOmM6bzo4ODg4MzcwNDg1NjE0ZDUwYWQyMDMzZWZjOGI4N2JhYzo3OjM4ZmE6MGNlZTU5OTRjNzEzOGYzOTMzM2UzM2M0ZDNhZmY3YmFhZTE1NDRjMTZmNjJlYjExN2MyOTBjYjY3ZjlmZGMzZTpoOlQ6Tg>
>
>
>
> *From: *Nick Couchman <vn...@apache.org>
> *Date: *Wednesday, 26 March 2025 at 12:05
> *To: *user@guacamole.apache.org <user@guacamole.apache.org>
> *Subject: *Re: Guacamole client .onrequired
>
> On Wed, Mar 26, 2025 at 4:07 AM Gal Sabas <gal...@checkpoint.com.invalid>
> wrote:
>
> Hi,
>
>
>
> I have my own web-client that is based on guacamole-client.
>
> I’m trying to add support to the “required” request for parameter
> prompting, I added this code to my client:
>
>
>
> let client = new Guacamole.Client(tunnel)
>
> client.onrequired = function(params) {
>
> …
>
> client.send(credentials);
>
> }
>
>
>
> For some reason, no matter what I send through the credentials, guacd
> don’t seem to accept them. Do I need to disconnect from the client and then
> connect again with the credentials?
>
> Can someone please help me and maybe provide an example for and
> .onrequired?
>
>
>
>
>
> The official Guacamole Client code uses this:
>
>
>
>
> https://github.com/apache/guacamole-client/blob/78e0436dc202673686dc8a7741eca6cb21513d77/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js#L720-L728
> <https://protect.checkpoint.com/v2/r02/___https:/github.com/apache/guacamole-client/blob/78e0436dc202673686dc8a7741eca6cb21513d77/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js%23L720-L728___.YzJlOmNwYWxsOmM6bzo1M2RhZWQyNTY1NWNiZDZkMzc3ZjBjNjc4Y2M1MjkxYzo3OmIzMzI6MzA2YTM4YjUxNjhhNDhlNjU5MTc4MWQ4YTlhYWM3OTY4ZjVjZjZmNTVhNzI0NjcxYThjNTU2YjRmNTQ2MDUyNjpoOlQ6Tg>
>
>
>
> I'd highly suggest going through the Guacamole Client code, particularly
> for the AngularJS front-end, to see how it is handled in there - this block
> only takes care of letting the client know that a required instruction has
> been sent and prompting the user - you have to go to a couple of other
> places to see where the user is actually prompted and where those responses
> are actually sent back to guacd.
>
>
>
> And to answer your question, no, there is no need to disconnect and
> reconnect - in the cases where guacd sends the "required" instruction, it
> is usually because there is a call-back function from one of the supported
> protocols being invoked that needs more information and is now waiting on
> that information to be provided.
>
>
>
> I know that's a very high-level answer - feel free to post back with more
> specific/detailed questions.
>
>
>
> -Nick
>


-- 
Best Regards

Lukáš Raška

Reply via email to