Community discussions

 
mauri
just joined
Topic Author
Posts: 5
Joined: Thu Feb 28, 2013 1:37 am

c# api create hotspot user command

Thu Feb 28, 2013 1:46 am

hi,
What is the c# api command to create the hotspot user?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: c# api create hotspot user command

Thu Feb 28, 2013 7:40 pm

Same as with any other client:
/ip/hotspot/user/add
=name=username
=password=password
=profile=profile1
The exact C# code would depend on which C# client we're talking about.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
mauri
just joined
Topic Author
Posts: 5
Joined: Thu Feb 28, 2013 1:37 am

Re: c# api create hotspot user command

Thu Feb 28, 2013 8:54 pm

hi boen_robot,


Mikrotik RB1100AHx2 1U Router Firewall
RouterOS v5.23
WS 2010

c# api class = http://wiki.mikrotik.com/wiki/API_in_C_Sharp

code =

private void createuserBtn_Click(object sender, EventArgs e)
{
MK mikrotik = new MK("x.x.x.197");
if (!mikrotik.Login("admin", "123"))
{
MessageBox.Show("no connect");
mikrotik.Close();
return;
}
MessageBox.Show("connect");

mikrotik.Send("/ip/hotspot/user/add");
mikrotik.Send("=name=999");
mikrotik.Send("=password=999");
mikrotik.Send("=profile=profile1");

//MessageBox.Show("create user");
mikrotik.Close();
}

result =
connect ok,
create user no,
disconnect ok.

? = Why not create a user... :)
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: c# api create hotspot user command

Thu Feb 28, 2013 9:27 pm

Add "false" as a second argument to each method, to ensure all API words are part of the same API sentence.

i.e.
MK mikrotik = new MK("x.x.x.197");
 if (!mikrotik.Login("admin", "123"))
 {
 MessageBox.Show("no connect");
 mikrotik.Close();
 return;
 }
 MessageBox.Show("connect");

 mikrotik.Send("/ip/hotspot/user/add", false);
 mikrotik.Send("=name=999", false);
 mikrotik.Send("=password=999", false);
 mikrotik.Send("=profile=profile1");

 //MessageBox.Show("create user");
 mikrotik.Close();
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
mauri
just joined
Topic Author
Posts: 5
Joined: Thu Feb 28, 2013 1:37 am

Re: c# api create hotspot user command

Thu Feb 28, 2013 9:48 pm

