Community discussions

MikroTik App
 
icu4ever
just joined
Topic Author
Posts: 6
Joined: Tue Aug 04, 2015 7:25 pm

Mikrotik API

Tue Aug 04, 2015 7:34 pm

Hi,

I'm creating an app to connect Mikrotik user manager,

i can add user with this command :

/tool/user-manager/user/add
=customer=admin
=username=u11
=password=u11
=location=park
=first-name=fname
=last-name=lname
=shared-users=1
=copy-from=IT

only when i add a user with command i got the "id"

for remove or change the user information such as password, and other information i need "id"

how can i find the "id" of user

Here is the remove and change mikrotik command :

---- ***** User Manager --> Delete User

/tool/user-manager/user/remove
=.id=*88


---- ***** User Manager --> SET User


/tool/user-manager/user/set
=.id=*14
=username=somenewuser
=password=somenewpassword
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API

Wed Aug 05, 2015 2:02 pm

In menus where there's a name, you don't need to find an ID. You can use the name instead. This is certainly the case with the user manager's "user" menu, so f.e.
/tool/user-manager/user/set
=.id=u11
=username=somenewuser
=password=somenewpassword
In menus where there's no name, you can use the "print" command to get a list of all IDs in a menu. You can add a query to it to find a specific item's ID, and you can add the ".proplist" argument to limit the returned properties to just the ID, e.g.
/tool/user-manager/user/print
=.proplist=.id
?username=u11
will return
!re
=.id=*14

!done
 
icu4ever
just joined
Topic Author
Posts: 6
Joined: Tue Aug 04, 2015 7:25 pm

Re: Mikrotik API

Fri Aug 07, 2015 8:34 am

tnx, it work.
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: Mikrotik API

Fri Aug 07, 2015 3:15 pm

mk.Send("/tool/user-manager/user/add", False)
mk.Send("=customer=admin", False)
mk.Send("=username=" & tb_name.Text & "", False)
mk.Send("=password=" & tb_password.Text & "", False)
mk.Send("=shared-users=3", False)
mk.Send("=;create-and-activate-profile=" & tb_name.Text & "", False)
mk.Send("=customer=admin", False)
mk.Send("=profile = general", True)

i am try to add user form visual basic API from above code. but result of the above code is unknown parameter. but if am i use following code i can create user successfully. any one can help me..?

mk.Send("/tool/user-manager/user/add", False)
mk.Send("=customer=admin", False)
mk.Send("=username=" & tb_name.Text & "", False)
mk.Send("=password=" & tb_password.Text & "", False)
mk.Send("=copyfrom=0", true)
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API

Fri Aug 07, 2015 5:35 pm

If your code is literally a "copy&paste", then the line
mk.Send("=;create-and-activate-profile=" & tb_name.Text & "", False)
is where the problem is at.

Remove the ";" at the start there.

Also... Isn't "create-and-active-profile" a separate command altogether?
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: Mikrotik API

Sat Aug 08, 2015 3:05 pm

If your code is literally a "copy&paste", then the line
mk.Send("=;create-and-activate-profile=" & tb_name.Text & "", False)
is where the problem is at.

Remove the ";" at the start there.

Also... Isn't "create-and-active-profile" a separate command altogether?
actually i want to send following win box terminal code from visual basic
add customer=admin username=name passwor
d=password;create-and-activate-profile name customer=admin profile=general
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API

Mon Aug 10, 2015 2:47 pm

Right. In Winbox's terminal, those are two different commands. Therefore, you need to send two separate sentences, e.g.
mk.Send("/tool/user-manager/user/add", False)
mk.Send("=customer=admin", False)
mk.Send("=username=" & tb_name.Text & "", False)
mk.Send("=password=" & tb_password.Text & "", False)
mk.Send("=shared-users=3", True)

mk.Send("/tool/user-manager/user/create-and-activate-profile", False)
mk.Send("=numbers=" & tb_name.Text & "", False)
mk.Send("=customer=admin", False)
mk.Send("=profile = general", True)
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: Mikrotik API

Tue Aug 11, 2015 9:46 am

Right. In Winbox's terminal, those are two different commands. Therefore, you need to send two separate sentences, e.g.
mk.Send("/tool/user-manager/user/add", False)
mk.Send("=customer=admin", False)
mk.Send("=username=" & tb_name.Text & "", False)
mk.Send("=password=" & tb_password.Text & "", False)
mk.Send("=shared-users=3", True)

mk.Send("/tool/user-manager/user/create-and-activate-profile", False)
mk.Send("=numbers=" & tb_name.Text & "", False)
mk.Send("=customer=admin", False)
mk.Send("=profile = general", True)
i tried above code. that create user, but not assign profile "general" to users.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API

Tue Aug 11, 2015 1:40 pm

Remove the spaces in the profile line:
mk.Send("=profile=general", True)
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: Mikrotik API

Fri Aug 21, 2015 10:35 pm

Remove the spaces in the profile line:
mk.Send("=profile=general", True)
ok done. now i want to develop this code to create user batch
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: Mikrotik API

Mon Aug 31, 2015 9:12 am

i want to view available user profile when i load the api. it is better if i can insert profiles into combo box item
 
mrtasneemk
just joined
Posts: 2
Joined: Sat Jun 27, 2015 7:30 pm

Re: Mikrotik API

Tue Oct 06, 2015 10:05 pm

Hi having some problem with my code

mikrotik.Send("/tool/user-manager/user/create-and-activate-profile");
mikrotik.Send("=numbers=user1");
mikrotik.Send("=customer=admin");
mikrotik.Send("=profile=1Mbps",true );
this is not assigning any profile

Please help.
 
zackc95
just joined
Posts: 2
Joined: Fri May 20, 2016 8:58 pm

Re: Mikrotik API

Sat May 21, 2016 1:48 am

I am using the Java api to connect to my Mikrotik and change the users password. I can connect to the router but not run the command. I have tried multiple different ways and tried to learn how to write the commands in the api but without any luck. Is anyone willing to help me figure out how to write the code?

Who is online

Users browsing this forum: No registered users and 71 guests