Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
martinbach #1
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Subject: How to Register a new Account on an xmpp server
Hi Alex,

I tried to register a new account on a xmpp server via Matrix.Xmpp.Register.Register.
But this seems not to work.
How do I register a new account via MatriX for .Net on e.g. web.jabber.ccc.de or jabber.org ?

Thank you
Martin
Avatar
Alex #2
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I added registration for the next version. I will upload a new binary for the full framework tomorrow and post the link here.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
new dll is here http://www.ag-software.net/downloads.html when you navigate to  MatriX > Release > Full.

You have to set RegisterNewAccount = true. Then subscribe to the events OnRegisterInformation, OnRegister and OnRegisterError.
In OnRegisterInformation you have to set the Register Info automatically or display a XData form in the user interface.

  1. private void xmppClient_OnRegisterInformation(object sender, RegisterEventArgs e)
  2. {
  3.     e.Register.RemoveAll<Data>();
  4.    
  5.     e.Register.Username = xmppClient.Username;
  6.     e.Register.Password = xmppClient.Password;
  7. }
  8.  
  9. private void xmppClient_OnRegister(object sender, EventArgs e)
  10. {
  11.  
  12. }
  13.  
  14. private void xmppClient_OnRegisterError(object sender, IqEventArgs e)
  15. {
  16.     xmppClient.Close();
  17. }

Alex
Avatar
martinbach #4
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Hi Alex,

thanks! I' ll try it asap.

Martin
Avatar
martinbach #5
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Hi Alex,

I tried to register a new account on openfire, but got always the error:

<error code="400" type="modify" xmlns="jabber:client">
  <jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
</error>

Here is the used code:
        XmppClient xmppClientToRegister;

        private void buttonRegisterNewAccount_Click_1(object sender, System.EventArgs e)
        {       
            xmppClientToRegister = new XmppClient(textBoxNewUsernameNewAccount.Text, textBoxDomainNewAccount.Text, textBoxPasswordNewAccount.Text);
            xmppClientToRegister.Hostname = "localhost";
            xmppClientToRegister.RegisterNewAccount = true;
            xmppClientToRegister.OnRegister += new EventHandler<Matrix.EventArgs>(xmppClient_OnRegister);
            xmppClientToRegister.OnRegisterError += new EventHandler<IqEventArgs>(xmppClient_OnRegisterError);
            xmppClientToRegister.OnRegisterInformation += new EventHandler<Matrix.Xmpp.Register.RegisterEventArgs>(xmppClient_OnRegisterInformation);
            xmppClientToRegister.Open();
        }

        void xmppClient_OnRegisterInformation(object sender, Matrix.Xmpp.Register.RegisterEventArgs e)
        {
            this.richTextBoxLoggingNewAccount.Text = "... trying to register new user ...";
            e.Register.RemoveAll<Data>();
            e.Register.Username = xmppClientToRegister.Username;
            e.Register.Password = xmppClientToRegister.Password;
        }

        void xmppClient_OnRegisterError(object sender, IqEventArgs e)
        {
            this.richTextBoxLoggingNewAccount.Text = "Error !: " + e.Iq.Error.ToString();
            xmppClientToRegister.Close();
        }

        void xmppClient_OnRegister(object sender, Matrix.EventArgs e)
        {

        }

I'm sure I did something wrong ... but what ?

Do you have an idea?

Thanks
Martin
Avatar
Alex #6
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please post your xml log. According to the error message there is a problem with the jid.

Alex
Avatar
martinbach #7
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Hi Alex,

here is my log:

Connecting to maltin3@yk8j072337/MatriX ...
OnSendXml: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="yk8j072337" version="1.0" >
OnReceivingXml: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="yk8j072337" id="6eb6c785" xml:lang="en" version="1.0" >
OnReceivingXml: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    <mechanism>DIGEST-MD5</mechanism>
    <mechanism>PLAIN</mechanism>
    <mechanism>ANONYMOUS</mechanism>
    <mechanism>CRAM-MD5</mechanism>
  </mechanisms>
  <compression xmlns="http://jabber.org/features/compress">
    <method>zlib</method>
  </compression>
  <auth xmlns="http://jabber.org/features/iq-auth" />
  <register xmlns="http://jabber.org/features/iq-register" />