Thanks
I tried but it does not ...
:(
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: c# api create hotspot user command

Thu Feb 28, 2013 10:12 pm

Perhaps you need to explicitly do a Read() too, even if you're not going to use the results, e.g.
mikrotik.Send("=profile=profile1");
mikrotik.Read();
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
mauri
just joined
Topic Author
Posts: 5
Joined: Thu Feb 28, 2013 1:37 am

Re: c# api create hotspot user command

Fri Mar 01, 2013 1:27 am

hi,

not create user.
:(
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: c# api create hotspot user command

Fri Mar 01, 2013 1:36 am

Looking at the source, it seems this client has a big bug in it... the "false" thing doesn't really work - it's ignored. More importantly though, it always finishes the API sentence. But not all is lost. The version without a second argument doesn't finish the API sentence, oddly enough.

So, in combination with the Read() thing, you should be able to do it with:
MK mikrotik = new MK("x.x.x.197");
 if (!mikrotik.Login("admin", "123"))
 {
 MessageBox.Show("no connect");
 mikrotik.Close();
 return;
 }
 MessageBox.Show("connect");

 mikrotik.Send("/ip/hotspot/user/add");
 mikrotik.Send("=name=999");
 mikrotik.Send("=password=999");
 mikrotik.Send("=profile=profile1", true);
 mikrotik.Read();

 //MessageBox.Show("create user");
 mikrotik.Close();
If even that doesn't work, I'd highly advise you to use the other C# client - the one at the bottom of the API spec.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
mauri
just joined
Topic Author
Posts: 5
Joined: Thu Feb 28, 2013 1:37 am

Re: c# api create hotspot user command

Sun Mar 03, 2013 10:29 pm

hi,

thanks.

not with api, I'm trying to ssh in c#
 
akmjahangir
newbie
Posts: 48
Joined: Sun Aug 10, 2008 8:27 pm
Location: Dhaka, Bangladesh
Contact:

Re: c# api create hotspot user command

Sun Apr 14, 2013 7:23 am

now hotspot user's balance can view from client pc

http://forum.mikrotik.com/viewtopic.php ... 71#p364571
A.K.M. Jahangir
(Mikrotik listed 1st consultant of BD)
ED & Head of NOC, Bijoy Online Ltd.
Chief Technical Officer & Partner of IMC Plus
Phone: 01819-231755, Skype: jahan_bijoy web: www.bijoy.net/jahan/
BSc(Hons), MSc, DU. MTCNA (Egypt,2007), MTCNA, MTCRE, MTCTCE.
 
solonxpl
just joined
Posts: 4
Joined: Tue Apr 14, 2015 7:33 pm

Re: c# api create hotspot user command

Tue Apr 14, 2015 7:49 pm

I have a C# application where I need to update a usermanager user
I use this code
  		MikrotikApi.Send("/tool/user-manager/user/set");
                MikrotikApi.Send("=name=" + username);
                MikrotikApi.Send("=first-name=" + firstName);
                MikrotikApi.Send("=comment=" + comment);
                MikrotikApi.Send("=email=" + email);
                MikrotikApi.Send("=password=" + password);
                MikrotikApi.Send("=customer=admin", true);
And the code is executed with no error.
Yet nothing gets updated . WHY ??? what did I forget here?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: c# api create hotspot user command

Tue Apr 14, 2015 9:50 pm

Use the argument "numbers" to target items. Everything else is the new value you want for that user (e.g. if you want to rename a user, you'll want "numbers" with the current username, and "name" with the new username).

The "numbers" argument I think accepts the username, but if it doesn't, you'll need to use the "print" command with a query, to get the user's ID.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
solonxpl
just joined
Posts: 4
Joined: Tue Apr 14, 2015 7:33 pm

Re: c# api create hotspot user command

Tue Apr 14, 2015 10:22 pm

Use the argument "numbers" to target items. Everything else is the new value you want for that user (e.g. if you want to rename a user, you'll want "numbers" with the current username, and "name" with the new username).

The "numbers" argument I think accepts the username, but if it doesn't, you'll need to use the "print" command with a query, to get the user's ID.
I did it already thanks for the quick reply :D
 
manchado20
just joined
Posts: 2
Joined: Sun May 27, 2018 7:28 pm

Question c# api create hotspot user command

Sun May 27, 2018 7:55 pm

Goodnight.

I have a question, I am trying to add users through the hotspot what happens is that in this code the winbox does not receive the password, only the created user is displayed, I thought it was the false but the same error still appears.

Thank you.

This is the code

class Program
{
static void Main (string [] args)
{
MK mikrotik = new MK ("10.10.0.254");
if (! mikrotik.Login ("itamar", "12345678"))
{
Console.WriteLine ("The account could not be entered");
Console.ReadKey ();
mikrotik.Close ();
return;
}
//mikrotik.Send("/system/identity/getall ");
//mikrotik.Send(".tag=sss ", true);
mikrotik.Send ("/ ip / hotspot / user / add");
mikrotik.Send ("= name = user1", false);
mikrotik.Send ("= password = new2", false);
mikrotik.Send ("= profile = profile1", true);
Console.WriteLine ("created user");

foreach (string h in mikrotik.Read ())
{
Console.WriteLine (h);
}
Console.ReadKey ();
}
}
 
arnel
just joined
Posts: 1
Joined: Sat Jul 21, 2018 8:49 am

Re: c# api create hotspot user command

Sat Jul 21, 2018 8:52 am

can we add a new user with time limits?
 
Roberson
just joined
Posts: 2
Joined: Mon Aug 27, 2018 3:03 pm

Re: c# api create hotspot user command

Mon Aug 27, 2018 4:03 pm

Good morning, I'm with this error, someone has a solution.
thank you
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: MSN [Bot] and 15 guests