Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
jmaines2 #1
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: How do I register a new account programmatically?
I'd like to have my application self-register. 

Here's what I'm attempting to do: I have a user ID that may or may not exist on the Jabber server already.
The Jabber server that I am connecting to is setup to allow for auto-registry.
I'd like to check if the account exists and if not, auto-register the account.
I'm assuming that I'd use something like xmppClient.RegisterNewAccount.

Are there parameters that need to be passed in?
Could you provide me with a quick code snippet on how to do something like this?

Thanks in advance.
Avatar
Alex #2
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by jmaines2:
I'd like to have my application self-register. 

Here's what I'm attempting to do: I have a user ID that may or may not exist on the Jabber server already.
The Jabber server that I am connecting to is setup to allow for auto-registry.
I'd like to check if the account exists and if not, auto-register the account.
I'm assuming that I'd use something like xmppClient.RegisterNewAccount.
yes this is how it works. If you can't register because the account is already in use or the server supports no registration you get the OnRegisterError event. On Success you get the OnRegisterEvent.

Quote by jmaines2:
Are there parameters that need to be passed in?
Could you provide me with a quick code snippet on how to do something like this?
In the OnRegisterInformation event you must set the registration fields like username, password, email...

here is an example:
  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.     // success
  12. }
  13.  
  14. private void xmppClient_OnRegisterError(object sender, IqEventArgs e)
  15. {
  16.     // error
  17.     xmppClient.Close();
  18. }

Alex
Avatar
jmaines2 #3
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Thanks so much for the help Alex. Hopefully, the company I'm doing this work for will purchase Matrix within the next week.
Avatar
jmaines2 #4
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Quote by Alex:
In the OnRegisterInformation event you must set the registration fields like username, password, email...

here is an example:
  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. }

Alex

What should I be replacing "Data" with? I'm getting the following message when I use the code as-is:
"The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?)"
Avatar
mrbelk #5
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
Subject: Resurrecting an old topic...
When "self registering," how does one add oneself to a roster group when registering with a particular server?

I noticed when manually adding users to OpenFire XMPP server that when I added a user to a group, that the subscriptions were automatically set up for me, with no need to acknowledge or approve them. Is that something that OpenFire does as a convenience when using its admin console, or will those subscriptions be made for me even if I self-register a new user on a server?
Avatar
Alex #6
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes, roster groups are usually just a convenience on the server side for managing users and groups. many server also have LDAP plugins for this for example.

Usually on the client side you have to add every single user, and can decide in which group you put them. Additional you have to request and send authorization to every contact, because in XMPP you can control this very granular.

Some servers have XMPP extensions where you can use the groups features also from the client side, or they have auto subscription plugins where the server automatically replies positive to every subscription request, which makes sense in many environments.
Avatar
mrbelk #7
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
I actually found a very nice REST API plugin for OpenFire that will do all this for me outside of Matrix. The subscriptions are automatically created when I use the REST API to add a user to a particular group.

Thanks,
Matthew
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