</stream:features>
OnSendXml: <iq id="MX_1" type="get" to="yk8j072337" xmlns="jabber:client">
  <query xmlns="jabber:iq:register" />
</iq>
OnReceivingXml: <iq type="result" id="MX_1" from="yk8j072337" xmlns="jabber:client">
  <query xmlns="jabber:iq:register">
    <username />
    <password />
    <email />
    <name />
    <x xmlns="jabber:x:data" type="form">
      <title>XMPP Client Registration</title>
      <instructions>Please provide the following information</instructions>
      <field var="FORM_TYPE" type="hidden">
        <value>jabber:iq:register</value>
      </field>
      <field label="Username" var="username" type="text-single">
        <required />
      </field>
      <field label="Full name" var="name" type="text-single" />
      <field label="Email" var="email" type="text-single" />
      <field label="Password" var="password" type="text-private">
        <required />
      </field>
    </x>
  </query>
</iq>
 OnRegisterInformation: maltin3 
OnSendXml: <iq type="set" to="yk8j072337" id="MX_2" xmlns="jabber:client">
  <query xmlns="jabber:iq:register">
    <username>maltin3</username>
    <password>popania</password>
    <email />
    <name />
    <x xmlns="jabber:x:data" type="form">
      <title>XMPP Client Registration</title>
      <instructions>Please provide the following information</instructions>
      <field var="FORM_TYPE" type="hidden">
        <value>jabber:iq:register</value>
      </field>
      <field label="Username" var="username" type="text-single">
        <required />
      </field>
      <field label="Full name" var="name" type="text-single" />
      <field label="Email" var="email" type="text-single" />
      <field label="Password" var="password" type="text-private">
        <required />
      </field>
    </x>
  </query>
</iq>
OnReceivingXml: <iq type="error" id="MX_2" from="yk8j072337" to="yk8j072337/6eb6c785" xmlns="jabber:client">
  <query xmlns="jabber:iq:register">
    <username>maltin3</username>
    <password>popania</password>
    <email />
    <name />
    <x xmlns="jabber:x:data" type="form">
      <title>XMPP Client Registration</title>
      <instructions>Please provide the following information</instructions>
      <field var="FORM_TYPE" type="hidden">
        <value>jabber:iq:register</value>
      </field>
      <field label="Username" var="username" type="text-single">
        <required />
      </field>
      <field label="Full name" var="name" type="text-single" />
      <field label="Email" var="email" type="text-single" />
      <field label="Password" var="password" type="text-private">
        <required />
      </field>
    </x>
  </query>
  <error code="400" type="modify">
    <jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
  </error>
</iq>
 OnRegisterError:
OnSendXml: </stream:stream>
OnReceivingXml: </stream:stream>


Thanks,
Martin
Avatar
Alex #8
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you don't remove the XData object from the RegisterInfo object. This should be the problem.

Alex
Avatar
martinbach #9
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Alex,

I scanned my whole source code but couldn't find any XData object to remove.
So I tired:

e.Register.Data.Remove();

... and it works now  :-)

Can you tell me a little bit why I have to do this ?

Thank you.
Martin
Avatar
Alex #10
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The server send you the following information for registering:

  1. <iq type="result" id="MX_1" from="yk8j072337" xmlns="jabber:client">
  2.  <query xmlns="jabber:iq:register">
  3.     <!--
  4.       Option 1
  5.      --->
  6.     <username />
  7.     <password />
  8.     <email />
  9.     <name />
  10.     <!--
  11.       Option 2
  12.     --->
  13.     <x xmlns="jabber:x:data" type="form">
  14.       <title>XMPP Client Registration</title>
  15.       <instructions>Please provide the following information</instructions>
  16.       <field var="FORM_TYPE" type="hidden">
  17.         <value>jabber:iq:register</value>
  18.       </field>
  19.       <field label="Username" var="username" type="text-single">
  20.         <required />
  21.       </field>
  22.       <field label="Full name" var="name" type="text-single" />
  23.       <field label="Email" var="email" type="text-single" />
  24.       <field label="Password" var="password" type="text-private">
  25.         <required />
  26.       </field>
  27.     </x>
  28.  </query>
  29. </iq>

