Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Sterner #1
Member since Oct 2015 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: XEP-0133: Service Administration
Hi

Could please provide an example of service administration if it is supported by Matrix, for example "Add User" flow.
I have found AdminIq class, but didn't find Command.
Ejabberd is used as server.

Thank you in advance
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

usually this is done over XEP-0050: Ad-Hoc Commands

Please check if your server supports this. If you have any question on how to build a special packet with MatriX for it let us know and we will provide you the code snippets.

Alex
Avatar
Sterner #3
Member since Oct 2015 · 6 posts
Group memberships: Members
Show profile · Link to this post
Hi

Server supports them. Please provide an example of usage, because I didn't find any information about user management in specification.

It will be very appreciated.
Avatar
Alex #4
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Here is how it works on our Prosody server. Ejabberd should be the same.

1) Send a Disco Items request to the commands node to get all available commands to execute:

Code:
  1. var dm = new DiscoManager(xmppClient);
  2. var itemsResultIq = await dm.DiscoverItemsAsync("ag-software.net", "alex@ag-software.net/Matrix", Namespaces.AdHocCommands);

XML:
  1. SEND:
  2. <iq type="get" to="ag-software.net" id="MX-5">
  3. <query xmlns="http://jabber.org/protocol/disco#items" node="http://jabber.org/protocol/commands"/>
  4. </iq>
  5.  
  6. RECV:
  7. <iq from="ag-software.net" type="result" id="MX-5" to="alex@ag-software.net/Matrix">
  8. <query xmlns="http://jabber.org/protocol/disco#items" node="http://jabber.org/protocol/commands">
  9. <item node="http://jabber.org/protocol/admin#get-user-password" name="Get User Password" jid="ag-software.net"/>
  10. <item node="http://jabber.org/protocol/admin#delete-user" name="Delete User" jid="ag-software.net"/>
  11. <item node="http://prosody.im/protocol/modules#global-load" name="Globally load module" jid="ag-software.net"/>
  12. <item node="http://jabber.org/protocol/admin#get-user-roster" name="Get User Roster" jid="ag-software.net"/>
  13. <item node="http://jabber.org/protocol/admin#change-user-password" name="Change User Password" jid="ag-software.net"/>
  14. <item node="http://jabber.org/protocol/admin#get-online-users-list" name="Get List of Online Users" jid="ag-software.net"/>
  15. <item node="http://prosody.im/protocol/modules#list" name="List loaded modules" jid="ag-software.net"/>
  16. <item node="http://jabber.org/protocol/admin#add-user" name="Add User" jid="ag-software.net"/>
  17. <item node="http://prosody.im/protocol/modules#global-unload" name="Globally unload module" jid="ag-software.net"/>
  18. <item node="ping" name="Ping" jid="ag-software.net"/>
  19. <item node="http://prosody.im/protocol/hosts#deactivate" name="Deactivate host" jid="ag-software.net"/>
  20. <item node="http://prosody.im/protocol/hosts#activate" name="Activate host" jid="ag-software.net"/>
  21. <item node="http://prosody.im/protocol/modules#reload" name="Reload modules" jid="ag-software.net"/>
  22. <item node="http://prosody.im/protocol/modules#global-reload" name="Globally reload module" jid="ag-software.net"/>
  23. <item node="http://jabber.org/protocol/admin#user-stats" name="Get User Statistics" jid="ag-software.net"/>
  24. <item node="uptime" name="Get uptime" jid="ag-software.net"/>
  25. <item node="http://prosody.im/protocol/modules#load" name="Load module" jid="ag-software.net"/>
  26. <item node="http://prosody.im/protocol/modules#unload" name="Unload modules" jid="ag-software.net"/>
  27. <item node="http://jabber.org/protocol/admin#shutdown" name="Shut Down Service" jid="ag-software.net"/>
  28. <item node="http://jabber.org/protocol/admin#end-user-session" name="End User Session" jid="ag-software.net"/>
  29. <item node="http://prosody.im/protocol/config#reload" name="Reload configuration" jid="ag-software.net"/>
  30. </query>
  31. </iq>

As you can see in the list is the add user command:
http://jabber.org/protocol/admin#add-user

2) now I send a command query of type set, and the server returns me a data from.

Code:
  1. var iq = new IqQuery<Matrix.Xmpp.AdHocCommands.Command>
  2.    {
  3.       To = "ag-software.net",
  4.       Type = IqType.Set,       
  5.    };
  6. iq.Query.Node = "http://jabber.org/protocol/admin#add-user";
  7. var result = await xmppClient.IqFilter.SendIqAsync(iq);

Xml:
  1. SEND:
  2. <iq type="set" to="ag-software.net" id="MX-6">
  3. <command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#add-user"/>
  4. </iq>
  5.  
  6. RECEIVE:
  7. <iq from="ag-software.net" type="result" id="MX-6" to="alex@ag-software.net/Matrix">
  8. <command xmlns="http://jabber.org/protocol/commands" status="executing" node="http://jabber.org/protocol/admin#add-user" sessionid="f0eb1bfb-9f1e-462f-a5d4-ec5662e8a314">
  9. <x xmlns="jabber:x:data" type="form">
  10. <title>Adding a User</title>
  11. <instructions>Fill out this form to add a user.</instructions>
  12. <field type="hidden" var="FORM_TYPE">
  13. <value>http://jabber.org/protocol/admin</value>
  14. </field>
  15. <field type="jid-single" label="The Jabber ID for the account to be added" var="accountjid">
  16. <required/>
  17. </field>
  18. <field type="text-private" label="The password for this account" var="password"/>
  19. <field type="text-private" label="Retype password" var="password-verify"/>
  20. </x>
  21. <actions execute="complete">
  22. <next/>
  23. <complete/>
  24. </actions>
  25. </command>
  26. </iq>

3) I fill out the form, execute the command, and the server returns sucess.

  1. SEND:
  2. <iq type="set" to="ag-software.net" id="MX-7">
  3. <command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#add-user" sessionid="f0eb1bfb-9f1e-462f-a5d4-ec5662e8a314">
  4. <x xmlns="jabber:x:data" type="submit">
  5. <field type="hidden" var="FORM_TYPE">
  6. <value>http://jabber.org/protocol/admin</value>
  7. </field>
  8. <field type="jid-single" var="accountjid">
  9. <value>foo1@ag-software.net</value>
  10. </field>
  11. <field type="text-private" var="password">
  12. <value>secret</value>
  13. </field>
  14. <field type="text-private" var="password-verify">
  15. <value>secret</value>
  16. </field>
  17. </x>
  18. </command>
  19. </iq>
  20.  
  21. RECV:
  22. <iq from="ag-software.net" type="result" id="MX-7" to="alex@ag-software.net/Matrix">
  23. <command xmlns="http://jabber.org/protocol/commands" status="completed" node="http://jabber.org/protocol/admin#add-user" sessionid="f0eb1bfb-9f1e-462f-a5d4-ec5662e8a314">
  24. <note type="info">Account successfully created</note>
  25. </command>
  26. </iq>

If you want to build a UI from Dataforms then plkease take a look at the code we published here:
  • https://gitlab.com/matrix-xmpp/data-forms-ui
  • https://gitlab.com/matrix-xmpp/samples/tree/master/csharp/XDataUI

let me know if this helps.

Alex
Avatar
Sterner #5
Member since Oct 2015 · 6 posts
Group memberships: Members
Show profile · Link to this post
Thanks
Everything works fine.
Avatar
Alex #6
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS