Page 1 of 1
Mikrotik API
Posted: Tue Aug 04, 2015 7:34 pm
by icu4ever
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
Re: Mikrotik API
Posted: Wed Aug 05, 2015 2:02 pm
by boen_robot
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: Mikrotik API
Posted: Fri Aug 07, 2015 8:34 am
by icu4ever
tnx, it work.
Re: Mikrotik API
Posted: Fri Aug 07, 2015 3:15 pm
by tiran
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)
Re: Mikrotik API
Posted: Fri Aug 07, 2015 5:35 pm
by boen_robot
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?
Re: Mikrotik API
Posted: Sat Aug 08, 2015 3:05 pm
by tiran
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
Re: Mikrotik API
Posted: Mon Aug 10, 2015 2:47 pm
by boen_robot
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)
Re: Mikrotik API
Posted: Tue Aug 11, 2015 9:46 am
by tiran
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.
Re: Mikrotik API
Posted: Tue Aug 11, 2015 1:40 pm
by boen_robot
Remove the spaces in the profile line:
mk.Send("=profile=general", True)
Re: Mikrotik API
Posted: Fri Aug 21, 2015 10:35 pm
by tiran
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
Re: Mikrotik API
Posted: Mon Aug 31, 2015 9:12 am
by tiran
i want to view available user profile when i load the api. it is better if i can insert profiles into combo box item
Re: Mikrotik API
Posted: Tue Oct 06, 2015 10:05 pm
by mrtasneemk
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.
Re: Mikrotik API
Posted: Sat May 21, 2016 1:48 am
by zackc95
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?