This iq has 2 options, either you use the provided xdata form for registering, or the simple <username /> <password /> <email /> <name /> tags. You have chosen the latter as I did in my example above. You reused the Register element and filled out username, password fields, but you didn't remove or fill our the xdata from which is causing an error on the Openfire server.

Alex
Avatar
martinbach #11
Member since Mar 2009 · 60 posts
Group memberships: Members, Premium
Show profile · Link to this post
Hi Alex,

great help !! Thank you.

Martin
Avatar
anandafit #12
Member since May 2011 · 1 post
Group memberships: Members
Show profile · Link to this post
Here you can find a solution for how to register new user in xmpp server using xmpphp http://anandafit.info/2011/05/10/register-new-xmpp-users-w…
Avatar
Arthur #13
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: I'm having problems registering a new account
Hi Alex,

I'm not able to register a new account on an xmpp server.  I'm using the Matrix lib version 1.4.0.1.  I added a button to the MiniClient sample app.

private void button1_Click(object sender, System.EventArgs e)
{
                xmppClient.SetUsername(txtUsername.Text);
                xmppClient.SetXmppDomain(txtServer.Text);
                xmppClient.Password = txtPassword.Text;
      xmppClient.RegisterNewAccount = true;

                xmppClient.Open();
}

When I run the app and click the button the "OnAuthError" event gets fired.  Here is the debug xml:

SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="xmpp.someplace.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="xmpp.someplace.com" id="60335c09" xml:lang="en" version="1.0" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    <mechanism>DIGEST-MD5</mechanism>
    <mechanism>PLAIN</mechanism>
    <mechanism>CRAM-MD5</mechanism>
  </mechanisms>
  <compression xmlns="http://jabber.org/features/compress">
    <method>zlib</method>
  </compression>
  <auth xmlns="http://jabber.org/features/iq-auth" />
</stream:features>
SEND: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09InhtcHAtZGV2Lm1pdGNoZWxsLmNvbSIsbm9uY2U9IkcxV1JVemVLejROcmtCUTQzRzlDKzF5SUJNNXpwV0E1MXlxL0RuYXYiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InJlZ2lzdGVydGVzdCIscmVhbG09InhtcHAtZGV2Lm1pdGNoZWxsLmNvbSIsbm9uY2U9IkcxV1JVemVLejROcmtCUTQzRzlDKzF5SUJNNXpwV0E1MXlxL0RuYXYiLGNub25jZT0iNjI0MTczMTFiZjVhYmE3ZWJmODc2M2Y2NTU0NjNiMTE0MWRkZjFhNmQwMTQ2YWZiYzA4ZWU5OGZlZjQwOGE1NSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC94bXBwLWRldi5taXRjaGVsbC5jb20iLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9ZWY1YmQ1MTk5MjdjMDgxYTNhNTQxMzYwNGI1NDM4MmQ=</response>
RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  <not-authorized />
</failure>
SEND: </stream:stream>
RECV: </stream:stream>

There are some differences between my xml log and martin's.  I seem to be missing
"<register xmlns="http://jabber.org/features/iq-register" />"
and
"<iq id="MX_1" type="get" to="yk8j072337" xmlns="jabber:client"><query xmlns="jabber:iq:register" /></iq>"

Any suggestions?  Thanks.
Avatar
Alex #14
Member since Feb 2003 · 4311 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Your server does not advertise the register stream feature. When the feature is not advertised  matrix does not register accounts because the missing feature stands for disabled registration.

Alex
Avatar
Arthur #15
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex.  Everything worked after we turned the feature on.
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